From dc9946533eb06ace7a62b6b252402f4978692c62 Mon Sep 17 00:00:00 2001 From: Migatu Date: Fri, 23 Jun 2023 20:06:18 +0200 Subject: [PATCH] Various fixes Trunk + mod FIx --- .gitignore | 39 +++++++++++++++++++++++++++++++++++++++ .trunk/.gitignore | 8 ++++++++ .trunk/trunk.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 7 ++++++- bot.py | 26 ++++++++++++++------------ settings.json | 7 +++++++ 6 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 .trunk/.gitignore create mode 100644 .trunk/trunk.yaml diff --git a/.gitignore b/.gitignore index 68bc17f..78099cb 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,42 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +package-lock.json +package.json +.vscode/settings.json +node_modules/.package-lock.json +node_modules/.bin/prettier +node_modules/prettier/bin-prettier.js +node_modules/prettier/cli.js +node_modules/prettier/doc.js +node_modules/prettier/index.js +node_modules/prettier/LICENSE +node_modules/prettier/package.json +node_modules/prettier/parser-angular.js +node_modules/prettier/parser-babel.js +node_modules/prettier/parser-espree.js +node_modules/prettier/parser-flow.js +node_modules/prettier/parser-glimmer.js +node_modules/prettier/parser-graphql.js +node_modules/prettier/parser-html.js +node_modules/prettier/parser-markdown.js +node_modules/prettier/parser-meriyah.js +node_modules/prettier/parser-postcss.js +node_modules/prettier/parser-typescript.js +node_modules/prettier/parser-yaml.js +node_modules/prettier/README.md +node_modules/prettier/standalone.js +node_modules/prettier/third-party.js +node_modules/prettier/esm/parser-angular.mjs +node_modules/prettier/esm/parser-babel.mjs +node_modules/prettier/esm/parser-espree.mjs +node_modules/prettier/esm/parser-flow.mjs +node_modules/prettier/esm/parser-glimmer.mjs +node_modules/prettier/esm/parser-graphql.mjs +node_modules/prettier/esm/parser-html.mjs +node_modules/prettier/esm/parser-markdown.mjs +node_modules/prettier/esm/parser-meriyah.mjs +node_modules/prettier/esm/parser-postcss.mjs +node_modules/prettier/esm/parser-typescript.mjs +node_modules/prettier/esm/parser-yaml.mjs +node_modules/prettier/esm/standalone.mjs diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 0000000..8130ba6 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,8 @@ +*out +*logs +*actions +*notifications +plugins +user_trunk.yaml +user.yaml +shims diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 0000000..79fe373 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,41 @@ +version: 0.1 +cli: + version: 1.11.1 +plugins: + sources: + - id: trunk + ref: v0.0.20 + uri: https://github.com/trunk-io/plugins +lint: + enabled: + - pylint + - codespell + - cspell + - git-diff-check + - eslint + - prettier + - semgrep + - autopep8 + - bandit + - black + - flake8 + - isort + - mypy + - pylint + - ruff + - semgrep + - yapf + - gitleaks + +runtimes: + enabled: + - go@1.19.5 + - node@18.12.1 + - python@3.10.6 +actions: + disabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + enabled: + - trunk-upgrade-available diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c8b1b3..a5026fb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,9 @@ { "python.linting.enabled": true, - "python.linting.pylintEnabled": true + "python.linting.pylintEnabled": true, + "trunk.inlineDecorators": true, + "trunk.inlineDecoratorsForAllExtensions": true, + "trunk.showPreexistingIssues": true, + "trunk.autoInit": true, + "trunk.showBelowThresholdIssues": true } \ No newline at end of file diff --git a/bot.py b/bot.py index 5a6f193..d75113f 100644 --- a/bot.py +++ b/bot.py @@ -24,7 +24,7 @@ from logging import handlers from pathlib import Path, PurePath from platform import uname from sys import platform -from typing import List, TypedDict, Optional +from typing import List, Optional, TypedDict # *==============Imported libraries import discord @@ -53,10 +53,12 @@ Music_Config = TypedDict( ) # *=========================================== Predefines -formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") +formatter = logging.Formatter( + "%(asctime)s - %(name)s - %(levelname)s - %(message)s") MASTER_TIMEOUT = datetime.now() INITIAL_TIME_WAIT = 5 -MUZYKA: Music_Config = {"playing": False, "ctx": None, "queue": [], "requestor": []} +MUZYKA: Music_Config = {"playing": False, + "ctx": None, "queue": [], "requestor": []} LOGFILE = "" NETRC_FILE = "" @@ -363,7 +365,6 @@ async def disconnect(ctx): # trunk-ignore(pylint/R0915) -# trunk-ignore(pylint/R0914) # trunk-ignore(pylint/R0912) async def play(ctx, zamawial=None, arg=None): """ @@ -449,7 +450,6 @@ async def check(): """Funkcja sprawdzająca czy grać następny kawałek.""" while True: # TODO: Tu dołożyć skanowanie rozmiaru pliku logowania oraz plików pamięci i przenoszenie ich na większy dysk. - # TODO: Dodać typing i dać znać że wykonuje operacje porządkowania Baru (zamiata, układa szklanki itp.) # trunk-ignore(codespell/misspelled) # TODO: dlaczego sie tu wypierdala if client.voice_clients: @@ -631,7 +631,8 @@ async def get_file(ctx, source, link): item_type, item_id = spotify.parse_spotify_url(link) if item_id: file_list = spotify.fetch_tracks(spotify_ctrl, item_type, link) - directory_name = spotify.get_item_name(spotify_ctrl, item_type, item_id) + directory_name = spotify.get_item_name( + spotify_ctrl, item_type, item_id) url_data = {"urls": []} url_dict = {} url_dict["save_path"] = Path( @@ -788,10 +789,8 @@ async def wyszukaj(ctx, how_many=0): logger.info("Słowo kluczowe: %s", word) itr = 0 for file in music_file_list: - if platform == "win32": - file = file.split("\\") - else: - file = file.split("/") + file = file.split(SEPARATOR_FILE_PATH) + char_remove = [ ".", "^", @@ -804,6 +803,7 @@ async def wyszukaj(ctx, how_many=0): "[", "]", "\\", + "/", "|", "(", ")", @@ -832,13 +832,15 @@ async def wyszukaj(ctx, how_many=0): if re.match(pattern, itm, re.IGNORECASE): temp_weight = ( search_weight[itr][0] - + (token_weight + (pingu**1.5) / pattern_len) / matched_times + + (token_weight + (pingu**1.5) / + pattern_len) / matched_times ) search_weight[itr] = temp_weight, music_file_list[itr] matched_times += 1 itr += 1 - logger.info("Stworzylem tablice wag zajęło mi to %s", datetime.now() - time_start) + logger.info("Stworzylem tablice wag zajęło mi to %s", + datetime.now() - time_start) time_start = datetime.now() item_to_search = await max_weight(search_weight) itr = 0 diff --git a/settings.json b/settings.json index 702fab8..7c87767 100644 --- a/settings.json +++ b/settings.json @@ -358,6 +358,13 @@ false, false ], + "same plusy[\\s\\.]*": [ + "...Jak na cmentarzu", + 15.0, + 0, + false, + false + ], "(oj\\.*\\s*){3,}": [ "Widzę że szykuje się wpierdol. *Przeładowuje ręczną rewolwerową wyrzutnię granatów termojądrowych i szeroko się uśmiecha w kierunku Hammera i Wykidajłów*", 15.0,