ソースを参照

Fixed some deepsource things (#106)

Akshay Rajput 5 年 前
親
コミット
d50a9ad859

+ 2 - 2
sample_config.py

@@ -14,9 +14,9 @@ if HEROKU:
     )
     )
     SESSION_STRING = environ.get("SESSION_STRING", None)
     SESSION_STRING = environ.get("SESSION_STRING", None)
     USERBOT_PREFIX = environ.get("USERBOT_PREFIX", ".")
     USERBOT_PREFIX = environ.get("USERBOT_PREFIX", ".")
-    SUDO_USERS_ID = list(
+    SUDO_USERS_ID = [
         int(x) for x in environ.get("SUDO_USERS_ID", "").split()
         int(x) for x in environ.get("SUDO_USERS_ID", "").split()
-    )
+    ]
     LOG_GROUP_ID = int(environ.get("LOG_GROUP_ID", None))
     LOG_GROUP_ID = int(environ.get("LOG_GROUP_ID", None))
     GBAN_LOG_GROUP_ID = int(environ.get("GBAN_LOG_GROUP_ID", None))
     GBAN_LOG_GROUP_ID = int(environ.get("GBAN_LOG_GROUP_ID", None))
     MESSAGE_DUMP_CHAT = int(environ.get("MESSAGE_DUMP_CHAT", None))
     MESSAGE_DUMP_CHAT = int(environ.get("MESSAGE_DUMP_CHAT", None))

+ 1 - 1
wbb/core/types/InlineQueryResult.py

@@ -104,7 +104,7 @@ class InlineQueryResultAudio(InlineQueryResult):
 
 
         self.audio_url = audio_url
         self.audio_url = audio_url
         self.thumb_url = thumb_url
         self.thumb_url = thumb_url
-        self.voice = True if mime_type == "audio/ogg" else False
+        self.voice = bool(mime_type == "audio/ogg")
         self.title = title
         self.title = title
         self.caption = caption
         self.caption = caption
         self.description = description
         self.description = description

+ 3 - 3
wbb/modules/admin.py

@@ -144,7 +144,7 @@ async def list_members(group_id):
     filters.command("purge") & ~filters.edited & ~filters.private
     filters.command("purge") & ~filters.edited & ~filters.private
 )
 )
 @adminsOnly("can_delete_messages")
 @adminsOnly("can_delete_messages")
-async def purgeFunc(client, message: Message):
+async def purgeFunc(_, message: Message):
     await message.delete()
     await message.delete()
 
 
     if not message.reply_to_message:
     if not message.reply_to_message:
@@ -402,8 +402,8 @@ async def pin(_, message: Message):
         disable_web_page_preview=True,
         disable_web_page_preview=True,
     )
     )
     msg = "Please check the pinned message: ~ " + f"[Check, {r.link}]"
     msg = "Please check the pinned message: ~ " + f"[Check, {r.link}]"
-    filter = dict(type="text", data=msg)
-    await save_filter(message.chat.id, "~pinned", filter)
+    filter_ = dict(type="text", data=msg)
+    await save_filter(message.chat.id, "~pinned", filter_)
 
 
 
 
 # Mute members
 # Mute members

+ 1 - 1
wbb/modules/anonymize.py

@@ -34,7 +34,7 @@ from pyrogram.types import Chat, Message
 from wbb import LOG_GROUP_ID, SUDOERS, USERBOT_ID, USERBOT_PREFIX
 from wbb import LOG_GROUP_ID, SUDOERS, USERBOT_ID, USERBOT_PREFIX
 from wbb import aiohttpsession as session
 from wbb import aiohttpsession as session
 from wbb import app, app2
 from wbb import app, app2
-from wbb.modules.userbot import eor as eor
+from wbb.modules.userbot import eor
 from wbb.utils.functions import extract_user
 from wbb.utils.functions import extract_user
 
 
 
 

+ 3 - 1
wbb/modules/crypto.py

@@ -22,7 +22,9 @@ async def crypto(_, message):
     currency = message.text.split(None, 1)[1].lower()
     currency = message.text.split(None, 1)[1].lower()
 
 
     btn = ikb(
     btn = ikb(
-        {"Available Currencies": "https://plotcryptoprice.herokuapp.com"},
+        {
+            "Available Currencies": "https://plotcryptoprice.herokuapp.com"
+        },
     )
     )
 
 
     m = await message.reply("`Processing...`")
     m = await message.reply("`Processing...`")

+ 3 - 3
wbb/modules/devs.py

@@ -38,7 +38,7 @@ async def aexec(code, client, message):
     & ~filters.edited
     & ~filters.edited
     & filters.command("eval")
     & filters.command("eval")
 )
 )
-async def executor(client, message):
+async def executor(client, message: Message):
     try:
     try:
         cmd = message.text.split(" ", maxsplit=1)[1]
         cmd = message.text.split(" ", maxsplit=1)[1]
     except IndexError:
     except IndexError:
@@ -118,7 +118,7 @@ async def runtime_func_cq(_, cq):
     & ~filters.edited
     & ~filters.edited
     & filters.command("sh"),
     & filters.command("sh"),
 )
 )
-async def shellrunner(client, message):
+async def shellrunner(_, message: Message):
     if len(message.command) < 2:
     if len(message.command) < 2:
         return await eor(message, text="**Usage:**\n/sh git pull")
         return await eor(message, text="**Usage:**\n/sh git pull")
     text = message.text.split(None, 1)[1]
     text = message.text.split(None, 1)[1]
@@ -143,7 +143,7 @@ async def shellrunner(client, message):
             output += "\n"
             output += "\n"
     else:
     else:
         shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", text)
         shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", text)
-        for a in range(len(shell)):
+        for a, _ in enumerate(shell):
             shell[a] = shell[a].replace('"', "")
             shell[a] = shell[a].replace('"', "")
         try:
         try:
             process = subprocess.Popen(
             process = subprocess.Popen(

+ 0 - 1
wbb/modules/download_upload.py

@@ -33,7 +33,6 @@ from pyrogram.types import Message
 from wbb import SUDOERS, USERBOT_PREFIX, app2, eor
 from wbb import SUDOERS, USERBOT_PREFIX, app2, eor
 from wbb.core.sections import section
 from wbb.core.sections import section
 from wbb.core.tasks import add_task, rm_task
 from wbb.core.tasks import add_task, rm_task
-from wbb.modules.userbot import eor
 from wbb.utils.downloader import download
 from wbb.utils.downloader import download
 
 
 
 

+ 10 - 8
wbb/modules/filters.py

@@ -149,18 +149,20 @@ async def filters_re(_, message):
                         reply_markup=keyb,
                         reply_markup=keyb,
                         disable_web_page_preview=True,
                         disable_web_page_preview=True,
                     )
                     )
+
                     if text.startswith("~"):
                     if text.startswith("~"):
-                        return await message.delete()
+                        await message.delete()
                     return
                     return
+
                 return await message.reply_text(
                 return await message.reply_text(
                     data,
                     data,
                     reply_markup=keyb,
                     reply_markup=keyb,
                     disable_web_page_preview=True,
                     disable_web_page_preview=True,
                 )
                 )
-            else:
-                if message.reply_to_message:
-                    await message.reply_to_message.reply_sticker(data)
-                    if text.startswith("~"):
-                        return await message.delete()
-                    return
-                return await message.reply_sticker(data)
+            if message.reply_to_message:
+                await message.reply_to_message.reply_sticker(data)
+
+                if text.startswith("~"):
+                    await message.delete()
+                return
+            return await message.reply_sticker(data)

+ 52 - 51
wbb/modules/greetings.py

@@ -231,59 +231,60 @@ async def callback_query_welcome_button(_, callback_query):
             ):
             ):
                 correct_answer = i["answer"]
                 correct_answer = i["answer"]
                 keyboard = i["keyboard"]
                 keyboard = i["keyboard"]
-    if pending_user_id == pressed_user_id:
-        if answer != correct_answer:
-            await callback_query.answer("Yeah, It's Wrong.")
-            for iii in answers_dicc:
-                if (
-                    iii["user_id"] == pending_user_id
-                    and iii["chat_id"] == button_message.chat.id
-                ):
-                    attempts = iii["attempts"]
-                    if attempts >= 3:
-                        answers_dicc.remove(iii)
-                        await button_message.chat.kick_member(
-                            pending_user_id
-                        )
-                        await asyncio.sleep(1)
-                        await button_message.chat.unban_member(
-                            pending_user_id
-                        )
-                        await button_message.delete()
-                        await update_captcha_cache(answers_dicc)
-                        return
-                    else:
-                        iii["attempts"] += 1
-                        break
-            shuffle(keyboard[0])
-            shuffle(keyboard[1])
-            shuffle(keyboard[2])
-            shuffle(keyboard)
-            keyboard = InlineKeyboardMarkup(keyboard)
-            await button_message.edit(
-                text=button_message.caption.markdown,
-                reply_markup=keyboard,
-            )
-            return
-        await callback_query.answer("Captcha passed successfully!")
-        await button_message.chat.unban_member(pending_user_id)
-        await button_message.delete()
-        if len(answers_dicc) != 0:
-            for ii in answers_dicc:
-                if (
-                    ii["user_id"] == pending_user_id
-                    and ii["chat_id"] == button_message.chat.id
-                ):
-                    answers_dicc.remove(ii)
+
+    if pending_user_id != pressed_user_id:
+        return await callback_query.answer("This is not for you")
+
+    if answer != correct_answer:
+        await callback_query.answer("Yeah, It's Wrong.")
+        for iii in answers_dicc:
+            if (
+                iii["user_id"] == pending_user_id
+                and iii["chat_id"] == button_message.chat.id
+            ):
+                attempts = iii["attempts"]
+                if attempts >= 3:
+                    answers_dicc.remove(iii)
+                    await button_message.chat.kick_member(
+                        pending_user_id
+                    )
+                    await asyncio.sleep(1)
+                    await button_message.chat.unban_member(
+                        pending_user_id
+                    )
+                    await button_message.delete()
                     await update_captcha_cache(answers_dicc)
                     await update_captcha_cache(answers_dicc)
-        """ send welcome message """
-        await send_welcome_message(
-            callback_query.message.chat, pending_user_id
+                    return
+
+                iii["attempts"] += 1
+                break
+
+        shuffle(keyboard[0])
+        shuffle(keyboard[1])
+        shuffle(keyboard[2])
+        shuffle(keyboard)
+        keyboard = InlineKeyboardMarkup(keyboard)
+        return await button_message.edit(
+            text=button_message.caption.markdown,
+            reply_markup=keyboard,
         )
         )
-        return
-    else:
-        await callback_query.answer("This is not for you")
-        return
+
+    await callback_query.answer("Captcha passed successfully!")
+    await button_message.chat.unban_member(pending_user_id)
+    await button_message.delete()
+
+    if len(answers_dicc) != 0:
+        for ii in answers_dicc:
+            if (
+                ii["user_id"] == pending_user_id
+                and ii["chat_id"] == button_message.chat.id
+            ):
+                answers_dicc.remove(ii)
+                await update_captcha_cache(answers_dicc)
+
+    return await send_welcome_message(
+        callback_query.message.chat, pending_user_id
+    )
 
 
 
 
 async def kick_restricted_after_delay(
 async def kick_restricted_after_delay(

+ 3 - 1
wbb/modules/img_pdf.py

@@ -83,7 +83,9 @@ async def convert(
 
 
     await m.delete()
     await m.delete()
     pdf.close()
     pdf.close()
-    [remove(file) for file in documents if path.exists(file)]
+    for file in documents:
+        if path.exists(file):
+            remove(file)
 
 
 
 
 @app.on_message(filters.command("pdf"))
 @app.on_message(filters.command("pdf"))

+ 13 - 9
wbb/modules/info.py

@@ -27,7 +27,6 @@ from pyrogram import filters
 from pyrogram.types import Message
 from pyrogram.types import Message
 
 
 from wbb import SUDOERS, app
 from wbb import SUDOERS, app
-from wbb.core.decorators.errors import capture_err
 from wbb.core.sections import section
 from wbb.core.sections import section
 from wbb.utils.dbfunctions import is_gbanned_user, user_global_karma
 from wbb.utils.dbfunctions import is_gbanned_user, user_global_karma
 
 
@@ -72,7 +71,7 @@ async def get_chat_info(chat, already=False):
     chat_id = chat.id
     chat_id = chat.id
     username = chat.username
     username = chat.username
     title = chat.title
     title = chat.title
-    type = chat.type
+    type_ = chat.type
     is_scam = chat.is_scam
     is_scam = chat.is_scam
     description = chat.description
     description = chat.description
     members = chat.members_count
     members = chat.members_count
@@ -83,7 +82,7 @@ async def get_chat_info(chat, already=False):
     body = {
     body = {
         "ID": chat_id,
         "ID": chat_id,
         "DC": dc_id,
         "DC": dc_id,
-        "Type": type,
+        "Type": type_,
         "Name": [title],
         "Name": [title],
         "Username": [("@" + username) if username else None],
         "Username": [("@" + username) if username else None],
         "Mention": [link],
         "Mention": [link],
@@ -97,7 +96,6 @@ async def get_chat_info(chat, already=False):
 
 
 
 
 @app.on_message(filters.command("info"))
 @app.on_message(filters.command("info"))
-@capture_err
 async def info_func(_, message: Message):
 async def info_func(_, message: Message):
     if message.reply_to_message:
     if message.reply_to_message:
         user = message.reply_to_message.from_user.id
         user = message.reply_to_message.from_user.id
@@ -105,16 +103,20 @@ async def info_func(_, message: Message):
         user = message.from_user.id
         user = message.from_user.id
     elif not message.reply_to_message and len(message.command) != 1:
     elif not message.reply_to_message and len(message.command) != 1:
         user = message.text.split(None, 1)[1]
         user = message.text.split(None, 1)[1]
+
     m = await message.reply_text("Processing")
     m = await message.reply_text("Processing")
+
     try:
     try:
         info_caption, photo_id = await get_user_info(user)
         info_caption, photo_id = await get_user_info(user)
     except Exception as e:
     except Exception as e:
         return await m.edit(str(e))
         return await m.edit(str(e))
+
     if not photo_id:
     if not photo_id:
         return await m.edit(
         return await m.edit(
             info_caption, disable_web_page_preview=True
             info_caption, disable_web_page_preview=True
         )
         )
     photo = await app.download_media(photo_id)
     photo = await app.download_media(photo_id)
+
     await message.reply_photo(
     await message.reply_photo(
         photo, caption=info_caption, quote=False
         photo, caption=info_caption, quote=False
     )
     )
@@ -123,30 +125,32 @@ async def info_func(_, message: Message):
 
 
 
 
 @app.on_message(filters.command("chat_info"))
 @app.on_message(filters.command("chat_info"))
-@capture_err
 async def chat_info_func(_, message: Message):
 async def chat_info_func(_, message: Message):
     try:
     try:
         if len(message.command) > 2:
         if len(message.command) > 2:
             return await message.reply_text(
             return await message.reply_text(
                 "**Usage:**/chat_info [USERNAME|ID]"
                 "**Usage:**/chat_info [USERNAME|ID]"
             )
             )
-        elif len(message.command) == 1:
+
+        if len(message.command) == 1:
             chat = message.chat.id
             chat = message.chat.id
         elif len(message.command) == 2:
         elif len(message.command) == 2:
             chat = message.text.split(None, 1)[1]
             chat = message.text.split(None, 1)[1]
+
         m = await message.reply_text("Processing")
         m = await message.reply_text("Processing")
+
         info_caption, photo_id = await get_chat_info(chat)
         info_caption, photo_id = await get_chat_info(chat)
         if not photo_id:
         if not photo_id:
             return await m.edit(
             return await m.edit(
                 info_caption, disable_web_page_preview=True
                 info_caption, disable_web_page_preview=True
             )
             )
+
         photo = await app.download_media(photo_id)
         photo = await app.download_media(photo_id)
         await message.reply_photo(
         await message.reply_photo(
             photo, caption=info_caption, quote=False
             photo, caption=info_caption, quote=False
         )
         )
+
         await m.delete()
         await m.delete()
         os.remove(photo)
         os.remove(photo)
     except Exception as e:
     except Exception as e:
-        await message.reply_text(e)
-        print(e)
-        await m.delete()
+        await m.edit(e)

+ 0 - 1
wbb/modules/inline.py

@@ -42,7 +42,6 @@ async def inline_query_handler(client, query):
             await client.answer_inline_query(
             await client.answer_inline_query(
                 query.id, results=answerss, cache_time=10
                 query.id, results=answerss, cache_time=10
             )
             )
-            return
         elif text.split()[0] == "alive":
         elif text.split()[0] == "alive":
             answerss = await alive_function(answers)
             answerss = await alive_function(answers)
             await client.answer_inline_query(
             await client.answer_inline_query(

+ 18 - 9
wbb/modules/locks.py

@@ -71,11 +71,14 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
     if lock:
     if lock:
         if perm not in permissions:
         if perm not in permissions:
             return await message.reply_text("Already locked.")
             return await message.reply_text("Already locked.")
+        permissions.remove(perm)
     else:
     else:
         if perm in permissions:
         if perm in permissions:
             return await message.reply_text("Already Unlocked.")
             return await message.reply_text("Already Unlocked.")
-    (permissions.remove(perm) if lock else permissions.append(perm))
+        permissions.append(perm)
+
     permissions = {perm: True for perm in list(set(permissions))}
     permissions = {perm: True for perm in list(set(permissions))}
+
     try:
     try:
         await app.set_chat_permissions(
         await app.set_chat_permissions(
             message.chat.id, ChatPermissions(**permissions)
             message.chat.id, ChatPermissions(**permissions)
@@ -84,6 +87,7 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
         return await message.reply_text(
         return await message.reply_text(
             "To unlock this, you have to unlock 'messages' first."
             "To unlock this, you have to unlock 'messages' first."
         )
         )
+
     await message.reply_text(("Locked." if lock else "Unlocked."))
     await message.reply_text(("Locked." if lock else "Unlocked."))
 
 
 
 
@@ -94,18 +98,22 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
 async def locks_func(_, message):
 async def locks_func(_, message):
     if len(message.command) != 2:
     if len(message.command) != 2:
         return await message.reply_text(incorrect_parameters)
         return await message.reply_text(incorrect_parameters)
+
     chat_id = message.chat.id
     chat_id = message.chat.id
     parameter = message.text.strip().split(None, 1)[1].lower()
     parameter = message.text.strip().split(None, 1)[1].lower()
     state = message.command[0].lower()
     state = message.command[0].lower()
+
     if parameter not in data and parameter != "all":
     if parameter not in data and parameter != "all":
         return await message.reply_text(incorrect_parameters)
         return await message.reply_text(incorrect_parameters)
+
     permissions = await current_chat_permissions(chat_id)
     permissions = await current_chat_permissions(chat_id)
+
     if parameter in data:
     if parameter in data:
-        return await tg_lock(
+        await tg_lock(
             message,
             message,
             permissions,
             permissions,
             data[parameter],
             data[parameter],
-            True if state == "lock" else False,
+            bool(state == "lock"),
         )
         )
     elif parameter == "all" and state == "lock":
     elif parameter == "all" and state == "lock":
         await app.set_chat_permissions(chat_id, ChatPermissions())
         await app.set_chat_permissions(chat_id, ChatPermissions())
@@ -116,11 +124,14 @@ async def locks_func(_, message):
 @capture_err
 @capture_err
 async def locktypes(_, message):
 async def locktypes(_, message):
     permissions = await current_chat_permissions(message.chat.id)
     permissions = await current_chat_permissions(message.chat.id)
+
     if not permissions:
     if not permissions:
         return await message.reply_text("No Permissions.")
         return await message.reply_text("No Permissions.")
+
     perms = ""
     perms = ""
     for i in permissions:
     for i in permissions:
         perms += f"__**{i}**__\n"
         perms += f"__**{i}**__\n"
+
     await message.reply_text(perms)
     await message.reply_text(perms)
 
 
 
 
@@ -129,14 +140,12 @@ async def url_detector(_, message):
     user = message.from_user
     user = message.from_user
     chat_id = message.chat.id
     chat_id = message.chat.id
     text = message.text.lower().strip()
     text = message.text.lower().strip()
-    if not text:
-        return
-    if not user:
-        return
-    if user.id in SUDOERS:
+
+    if not text or not user:
         return
         return
-    if user.id in await list_admins(chat_id):
+    if user.id in (SUDOERS + (await list_admins(chat_id))):
         return
         return
+
     check = get_urls_from_text(text)
     check = get_urls_from_text(text)
     if check:
     if check:
         permissions = await current_chat_permissions(chat_id)
         permissions = await current_chat_permissions(chat_id)

+ 2 - 2
wbb/modules/music.py

@@ -54,7 +54,7 @@ def get_file_extension_from_url(url):
     return basename.split(".")[-1]
     return basename.split(".")[-1]
 
 
 
 
-def download_youtube_audio(url: str, m=0):
+def download_youtube_audio(url: str):
     global is_downloading
     global is_downloading
     with youtube_dl.YoutubeDL(
     with youtube_dl.YoutubeDL(
         {
         {
@@ -109,7 +109,7 @@ async def music(_, message):
     try:
     try:
         loop = get_running_loop()
         loop = get_running_loop()
         music = await loop.run_in_executor(
         music = await loop.run_in_executor(
-            None, partial(download_youtube_audio, url, message)
+            None, partial(download_youtube_audio, url)
         )
         )
         if not music:
         if not music:
             await m.edit("Too Long, Can't Download.")
             await m.edit("Too Long, Can't Download.")

+ 2 - 2
wbb/modules/purge_me.py

@@ -119,12 +119,12 @@ async def purge_me_func(_, message: Message):
     # because we can't delete more than 100 messages at once,
     # because we can't delete more than 100 messages at once,
     # we have to do it in chunks of 100, i'll choose 99 just
     # we have to do it in chunks of 100, i'll choose 99 just
     # to be safe.
     # to be safe.
-    to_delete = list(
+    to_delete = [
         (
         (
             message_ids[i : i + 99]
             message_ids[i : i + 99]
             for i in range(0, len(message_ids), 99)
             for i in range(0, len(message_ids), 99)
         )
         )
-    )
+    ]
 
 
     for hundred_messages_or_less in to_delete:
     for hundred_messages_or_less in to_delete:
         await app2.delete_messages(
         await app2.delete_messages(

+ 6 - 8
wbb/modules/quotly.py

@@ -88,19 +88,17 @@ async def quotly_func(client, message: Message):
         if arg[0]:
         if arg[0]:
             if arg[1] < 2 or arg[1] > 10:
             if arg[1] < 2 or arg[1] > 10:
                 return await m.edit("Argument must be between 2-10.")
                 return await m.edit("Argument must be between 2-10.")
+
             count = arg[1]
             count = arg[1]
+
             messages = [
             messages = [
                 i
                 i
                 for i in await client.get_messages(
                 for i in await client.get_messages(
                     message.chat.id,
                     message.chat.id,
-                    [
-                        i
-                        for i in range(
-                            message.reply_to_message.message_id,
-                            message.reply_to_message.message_id
-                            + count,
-                        )
-                    ],
+                    range(
+                        message.reply_to_message.message_id,
+                        message.reply_to_message.message_id + count,
+                    ),
                     replies=0,
                     replies=0,
                 )
                 )
                 if not i.empty
                 if not i.empty

+ 1 - 4
wbb/modules/regex.py

@@ -80,10 +80,7 @@ def infinite_checker(repl):
     ]
     ]
     for match in regex:
     for match in regex:
         status = re.search(match, repl)
         status = re.search(match, repl)
-        if status:
-            return True
-        else:
-            return False
+        return bool(status)
 
 
 
 
 def separate_sed(sed_string):
 def separate_sed(sed_string):

+ 3 - 4
wbb/modules/userbot.py

@@ -146,8 +146,7 @@ async def executor(client, message: Message):
         status_ = await iter_edit(message, final_output)
         status_ = await iter_edit(message, final_output)
         if status_ == 0:
         if status_ == 0:
             return await message.reply(final_output, quote=True)
             return await message.reply(final_output, quote=True)
-        else:
-            return
+        return
     if not status.from_user:
     if not status.from_user:
         status = await app2.get_messages(
         status = await app2.get_messages(
             status.chat.id, status.message_id
             status.chat.id, status.message_id
@@ -162,7 +161,7 @@ async def executor(client, message: Message):
     & ~filters.edited
     & ~filters.edited
     & filters.command("sh", prefixes=USERBOT_PREFIX),
     & filters.command("sh", prefixes=USERBOT_PREFIX),
 )
 )
-async def shellrunner(client, message: Message):
+async def shellrunner(_, message: Message):
     if len(message.command) < 2:
     if len(message.command) < 2:
         return await eor(message, text="**Usage:**\n/sh git pull")
         return await eor(message, text="**Usage:**\n/sh git pull")
 
 
@@ -197,7 +196,7 @@ async def shellrunner(client, message: Message):
             output += "\n"
             output += "\n"
     else:
     else:
         shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", text)
         shell = re.split(""" (?=(?:[^'"]|'[^']*'|"[^"]*")*$)""", text)
-        for a in range(len(shell)):
+        for a, _ in enumerate(shell):
             shell[a] = shell[a].replace('"', "")
             shell[a] = shell[a].replace('"', "")
         try:
         try:
             process = subprocess.Popen(
             process = subprocess.Popen(

+ 8 - 11
wbb/utils/dbfunctions.py

@@ -56,16 +56,16 @@ flood_toggle_db = db.flood_toggle
 rssdb = db.rss
 rssdb = db.rss
 
 
 
 
-def obj_to_str(object):
-    if not object:
+def obj_to_str(obj):
+    if not obj:
         return False
         return False
-    string = codecs.encode(pickle.dumps(object), "base64").decode()
+    string = codecs.encode(pickle.dumps(obj), "base64").decode()
     return string
     return string
 
 
 
 
 def str_to_obj(string: str):
 def str_to_obj(string: str):
-    object = pickle.loads(codecs.decode(string.encode(), "base64"))
-    return object
+    obj = pickle.loads(codecs.decode(string.encode(), "base64"))
+    return obj
 
 
 
 
 """ Notes functions """
 """ Notes functions """
@@ -103,8 +103,7 @@ async def get_note(chat_id: int, name: str) -> Union[bool, dict]:
     _notes = await _get_notes(chat_id)
     _notes = await _get_notes(chat_id)
     if name in _notes:
     if name in _notes:
         return _notes[name]
         return _notes[name]
-    else:
-        return False
+    return False
 
 
 
 
 async def save_note(chat_id: int, name: str, note: dict):
 async def save_note(chat_id: int, name: str, note: dict):
@@ -169,8 +168,7 @@ async def get_filter(chat_id: int, name: str) -> Union[bool, dict]:
     _filters = await _get_filters(chat_id)
     _filters = await _get_filters(chat_id)
     if name in _filters:
     if name in _filters:
         return _filters[name]
         return _filters[name]
-    else:
-        return False
+    return False
 
 
 
 
 async def save_filter(chat_id: int, name: str, _filter: dict):
 async def save_filter(chat_id: int, name: str, _filter: dict):
@@ -453,8 +451,7 @@ async def get_couple(chat_id: int, date: str):
     lovers = await _get_lovers(chat_id)
     lovers = await _get_lovers(chat_id)
     if date in lovers:
     if date in lovers:
         return lovers[date]
         return lovers[date]
-    else:
-        return False
+    return False
 
 
 
 
 async def save_couple(chat_id: int, date: str, couple: dict):
 async def save_couple(chat_id: int, date: str, couple: dict):

+ 4 - 1
wbb/utils/formatter.py

@@ -38,10 +38,13 @@ def get_readable_time(seconds: int) -> str:
             break
             break
         time_list.append(int(result))
         time_list.append(int(result))
         seconds = int(remainder)
         seconds = int(remainder)
-    for i in range(len(time_list)):
+
+    for i, _ in enumerate(time_list):
         time_list[i] = str(time_list[i]) + time_suffix_list[i]
         time_list[i] = str(time_list[i]) + time_suffix_list[i]
+
     if len(time_list) == 4:
     if len(time_list) == 4:
         ping_time += time_list.pop() + ", "
         ping_time += time_list.pop() + ", "
+
     time_list.reverse()
     time_list.reverse()
     ping_time += ":".join(time_list)
     ping_time += ":".join(time_list)
     return ping_time
     return ping_time

+ 6 - 4
wbb/utils/functions.py

@@ -240,8 +240,9 @@ async def extract_user_and_reason(message):
     if len(args) == 2:
     if len(args) == 2:
         user = text.split(None, 1)[1]
         user = text.split(None, 1)[1]
         return await extract_userid(message, user), None
         return await extract_userid(message, user), None
+
     # if reason is given
     # if reason is given
-    elif len(args) > 2:
+    if len(args) > 2:
         user, reason = text.split(None, 2)[1:]
         user, reason = text.split(None, 2)[1:]
         return await extract_userid(message, user), reason
         return await extract_userid(message, user), reason
 
 
@@ -261,10 +262,11 @@ def get_file_id_from_message(
     if message.document:
     if message.document:
         if int(message.document.file_size) > max_file_size:
         if int(message.document.file_size) > max_file_size:
             return
             return
+
         mime_type = message.document.mime_type
         mime_type = message.document.mime_type
-        if mime_types:
-            if mime_type not in mime_types:
-                return
+
+        if mime_type not in mime_types:
+            return
         file_id = message.document.file_id
         file_id = message.document.file_id
 
 
     if message.sticker:
     if message.sticker:

+ 1 - 6
wbb/utils/json_prettify.py

@@ -27,12 +27,7 @@ async def json_object_prettify(objecc):
     dicc = objecc.__dict__
     dicc = objecc.__dict__
     output = ""
     output = ""
     for key, value in dicc.items():
     for key, value in dicc.items():
-        if (
-            key == "pinned_message"
-            or key == "photo"
-            or key == "_"
-            or key == "_client"
-        ):
+        if key in ["pinned_message", "photo", "_", "_client"]:
             continue
             continue
         output += f"**{key}:** `{value}`\n"
         output += f"**{key}:** `{value}`\n"
     return output
     return output

+ 4 - 2
wbb/utils/read_lines.py

@@ -21,8 +21,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 SOFTWARE.
 """
 """
-import random
+from random import choice
 
 
 
 
 async def random_line(fname):
 async def random_line(fname):
-    return random.choice(open(fname).read().splitlines())
+    with open(fname) as f:
+        data = f.read().splitlines()
+    return choice(data)

+ 4 - 5
wbb/utils/rss.py

@@ -28,10 +28,9 @@ class Feed:
             text += f"**Published:** `{self.published}`\n"
             text += f"**Published:** `{self.published}`\n"
         if self.updated:
         if self.updated:
             text += f"**Last Updated:** `{self.updated}`\n"
             text += f"**Last Updated:** `{self.updated}`\n"
-        if self.summary:
-            if "<div" not in self.summary:
-                text += f"**Summary:** {self.summary.strip()}\n"
+
+        if self.summary and "<div" not in self.summary:
+            text += f"**Summary:** {self.summary.strip()}\n"
 
 
         if text:
         if text:
-            text = "\n".join([i.strip() for i in text.splitlines()])
-        return text
+            return "\n".join([i.strip() for i in text.splitlines()])