Fix some stuff for deepsource

pull/1/head
hikariatama 2022-04-29 17:57:56 +00:00
parent df3a2befd3
commit 02fd9ad602
6 changed files with 19 additions and 19 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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"<code>{i}</code> | "
f"<code>{i}</code>"
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"🚫 <b>{utils.escape_html(str(e))}</b>")
return
@ -826,4 +826,4 @@ class LoaderMod(loader.Module):
},
)
await self._update_modules()
asyncio.ensure_future(self._update_modules())

View File

@ -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

View File

@ -77,7 +77,7 @@ function finish_login() {
method: "POST",
credentials: "include"
})
.then((response) => {
.then(() => {
window.expanse = true;
$(".blur").fadeOut(1500);
setTimeout(() => {