Ver código fonte

Fixed flake8 errors

TheHamkerCat 5 anos atrás
pai
commit
74ab5f5e22

+ 5 - 3
wbb/__init__.py

@@ -1,8 +1,8 @@
 from config import (
-    BOT_TOKEN, API_ID ,API_HASH, OWNER_ID, SUDO_USER_ID,
+    BOT_TOKEN, API_ID, API_HASH, OWNER_ID, SUDO_USER_ID,
     LOG_GROUP_ID, FERNET_ENCRYPTION_KEY, MONGO_DB_URI,
     WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API
-    )
+)
 from pyrogram import Client
 from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
 from Python_ARQ import ARQ
@@ -34,7 +34,9 @@ logging.getLogger("").addHandler(console)
 
 log = logging.getLogger()
 
-
+FERNET_ENCRYPTION_KEY = FERNET_ENCRYPTION_KEY
+WELCOME_DELAY_KICK_SEC = WELCOME_DELAY_KICK_SEC
+LOG_GROUP_ID = LOG_GROUP_ID
 SUDOERS = SUDO_USER_ID
 SUDOERS.append(OWNER_ID)
 MOD_LOAD = []

+ 2 - 0
wbb/__main__.py

@@ -118,11 +118,13 @@ async def help_parser(message, keyboard=None):
         keyboard,
     )
 
+
 @app.on_callback_query(filters.regex("stats_callback"))
 async def end_callbacc(_, CallbackQuery):
     text = await bot_sys_stats()
     await app.answer_callback_query(CallbackQuery.id, text, show_alert=True)
 
+
 @app.on_callback_query(filters.regex(r"help_(.*?)"))
 async def help_button(client, query):
     mod_match = re.match(r"help_module\((.+?)\)", query.data)

+ 2 - 5
wbb/modules/admin.py

@@ -1,6 +1,6 @@
 from pyrogram import filters
 from pyrogram.types import ChatPermissions
-from wbb import OWNER_ID, SUDOERS, app
+from wbb import SUDOERS, app
 from wbb.utils.botinfo import BOT_ID
 from wbb.utils.errors import capture_err
 from wbb.utils.dbfunctions import add_warn, get_warn, remove_warns, int_to_alpha
@@ -427,8 +427,6 @@ async def warn_user(_, message):
         await message.reply_text(str(e))
 
 
-
-
 # Rmwarns
 
 
@@ -469,7 +467,6 @@ async def check_warns(_, message):
         await message.reply_text("Reply to a message to check a user's warnings.")
         return
     try:
-        from_user_id = message.from_user.id
         user_id = message.reply_to_message.from_user.id
         mention_user = message.reply_to_message.from_user.mention
         mention_from_user = message.from_user.mention
@@ -489,7 +486,7 @@ async def check_warns(_, message):
         else:
             await message.reply_text(f"{mention_user} have no warnings.")
             return
-        await message.reply_text(f"{mention__from_user} have {warns}/3 warnings.")
+        await message.reply_text(f"{mention_from_user} have {warns}/3 warnings.")
     except Exception as e:
         await message.reply_text(str(e))
 

+ 0 - 1
wbb/modules/advanced.py

@@ -74,4 +74,3 @@ async def send_message(_, message):
     except Exception as e:
         await message.reply_text(str(e))
         print(str(e))
-

+ 4 - 8
wbb/modules/chatbot.py

@@ -1,5 +1,4 @@
-from wbb import app, arq 
-from wbb.utils.fetch import fetch
+from wbb import app, arq
 from wbb.utils.errors import capture_err
 from wbb.utils.botinfo import BOT_ID
 from wbb.utils.filter_groups import chatbot_group
@@ -23,7 +22,7 @@ async def chatbot_status(_, message):
         return
     status = message.text.split(None, 1)[1]
     chat_id = message.chat.id
-    
+
     if status == "ON" or status == "on" or status == "On":
         if chat_id not in active_chats:
             active_chats.append(chat_id)
@@ -41,15 +40,13 @@ async def chatbot_status(_, message):
             return
         await message.reply_text("ChatBot Is Already Disabled.")
         return
-    
+
     else:
         await message.reply_text("/chatbot [ON|OFF]")
 
 
-
-
 @app.on_message(filters.text & filters.reply & ~filters.bot &
-        ~filters.via_bot & ~filters.forwarded, group=chatbot_group)
+                ~filters.via_bot & ~filters.forwarded, group=chatbot_group)
 @capture_err
 async def chatbot_talk(_, message):
     if message.chat.id not in active_chats:
@@ -61,4 +58,3 @@ async def chatbot_talk(_, message):
     response = luna.response
     await app.send_chat_action(message.chat.id, "typing")
     await message.reply_text(response)
-

+ 5 - 7
wbb/modules/filters.py

@@ -1,10 +1,8 @@
-from wbb import app, db
+from wbb import app
 from wbb.modules.admin import member_permissions
 from wbb.utils.dbfunctions import (
-        _get_filters, save_filter,
-        get_filters_names, get_filter,
-        delete_filter
-        )
+    save_filter, get_filters_names, get_filter, delete_filter
+)
 from pyrogram import filters
 from wbb.utils.errors import capture_err
 from wbb.utils.filter_groups import chat_filters_group
@@ -72,7 +70,7 @@ async def del_filter(_, message):
         if deleted:
             await message.reply_text(f"**Deleted filter {name}.**")
         else:
-            await message.reply_text(f"**No such filter.**")
+            await message.reply_text("**No such filter.**")
 
 
 @app.on_message(filters.text & ~filters.edited &
@@ -95,6 +93,6 @@ async def filters_re(_, message):
                         else:
                             await message.reply_sticker(data)
                         return
-    except Exception as e:
+    except Exception:
         print("Error in filters_re function in filters.py [IGNORE THIS]")
         pass

+ 26 - 24
wbb/modules/global_stats.py

@@ -4,39 +4,42 @@ from wbb.utils.errors import capture_err
 from wbb.utils.botinfo import BOT_ID, BOT_NAME
 from wbb.utils.fetch import fetch
 from wbb.utils.dbfunctions import (
-        is_served_chat,
-        get_served_chats,
-        add_served_chat,
-        remove_served_chat,
-        get_notes_count,
-        get_filters_count,
-        get_warns_count,
-        get_karmas_count,
-        get_gbans_count
-        )
+    is_served_chat,
+    get_served_chats,
+    add_served_chat,
+    remove_served_chat,
+    get_notes_count,
+    get_filters_count,
+    get_warns_count,
+    get_karmas_count,
+    get_gbans_count
+)
 from pyrogram import filters
 
+
 @app.on_message(filters.text, group=global_stats_group)
 @capture_err
 async def chat_watcher(_, message):
     chat_id = message.chat.id
     served_chat = await is_served_chat(chat_id)
-    if served_chat: return
+    if served_chat:
+        return
     await add_served_chat(chat_id)
 
+
 @app.on_message(
-        filters.command("global_stats") & filters.user(SUDOERS)
-        & ~filters.edited
-        )
+    filters.command("global_stats") & filters.user(SUDOERS)
+    & ~filters.edited
+)
 @capture_err
 async def global_stats(_, message):
     m = await app.send_message(
-            message.chat.id,
-            text="__**Analysing Stats, Might Take 10-30 Seconds.**__",
-            disable_web_page_preview=True
-            )
-    
-    ## For bot served chat and users count
+        message.chat.id,
+        text="__**Analysing Stats, Might Take 10-30 Seconds.**__",
+        disable_web_page_preview=True
+    )
+
+    # For bot served chat and users count
     served_chats = []
     total_users = 0
     chats = await get_served_chats()
@@ -53,10 +56,10 @@ async def global_stats(_, message):
     for i in served_chats:
         mc = (await app.get_chat(i)).members_count
         total_users += int(mc)
-    
+
     # Gbans count
     gbans = await get_gbans_count()
-    ## Notes count across chats
+    # Notes count across chats
     _notes = await get_notes_count()
     notes_count = _notes["notes_count"]
     notes_chats_count = _notes["chats_count"]
@@ -65,7 +68,7 @@ async def global_stats(_, message):
     _filters = await get_filters_count()
     filters_count = _filters["filters_count"]
     filters_chats_count = _filters["chats_count"]
-    
+
     # Warns count across chats
     _warns = await get_warns_count()
     warns_count = _warns["warns_count"]
@@ -97,4 +100,3 @@ async def global_stats(_, message):
 **{developers}** Developers And **{commits}** Commits On **[Github]({rurl})**."""
 
     await m.edit(msg, disable_web_page_preview=True)
-

+ 2 - 2
wbb/modules/greetings.py

@@ -13,7 +13,6 @@ import asyncio
 from datetime import datetime
 from pyrogram import filters
 from wbb import app, WELCOME_DELAY_KICK_SEC
-from wbb.modules.admin import list_admins
 from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, ChatPermissions, User
 from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant
 from wbb.utils.errors import capture_err
@@ -25,7 +24,8 @@ from wbb.utils.dbfunctions import is_gbanned_user
 async def welcome(_, message: Message):
     """Mute new member and send message with button"""
     for member in message.new_chat_members:
-        if member.is_bot: continue  # ignore bots
+        if member.is_bot:
+            continue  # ignore bots
         if await is_gbanned_user(member.id):
             await message.chat.kick_member(member.id)
             continue

+ 9 - 7
wbb/modules/karma.py

@@ -1,9 +1,7 @@
-import operator
 from wbb import app
 from wbb.utils.errors import capture_err
-from wbb.utils.json_prettify import json_prettify
 from wbb.utils.dbfunctions import (update_karma, get_karma, get_karmas,
-    int_to_alpha, alpha_to_int)
+                                   int_to_alpha, alpha_to_int)
 from wbb.utils.filter_groups import karma_positive_group, karma_negative_group
 from pyrogram import filters
 
@@ -27,6 +25,7 @@ regex_downvote = r"^(\-|\-\-|\-1|👎)$"
                 & ~filters.bot
                 & ~filters.edited,
                 group=karma_positive_group)
+@capture_err
 async def upvote(_, message):
     if message.reply_to_message.from_user.id == message.from_user.id:
         return
@@ -57,6 +56,7 @@ async def upvote(_, message):
                 & ~filters.bot
                 & ~filters.edited,
                 group=karma_negative_group)
+@capture_err
 async def downvote(_, message):
     if message.reply_to_message.from_user.id == message.from_user.id:
         return
@@ -74,11 +74,12 @@ async def downvote(_, message):
         new_karma = {"karma": karma}
         await update_karma(chat_id, await int_to_alpha(user_id), new_karma)
     await message.reply_text(
-    f'Decremented Karma Of {user_mention} By 1 \nTotal Points: {karma}'
-)
+        f'Decremented Karma Of {user_mention} By 1 \nTotal Points: {karma}'
+    )
 
 
 @app.on_message(filters.command("karma") & filters.group)
+@capture_err
 async def karma(_, message):
     chat_id = message.chat.id
 
@@ -92,8 +93,9 @@ async def karma(_, message):
             user_karma = karma[i]['karma']
             user_name = (await app.get_users(user_id)).username
             karma_dicc[user_name] = user_karma
-            
-            karma_arranged = dict(sorted(karma_dicc.items(), key=lambda item: item[1], reverse=True))
+
+            karma_arranged = dict(
+                sorted(karma_dicc.items(), key=lambda item: item[1], reverse=True))
         for username, karma_count in karma_arranged.items():
             if limit > 9:
                 break

+ 3 - 4
wbb/modules/misc.py

@@ -21,7 +21,7 @@ __HELP__ = '''/commit - Generate Funny Commit Messages
 /cheat [Language] [Query] - Get Programming Related Help
 /weather [City] - To Get Weather Info
 /tr [en] - Translate A Message
-/json [URL] - Get Response From An API or Something. 
+/json [URL] - Get Response From An API or Something.
 #RTFM - Check it lol'''
 
 
@@ -122,7 +122,7 @@ async def decrypt(_, message):
 
 
 async def fetch_text(url):
-    async with aiohttp.ClientSession(headers={"user-agent":"curl"}) as session:
+    async with aiohttp.ClientSession(headers={"user-agent": "curl"}) as session:
         async with session.get(url) as resp:
             data = await resp.text()
     return data
@@ -198,7 +198,6 @@ async def tr(_, message):
         await message.reply_text(i.text)
 
 
-
 fetch_limit = 0
 
 
@@ -225,7 +224,7 @@ async def json_fetch(_, message):
     except Exception as e:
         await message.reply_text(str(e))
         print(str(e))
-    
+
 
 @app.on_message(filters.command('bun'))
 async def bunn(_, message):

+ 5 - 9
wbb/modules/music.py

@@ -1,6 +1,5 @@
 from __future__ import unicode_literals
 from urllib.parse import urlparse
-import os
 import youtube_dl
 import aiohttp
 import aiofiles
@@ -9,11 +8,9 @@ from random import randint
 from pyrogram import filters
 from wbb import app, SUDOERS, arq
 from wbb.utils.functions import convert_seconds_to_minutes
-from wbb.utils.fetch import fetch
 from wbb.utils.errors import capture_err
 
 
-
 __MODULE__ = "Music"
 __HELP__ = """/ytmusic [link] To Download Music From Various Websites Including Youtube.
 /saavn [query] To Download Music From Saavn.
@@ -49,7 +46,8 @@ async def music(_, message):
             # .webm -> .weba
             basename = audio_file.rsplit(".", 1)[-2]
             thumbnail_url = info_dict['thumbnail']
-            thumbnail_file = basename + "." + get_file_extension_from_url(thumbnail_url)
+            thumbnail_file = basename + "." + \
+                get_file_extension_from_url(thumbnail_url)
             audio_file = basename + ".mp3"
     except Exception as e:
         await m.edit(str(e))
@@ -103,7 +101,7 @@ async def jssong(_, message):
         ssingers = songs[0].singers
         duration = int(songs[0].duration)
         duration = convert_seconds_to_minutes(duration)
-        await m.edit("Downloading") 
+        await m.edit("Downloading")
         song = await download_song(slink)
         await m.edit("Uploading")
         await message.reply_audio(audio=song, title=sname,
@@ -115,7 +113,6 @@ async def jssong(_, message):
         return
 
 
-
 # Deezer Music
 
 
@@ -135,9 +132,9 @@ async def deezsong(_, message):
         artist = songs[0].artist
         duration = int(songs[0].duration)
         duration = convert_seconds_to_minutes(duration)
-        await m.edit("Downloading") 
+        await m.edit("Downloading")
         song = await download_song(url)
-        await m.edit("Uploading") 
+        await m.edit("Uploading")
         await message.reply_audio(audio=song, title=title,
                                   performer=artist, duration=duration)
         os.remove(song)
@@ -145,4 +142,3 @@ async def deezsong(_, message):
     except Exception as e:
         await m.edit(str(e))
         return
-

+ 8 - 10
wbb/modules/notes.py

@@ -1,9 +1,7 @@
 from wbb import app
 from wbb.utils.dbfunctions import (
-        _get_notes, save_note,
-        get_note_names, get_note,
-        delete_note
-        )
+    save_note, get_note_names, get_note, delete_note
+)
 from wbb.utils.errors import capture_err
 from wbb.modules.admin import member_permissions
 from pyrogram import filters
@@ -21,10 +19,10 @@ __HELP__ = """/notes To Get All The Notes In The Chat.
 async def save_notee(_, message):
     if len(message.command) < 2 or not message.reply_to_message:
         await message.reply_text("Usage:\nReply to a text or sticker with /save [NOTE_NAME] to save it.")
-    
+
     elif not message.reply_to_message.text and not message.reply_to_message.sticker:
         await message.reply_text("__**You can only save text or stickers in notes.**__")
-    
+
     elif len(await member_permissions(message.chat.id, message.from_user.id)) < 1:
         await message.reply_text("**You don't have enough permissions**")
     else:
@@ -67,7 +65,7 @@ async def get_one_note(_, message):
             return
         _note = await get_note(message.chat.id, name)
         if not _note:
-            await message.reply_text(f"**No such note.**")
+            await message.reply_text("**No such note.**")
         else:
             if _note["type"] == "text":
                 await message.reply_text(_note["data"])
@@ -80,10 +78,10 @@ async def get_one_note(_, message):
 async def del_note(_, message):
     if len(message.command) < 2:
         await message.reply_text("**Usage**\n__/delete [NOTE_NAME]__")
-    
+
     elif len(await member_permissions(message.chat.id, message.from_user.id)) < 1:
         await message.reply_text("**You don't have enough permissions**")
-    
+
     else:
         name = message.text.split(None, 1)[1].strip()
         if not name:
@@ -94,4 +92,4 @@ async def del_note(_, message):
         if deleted:
             await message.reply_text(f"**Deleted note {name} successfully.**")
         else:
-            await message.reply_text(f"**No such note.**")
+            await message.reply_text("**No such note.**")

+ 1 - 1
wbb/modules/regex.py

@@ -32,7 +32,7 @@ async def sed(_, message):
 
         try:
 
-            if infinite_checker(repl) == True:
+            if infinite_checker(repl):
                 await message.reply_text("Nice try -_-")
                 return
 

+ 1 - 1
wbb/modules/repo.py

@@ -13,7 +13,7 @@ __HELP__ = "/repo - To Get My Github Repository Link " \
 async def repo(_, message):
     users = await fetch("https://api.github.com/repos/thehamkercat/williambutcherbot/contributors")
     list_of_users = ""
-    count = 1    
+    count = 1
     for user in users:
         list_of_users += f"**{count}.** [{user['login']}]({user['html_url']})\n"
         count += 1

+ 0 - 1
wbb/modules/rice.py

@@ -95,4 +95,3 @@ async def callback_query_ignore_rice(_, callback_query):
         await callback_query.answer("Only admin or OP could ignore it")
         return
     await callback_query.message.delete()
-

+ 3 - 2
wbb/modules/stickers.py

@@ -5,9 +5,11 @@ from wbb.utils.errors import capture_err
 __MODULE__ = "Stickers"
 __HELP__ = """/sticker_id - To Get File ID of A Sticker."""
 
-## TODO Need to add /kang here
+# TODO Need to add /kang here
+
 
 @app.on_message(filters.command("sticker_id") & ~filters.edited)
+@capture_err
 async def sticker_id(_, message):
     if not message.reply_to_message:
         await message.reply_text("Reply to a sticker.")
@@ -17,4 +19,3 @@ async def sticker_id(_, message):
         return
     file_id = message.reply_to_message.sticker.file_id
     await message.reply_text(f"`{file_id}`")
-

+ 25 - 18
wbb/modules/sudoers.py

@@ -3,18 +3,16 @@ import time
 from pyrogram import filters, types
 import speedtest
 import psutil
-from subprocess import check_output
 from wbb import app, SUDOERS, bot_start_time
 from wbb.utils import nekobin, formatter
 from wbb.utils.errors import capture_err
 from wbb.utils.botinfo import BOT_ID
-from wbb.modules.global_stats import global_stats
 from wbb.utils.dbfunctions import (
-        is_gbanned_user,
-        add_gban_user,
-        remove_gban_user,
-        get_served_chats
-        )
+    is_gbanned_user,
+    add_gban_user,
+    remove_gban_user,
+    get_served_chats
+)
 
 
 __MODULE__ = "Sudoers"
@@ -149,17 +147,23 @@ async def ban_globally(_, message):
         else:
             served_chats = await get_served_chats()
             for served_chat in served_chats:
-                try: await app.kick_chat_member(served_chat['chat_id'], user_id)
-                except Exception: pass
+                try:
+                    await app.kick_chat_member(served_chat['chat_id'], user_id)
+                except Exception:
+                    pass
             await add_gban_user(user_id)
-            try: await app.send_message(
-            user_id, """Hello, You have been globally banned by {from_user_mention},
+            try:
+                await app.send_message(
+                    user_id, f"""
+Hello, You have been globally banned by {from_user_mention},
 You can appeal for this ban by talking to {from_user_mention} about this.""")
-            except Exception: pass
+            except Exception:
+                pass
             await message.reply_text(f"Banned {mention} Globally!")
 
 # Ungban
 
+
 @app.on_message(filters.command("ungban") & filters.user(SUDOERS))
 @capture_err
 async def unban_globally(_, message):
@@ -185,11 +189,12 @@ async def unban_globally(_, message):
 
 # Broadcast
 
+
 @app.on_message(
-        filters.command("/broadcast")
-        & filters.user(SUDOERS)
-        & ~filters.edited
-        )
+    filters.command("/broadcast")
+    & filters.user(SUDOERS)
+    & ~filters.edited
+)
 @capture_err
 async def broadcast_message(_, message):
     if len(message.command) < 2:
@@ -199,10 +204,12 @@ async def broadcast_message(_, message):
     sent = 0
     chats = []
     schats = await get_served_chats()
-    for chat in schats: chats.append(int(chat["chat_id"]))
+    for chat in schats:
+        chats.append(int(chat["chat_id"]))
     for i in chats:
         try:
             await app.send_message(i, text=text)
             sent += 1
-        except Exception: pass
+        except Exception:
+            pass
     await message.reply_text(f"**Broadcasted Message In {sent} Chats.**")

+ 1 - 1
wbb/utils/botinfo.py

@@ -8,7 +8,7 @@ async def get_info(app):
     global BOT_ID, BOT_NAME, BOT_USERNAME, BOT_DC_ID
     getme = await app.get_me()
     BOT_ID = getme.id
-    
+
     if getme.last_name:
         BOT_NAME = getme.first_name + " " + getme.last_name
     else:

+ 39 - 25
wbb/utils/dbfunctions.py

@@ -11,9 +11,11 @@ gbansdb = db.gban
 
 """ Notes functions """
 
+
 async def get_notes_count() -> dict:
     chats = notesdb.find({"chat_id": {"$lt": 0}})
-    if not chats: return {}
+    if not chats:
+        return {}
     chats_count = 0
     notes_count = 0
     for chat in await chats.to_list(length=1000000000):
@@ -21,10 +23,9 @@ async def get_notes_count() -> dict:
         notes_count += len(notes_name)
         chats_count += 1
     return {
-            "chats_count": chats_count,
-            "notes_count": notes_count
-            }
-
+        "chats_count": chats_count,
+        "notes_count": notes_count
+    }
 
 
 async def _get_notes(chat_id: int) -> Dict[str, int]:
@@ -91,7 +92,8 @@ async def delete_note(chat_id: int, name: str) -> bool:
 
 async def get_filters_count() -> dict:
     chats = filtersdb.find({"chat_id": {"$lt": 0}})
-    if not chats: return {}
+    if not chats:
+        return {}
     chats_count = 0
     filters_count = 0
     for chat in await chats.to_list(length=1000000000):
@@ -99,10 +101,9 @@ async def get_filters_count() -> dict:
         filters_count += len(filters_name)
         chats_count += 1
     return {
-            "chats_count": chats_count,
-            "filters_count": filters_count
-            }
-
+        "chats_count": chats_count,
+        "filters_count": filters_count
+    }
 
 
 async def _get_filters(chat_id: int) -> Dict[str, int]:
@@ -187,7 +188,8 @@ async def alpha_to_int(user_id_alphabet: str) -> int:
 
 async def get_warns_count() -> dict:
     chats = warnsdb.find({"chat_id": {"$lt": 0}})
-    if not chats: return {}
+    if not chats:
+        return {}
     chats_count = 0
     warns_count = 0
     for chat in await chats.to_list(length=100000000):
@@ -195,9 +197,10 @@ async def get_warns_count() -> dict:
             warns_count += chat['warns'][user]['warns']
         chats_count += 1
     return {
-            "chats_count": chats_count,
-            "warns_count": warns_count
-            }
+        "chats_count": chats_count,
+        "warns_count": warns_count
+    }
+
 
 async def get_warns(chat_id: int) -> Dict[str, int]:
     warns = await warnsdb.find_one({"chat_id": chat_id})
@@ -251,9 +254,11 @@ async def remove_warns(chat_id: int, name: str) -> bool:
 
 """ Karma functions """
 
+
 async def get_karmas_count() -> dict:
     chats = karmadb.find({"chat_id": {"$lt": 0}})
-    if not chats: return {}
+    if not chats:
+        return {}
     chats_count = 0
     karmas_count = 0
     for chat in await chats.to_list(length=1000000):
@@ -261,9 +266,10 @@ async def get_karmas_count() -> dict:
             karmas_count += chat['karma'][i]['karma']
         chats_count += 1
     return {
-            "chats_count": chats_count,
-            "karmas_count": karmas_count
-            }
+        "chats_count": chats_count,
+        "karmas_count": karmas_count
+    }
+
 
 async def get_karmas(chat_id: int) -> Dict[str, int]:
     karma = await karmadb.find_one({"chat_id": chat_id})
@@ -298,15 +304,18 @@ async def update_karma(chat_id: int, name: str, karma: dict):
 
 """ Chats log functions """
 
+
 async def is_served_chat(chat_id: int) -> bool:
     chat = await chatsdb.find_one({"chat_id": chat_id})
-    if not chat: return False
+    if not chat:
+        return False
     return True
 
 
 async def get_served_chats() -> list:
     chats = chatsdb.find({"chat_id": {'$lt': 0}})
-    if not chats: return []
+    if not chats:
+        return []
     chats_list = []
     for chat in await chats.to_list(length=1000000000):
         chats_list.append(chat)
@@ -315,13 +324,15 @@ async def get_served_chats() -> list:
 
 async def add_served_chat(chat_id: int):
     is_served = await is_served_chat(chat_id)
-    if is_served: return
+    if is_served:
+        return
     return await chatsdb.insert_one({"chat_id": chat_id})
 
 
 async def remove_served_chat(chat_id: int):
     is_served = await is_served_chat(chat_id)
-    if not is_served: return
+    if not is_served:
+        return
     return await chatsdb.delete_one({"chat_id": chat_id})
 
 
@@ -336,17 +347,20 @@ async def get_gbans_count() -> int:
 
 async def is_gbanned_user(user_id: int) -> bool:
     user = await gbansdb.find_one({"user_id": user_id})
-    if not user: return False
+    if not user:
+        return False
     return True
 
 
 async def add_gban_user(user_id: int):
     is_gbanned = await is_gbanned_user(user_id)
-    if is_gbanned: return
+    if is_gbanned:
+        return
     return await gbansdb.insert_one({"user_id": user_id})
 
 
 async def remove_gban_user(user_id: int):
     is_gbanned = await is_gbanned_user(user_id)
-    if not is_gbanned: return
+    if not is_gbanned:
+        return
     return await gbansdb.delete_one({"user_id": user_id})

+ 2 - 0
wbb/utils/errors.py

@@ -3,6 +3,7 @@ import traceback
 from functools import wraps
 from wbb import app, LOG_GROUP_ID
 
+
 def split_limits(text):
     if len(text) < 2048:
         return [text]
@@ -21,6 +22,7 @@ def split_limits(text):
 
     return result
 
+
 def capture_err(func):
     @wraps(func)
     async def capture(client, message, *args, **kwargs):

+ 3 - 1
wbb/utils/fetch.py

@@ -1,9 +1,11 @@
 import aiohttp
+
+
 async def fetch(url):
     async with aiohttp.ClientSession() as session:
         async with session.get(url) as resp:
             try:
                 data = await resp.json()
-            except:
+            except Exception:
                 data = await resp.text()
     return data

+ 5 - 4
wbb/utils/json_prettify.py

@@ -1,21 +1,22 @@
 async def json_object_prettify(objecc):
     dicc = objecc.__dict__
     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":
             continue
         output += f"**{key}:** `{value}`\n"
     return output
 
+
 async def json_prettify(data):
     output = ""
     try:
-        for key , value in data.items():
+        for key, value in data.items():
             output += f"**{key}:** `{value}`\n"
-    except:
+    except Exception:
         for datas in data:
-            for key , value in datas.items():
+            for key, value in datas.items():
                 output += f"**{key}:** `{value}`\n"
             output += "------------------------\n"
     return output