diff --git a/hikka/dispatcher.py b/hikka/dispatcher.py index ef95cf1..8eb99bc 100755 --- a/hikka/dispatcher.py +++ b/hikka/dispatcher.py @@ -213,6 +213,9 @@ class CommandDispatcher: change = str.maketrans(ru_keys + en_keys, en_keys + ru_keys) message = utils.censor(event.message) + if not event.message.message: + return False + if event.message.message.startswith(prefix): pass elif event.message.message.startswith(str.translate(prefix, change)): @@ -295,7 +298,6 @@ class CommandDispatcher: and initiator not in self._db.get(main.__name__, "nonickusers", []) and utils.get_chat_id(event) not in self._db.get(main.__name__, "nonickchats", []) ): - logging.debug("Ignoring message without nickname") return False txt, func = self._modules.dispatch(tag[0]) @@ -322,7 +324,6 @@ class CommandDispatcher: f"{str(utils.get_chat_id(message))}.{func.__self__.__module__}" in blacklist_chats ): - logging.debug("Command is blacklisted in chat") return False if ( @@ -330,7 +331,6 @@ class CommandDispatcher: and f"{utils.get_chat_id(message)}.{func.__self__.__module__}" not in whitelist_modules ): - logging.debug("Command is not whitelisted in chat") return False if self._db.get(main.__name__, "grep", False): diff --git a/hikka/loader.py b/hikka/loader.py index fc87647..bbbe4d0 100755 --- a/hikka/loader.py +++ b/hikka/loader.py @@ -750,5 +750,5 @@ class Modules: async def log(self, type_, *, group=None, affected_uids=None, data=None): return await asyncio.gather(*[fun(type_, group, affected_uids, data) for fun in self._log_handlers]) # fmt: skip - def register_logger(self, logger): - self._log_handlers.append(logger) + def register_logger(self, _logger): + self._log_handlers.append(_logger) diff --git a/hikka/modules/help.py b/hikka/modules/help.py index 0f9b84d..9ba4397 100755 --- a/hikka/modules/help.py +++ b/hikka/modules/help.py @@ -117,7 +117,7 @@ class HelpMod(loader.Module): module = self.allmodules.commands[args].__self__ if not module: - module_name = next( + module_name = next( # skipcq: PTC-W0063 reversed( sorted( [ @@ -133,7 +133,7 @@ class HelpMod(loader.Module): ) ) - module = next( + module = next( # skipcq: PTC-W0063 module for module in self.allmodules.modules if module.strings["name"] == module_name diff --git a/hikka/modules/loader.py b/hikka/modules/loader.py index 5771cc9..5bfa87d 100755 --- a/hikka/modules/loader.py +++ b/hikka/modules/loader.py @@ -35,8 +35,8 @@ import logging import os import re import sys -import urllib import uuid +from urllib.parse import urlparse from importlib.machinery import ModuleSpec import telethon from telethon.tl.types import Message @@ -190,7 +190,7 @@ class LoaderMod(loader.Module): async def dlmodcmd(self, message: Message) -> None: """Downloads and installs a module from the official module repo""" if args := utils.get_args(message): - args = args[0] if urllib.parse.urlparse(args[0]).netloc else args[0].lower() + args = args[0] if urlparse(args[0]).netloc else args[0].lower() await self.download_and_install(args, message) self._update_modules_in_db() @@ -202,10 +202,10 @@ class LoaderMod(loader.Module): + f"\n☁️ {repo.strip('/')}\n\n" + "\n".join( [ - " ".join(chunk).strip(" | ") + " | ".join(chunk) for chunk in utils.chunks( [ - f"{i} | " + f"{i}" for i in sorted( [ utils.escape_html( @@ -291,7 +291,7 @@ class LoaderMod(loader.Module): async def download_and_install(self, module_name, message=None): try: - if urllib.parse.urlparse(module_name).netloc: + if urlparse(module_name).netloc: url = module_name else: links = list( @@ -582,7 +582,7 @@ class LoaderMod(loader.Module): save_fs, ) # Try again except loader.LoadError as e: - self.allmodules.modules.remove(instance) + self.allmodules.modules.remove(instance) # skipcq: PYL-E0601 if message: await utils.answer(message, f"🚫 {utils.escape_html(str(e))}") return @@ -826,4 +826,4 @@ class LoaderMod(loader.Module): }, ) - await self._update_modules() + asyncio.ensure_future(self._update_modules()) diff --git a/hikka/modules/test.py b/hikka/modules/test.py index bdb7e10..de25899 100755 --- a/hikka/modules/test.py +++ b/hikka/modules/test.py @@ -84,9 +84,9 @@ class TestMod(loader.Module): async def watchdog(self): while True: try: - for mod in os.scandir(DEBUG_MODS_DIR): - last_modified = os.stat(mod.path).st_mtime - cls_ = mod.path.split("/")[-1].split(".py")[0] + for module in os.scandir(DEBUG_MODS_DIR): + last_modified = os.stat(module.path).st_mtime + cls_ = module.path.split("/")[-1].split(".py")[0] if cls_ not in self._memory: self._memory[cls_] = last_modified @@ -97,7 +97,7 @@ class TestMod(loader.Module): self._memory[cls_] = last_modified logger.debug(f"Reloading debug module {cls_}") - with open(mod.path, "r") as f: + with open(module.path, "r") as f: try: await next( module diff --git a/web-resources/static/root.js b/web-resources/static/root.js index e46bf3e..9d2a1f6 100644 --- a/web-resources/static/root.js +++ b/web-resources/static/root.js @@ -77,7 +77,7 @@ function finish_login() { method: "POST", credentials: "include" }) - .then((response) => { + .then(() => { window.expanse = true; $(".blur").fadeOut(1500); setTimeout(() => {