Переглянути джерело

Format, always use '-l 79' black arg

TheHamkerCat 4 роки тому
батько
коміт
cc3fbd4b8a

+ 15 - 15
wbb/__main__.py

@@ -48,13 +48,13 @@ async def start_bot():
     for module in ALL_MODULES:
         imported_module = importlib.import_module("wbb.modules." + module)
         if (
-                hasattr(imported_module, "__MODULE__")
-                and imported_module.__MODULE__
+            hasattr(imported_module, "__MODULE__")
+            and imported_module.__MODULE__
         ):
             imported_module.__MODULE__ = imported_module.__MODULE__
             if (
-                    hasattr(imported_module, "__HELP__")
-                    and imported_module.__HELP__
+                hasattr(imported_module, "__HELP__")
+                and imported_module.__HELP__
             ):
                 HELPABLE[
                     imported_module.__MODULE__.replace(" ", "_").lower()
@@ -133,9 +133,9 @@ home_keyboard_pm = InlineKeyboardMarkup(
 )
 
 home_text_pm = (
-        f"Hey there! My name is {BOT_NAME}. I can manage your "
-        + "group with lots of useful features, feel free to "
-        + "add me to your group."
+    f"Hey there! My name is {BOT_NAME}. I can manage your "
+    + "group with lots of useful features, feel free to "
+    + "add me to your group."
 )
 
 keyboard = InlineKeyboardMarkup(
@@ -176,8 +176,8 @@ async def start(_, message):
         elif "_" in name:
             module = name.split("_", 1)[1]
             text = (
-                    f"Here is the help for **{HELPABLE[module].__MODULE__}**:\n"
-                    + HELPABLE[module].__HELP__
+                f"Here is the help for **{HELPABLE[module].__MODULE__}**:\n"
+                + HELPABLE[module].__HELP__
             )
             await message.reply(text, disable_web_page_preview=True)
         elif name == "help":
@@ -227,8 +227,8 @@ async def help_command(_, message):
             name = (message.text.split(None, 1)[1]).replace(" ", "_").lower()
             if str(name) in HELPABLE:
                 text = (
-                        f"Here is the help for **{HELPABLE[name].__MODULE__}**:\n"
-                        + HELPABLE[name].__HELP__
+                    f"Here is the help for **{HELPABLE[name].__MODULE__}**:\n"
+                    + HELPABLE[name].__HELP__
                 )
                 await message.reply(text, disable_web_page_preview=True)
             else:
@@ -305,10 +305,10 @@ General command are:
     if mod_match:
         module = (mod_match.group(1)).replace(" ", "_")
         text = (
-                "{} **{}**:\n".format(
-                    "Here is the help for", HELPABLE[module].__MODULE__
-                )
-                + HELPABLE[module].__HELP__
+            "{} **{}**:\n".format(
+                "Here is the help for", HELPABLE[module].__MODULE__
+            )
+            + HELPABLE[module].__HELP__
         )
 
         await query.message.edit(

+ 9 - 22
wbb/modules/admin.py

@@ -25,28 +25,16 @@ import asyncio
 from time import time
 
 from pyrogram import filters
-from pyrogram.types import (
-    CallbackQuery,
-    ChatPermissions,
-    Message,
-    ChatMemberUpdated,
-)
+from pyrogram.types import (CallbackQuery, ChatMemberUpdated, ChatPermissions,
+                            Message)
 
 from wbb import BOT_ID, SUDOERS, app, log
 from wbb.core.decorators.errors import capture_err
 from wbb.core.keyboard import ikb
-from wbb.utils.dbfunctions import (
-    add_warn,
-    get_warn,
-    int_to_alpha,
-    remove_warns,
-    save_filter,
-)
-from wbb.utils.functions import (
-    extract_user,
-    extract_user_and_reason,
-    time_converter,
-)
+from wbb.utils.dbfunctions import (add_warn, get_warn, int_to_alpha,
+                                   remove_warns, save_filter)
+from wbb.utils.functions import (extract_user, extract_user_and_reason,
+                                 time_converter)
 
 __MODULE__ = "Admin"
 __HELP__ = """/ban - Ban A User
@@ -315,11 +303,10 @@ async def unban_func(_, message: Message):
     # normal users won't get text_mention if the user
     # they want to unban is not in the group.
     reply = message.reply_to_message
-    
-    if (reply and reply.sender_chat 
-        and reply.sender_chat != message.chat.id):
+
+    if reply and reply.sender_chat and reply.sender_chat != message.chat.id:
         return await message.reply_text("You cannot unban a channel")
-        
+
     if len(message.command) == 2:
         user = message.text.split(None, 1)[1]
     elif len(message.command) == 1 and reply:

+ 1 - 3
wbb/modules/alive.py

@@ -27,9 +27,7 @@ from pyrogram import filters
 from wbb import BOT_ID, SUDOERS, USERBOT_PREFIX, app2
 
 
-@app2.on_message(
-    filters.command("alive", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("alive", prefixes=USERBOT_PREFIX) & SUDOERS)
 async def alive_command_func(_, message):
     await message.delete()
     results = await app2.get_inline_bot_results(BOT_ID, "alive")

+ 2 - 4
wbb/modules/anonymize.py

@@ -39,8 +39,7 @@ from wbb.utils.functions import extract_user
 
 
 @app2.on_message(
-    filters.command("anonymize", prefixes=USERBOT_PREFIX)
-    & SUDOERS
+    filters.command("anonymize", prefixes=USERBOT_PREFIX) & SUDOERS
 )
 async def change_profile(_, message: Message):
     m = await eor(message, text="Anonymizing...")
@@ -68,8 +67,7 @@ async def change_profile(_, message: Message):
 
 
 @app2.on_message(
-    filters.command("impersonate", prefixes=USERBOT_PREFIX)
-    & SUDOERS
+    filters.command("impersonate", prefixes=USERBOT_PREFIX) & SUDOERS
 )
 async def impersonate(_, message: Message):
     user_id = await extract_user(message)

+ 6 - 4
wbb/modules/autocorrect.py

@@ -2,8 +2,9 @@ from pyrogram import filters
 from pyrogram.types import Message
 
 from wbb import SUDOERS, USERBOT_ID, USERBOT_PREFIX, app, app2, arq
-from wbb.utils.filter_groups import autocorrect_group
 from wbb.modules.userbot import eor
+from wbb.utils.filter_groups import autocorrect_group
+
 
 @app.on_message(filters.command("autocorrect"))
 async def autocorrect_bot(_, message: Message):
@@ -24,8 +25,7 @@ IS_ENABLED = False
 
 
 @app2.on_message(
-    filters.command("autocorrect", prefixes=USERBOT_PREFIX)
-    & SUDOERS
+    filters.command("autocorrect", prefixes=USERBOT_PREFIX) & SUDOERS
 )
 async def autocorrect_ubot_toggle(_, message: Message):
     global IS_ENABLED
@@ -39,7 +39,9 @@ async def autocorrect_ubot_toggle(_, message: Message):
         IS_ENABLED = False
         await eor(message, text="Disabled!")
     else:
-        return await eor(message, text="Wrong argument, Pass (ENABLE|DISABLE).")
+        return await eor(
+            message, text="Wrong argument, Pass (ENABLE|DISABLE)."
+        )
 
 
 @app2.on_message(

+ 1 - 3
wbb/modules/dice.py

@@ -10,9 +10,7 @@ __HELP__ = """
 """
 
 
-@app2.on_message(
-    filters.command("dice", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("dice", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("dice"))
 async def throw_dice(client, message: Message):
     six = (message.from_user.id in SUDOERS) if message.from_user else False

+ 2 - 5
wbb/modules/download_upload.py

@@ -37,8 +37,7 @@ from wbb.utils.downloader import download
 
 
 @app2.on_message(
-    SUDOERS
-    & filters.command("download", prefixes=USERBOT_PREFIX)
+    SUDOERS & filters.command("download", prefixes=USERBOT_PREFIX)
 )
 async def download_func(_, message: Message):
     reply = message.reply_to_message
@@ -106,9 +105,7 @@ async def download_func(_, message: Message):
     await eor(m, text=section("Downloaded", body))
 
 
-@app2.on_message(
-    SUDOERS & filters.command("upload", prefixes=USERBOT_PREFIX)
-)
+@app2.on_message(SUDOERS & filters.command("upload", prefixes=USERBOT_PREFIX))
 async def upload_func(_, message: Message):
     if len(message.text.split()) != 2:
         return await eor(message, text="Invalid Arguments")

+ 1 - 1
wbb/modules/flood.py

@@ -87,7 +87,7 @@ async def flood_control_func(_, message: Message):
     reset_flood(chat_id, user_id)
 
     # Ignore devs and admins
-    mods = (await list_admins(chat_id))
+    mods = await list_admins(chat_id)
     if user_id in mods or user_id in SUDOERS:
         return
 

+ 2 - 6
wbb/modules/global_stats.py

@@ -39,9 +39,7 @@ from wbb.utils.http import get
 from wbb.utils.inlinefuncs import keywords_list
 
 
-@app.on_message(
-    filters.command("clean_db") & ~filters.edited & SUDOERS
-)
+@app.on_message(filters.command("clean_db") & ~filters.edited & SUDOERS)
 @capture_err
 async def clean_db(_, message):
     served_chats = [int(i["chat_id"]) for i in (await get_served_chats())]
@@ -61,9 +59,7 @@ async def clean_db(_, message):
     await m.edit("**Database Cleaned.**")
 
 
-@app.on_message(
-    filters.command("gstats") & ~filters.edited & SUDOERS
-)
+@app.on_message(filters.command("gstats") & ~filters.edited & SUDOERS)
 @capture_err
 async def global_stats(_, message):
     m = await app.send_message(

+ 2 - 3
wbb/modules/greetings.py

@@ -201,9 +201,7 @@ async def welcome(_, message: Message):
         await asyncio.sleep(0.5)
 
 
-async def send_welcome_message(
-        chat: Chat, user_id: int, delete: bool = False
-        ):
+async def send_welcome_message(chat: Chat, user_id: int, delete: bool = False):
     raw_text = await get_welcome(chat.id)
 
     if not raw_text:
@@ -225,6 +223,7 @@ async def send_welcome_message(
         )
         await asyncio.sleep(300)
         await m.delete()
+
     asyncio.create_task(_send_wait_delete())
 
 

+ 1 - 1
wbb/modules/locks.py

@@ -155,7 +155,7 @@ async def url_detector(_, message):
 
     if not text or not user:
         return
-    mods = (await list_admins(chat_id))
+    mods = await list_admins(chat_id)
     if user.id in mods or user.id in SUDOERS:
         return
 

+ 1 - 3
wbb/modules/misc.py

@@ -131,9 +131,7 @@ async def runs(_, message):
     await message.reply_text((await random_line("wbb/utils/runs.txt")))
 
 
-@app2.on_message(
-    filters.command("id", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("id", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("id"))
 async def getid(client, message):
     chat = message.chat

+ 4 - 12
wbb/modules/notes.py

@@ -46,9 +46,7 @@ Checkout /markdownhelp to know more about formattings and other syntax.
 """
 
 
-@app2.on_message(
-    filters.command("save", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("save", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("save") & ~filters.edited & ~filters.private)
 @adminsOnly("can_change_info")
 async def save_notee(_, message):
@@ -83,9 +81,7 @@ async def save_notee(_, message):
         await eor(message, text=f"__**Saved note {name}.**__")
 
 
-@app2.on_message(
-    filters.command("notes", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("notes", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("notes") & ~filters.edited & ~filters.private)
 @capture_err
 async def get_notes(_, message):
@@ -104,9 +100,7 @@ async def get_notes(_, message):
     await eor(message, text=msg)
 
 
-@app2.on_message(
-    filters.command("get", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("get", prefixes=USERBOT_PREFIX) & SUDOERS)
 async def get_one_note_userbot(_, message):
     if len(message.text.split()) < 2:
         return await eor(message, text="Invalid arguments")
@@ -155,9 +149,7 @@ async def get_one_note(_, message):
         await message.reply_sticker(_note["data"])
 
 
-@app2.on_message(
-    filters.command("delete", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("delete", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("delete") & ~filters.edited & ~filters.private)
 @adminsOnly("can_change_info")
 async def del_note(_, message):

+ 2 - 3
wbb/modules/parse_preview.py

@@ -8,8 +8,7 @@ from wbb.core.sections import section
 
 
 @app2.on_message(
-    filters.command("parse_preview", prefixes=USERBOT_PREFIX)
-    & SUDOERS
+    filters.command("parse_preview", prefixes=USERBOT_PREFIX) & SUDOERS
 )
 async def parse(_, message: Message):
     r = message.reply_to_message
@@ -18,7 +17,7 @@ async def parse(_, message: Message):
         return await eor(message, text="Reply to a message with a webpage")
 
     m_ = await eor(message, text="Parsing...")
-    
+
     if not r.web_page:
         text = r.text or r.caption
         if text:

+ 1 - 3
wbb/modules/paste.py

@@ -38,9 +38,7 @@ __HELP__ = "/paste - To Paste Replied Text Or Document To A Pastebin"
 pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
 
 
-@app2.on_message(
-    filters.command("paste", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("paste", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("paste") & ~filters.edited)
 @capture_err
 async def paste_func(_, message: Message):

+ 2 - 2
wbb/modules/purge_me.py

@@ -25,7 +25,7 @@ SOFTWARE.
 from pyrogram import filters
 from pyrogram.types import Message
 
-from wbb import USERBOT_ID, USERBOT_PREFIX, app2, eor, telegraph, log
+from wbb import USERBOT_ID, USERBOT_PREFIX, app2, eor, log, telegraph
 
 __MODULE__ = "Userbot"
 TEXT = """
@@ -136,7 +136,7 @@ async def purge_me_func(_, message: Message):
     # we have to do it in chunks of 100, i'll choose 99 just
     # to be safe.
     to_delete = [
-        message_ids[i: i + 99] for i in range(0, len(message_ids), 99)
+        message_ids[i : i + 99] for i in range(0, len(message_ids), 99)
     ]
 
     for hundred_messages_or_less in to_delete:

+ 1 - 3
wbb/modules/quotly.py

@@ -64,9 +64,7 @@ def isArgInt(message: Message) -> list:
         return [False, 0]
 
 
-@app2.on_message(
-    filters.command("q", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("q", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("q") & ~filters.private)
 @capture_err
 async def quotly_func(client, message: Message):

+ 1 - 3
wbb/modules/reverse.py

@@ -44,9 +44,7 @@ async def get_soup(url: str, headers):
     return BeautifulSoup(html, "html.parser")
 
 
-@app2.on_message(
-    filters.command("reverse", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("reverse", prefixes=USERBOT_PREFIX) & SUDOERS)
 @app.on_message(filters.command("reverse"))
 @capture_err
 async def reverse_image_search(client, message: Message):

+ 11 - 17
wbb/modules/sudo.py

@@ -45,9 +45,7 @@ can even delete your account.
 """
 
 
-@app2.on_message(
-    filters.command("useradd", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("useradd", prefixes=USERBOT_PREFIX) & SUDOERS)
 @capture_err
 async def useradd(_, message: Message):
     if not message.reply_to_message:
@@ -58,28 +56,26 @@ async def useradd(_, message: Message):
     user_id = message.reply_to_message.from_user.id
     umention = (await app2.get_users(user_id)).mention
     sudoers = await get_sudoers()
-    
+
     if user_id in sudoers:
         return await eor(message, text=f"{umention} is already in sudoers.")
     if user_id == BOT_ID:
         return await eor(
             message, text="You can't add assistant bot in sudoers."
         )
-    
+
     await add_sudo(user_id)
-    
+
     if user_id not in SUDOERS:
         SUDOERS.add(user_id)
-    
+
     await eor(
         message,
         text=f"Successfully added {umention} in sudoers.",
     )
 
 
-@app2.on_message(
-    filters.command("userdel", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("userdel", prefixes=USERBOT_PREFIX) & SUDOERS)
 @capture_err
 async def userdel(_, message: Message):
     if not message.reply_to_message:
@@ -89,24 +85,22 @@ async def userdel(_, message: Message):
         )
     user_id = message.reply_to_message.from_user.id
     umention = (await app2.get_users(user_id)).mention
-    
+
     if user_id not in await get_sudoers():
         return await eor(message, text=f"{umention} is not in sudoers.")
-    
+
     await remove_sudo(user_id)
-    
+
     if user_id in SUDOERS:
         SUDOERS.remove(user_id)
-    
+
     await eor(
         message,
         text=f"Successfully removed {umention} from sudoers.",
     )
 
 
-@app2.on_message(
-    filters.command("sudoers", prefixes=USERBOT_PREFIX) & SUDOERS
-)
+@app2.on_message(filters.command("sudoers", prefixes=USERBOT_PREFIX) & SUDOERS)
 @capture_err
 async def sudoers_list(_, message: Message):
     sudoers = await get_sudoers()

+ 4 - 14
wbb/modules/sudoers.py

@@ -30,22 +30,12 @@ import psutil
 from pyrogram import filters
 from pyrogram.errors import FloodWait
 
-from wbb import (
-    BOT_ID,
-    GBAN_LOG_GROUP_ID,
-    SUDOERS,
-    USERBOT_USERNAME,
-    app,
-    bot_start_time,
-)
+from wbb import (BOT_ID, GBAN_LOG_GROUP_ID, SUDOERS, USERBOT_USERNAME, app,
+                 bot_start_time)
 from wbb.core.decorators.errors import capture_err
 from wbb.utils import formatter
-from wbb.utils.dbfunctions import (
-    add_gban_user,
-    get_served_chats,
-    is_gbanned_user,
-    remove_gban_user,
-)
+from wbb.utils.dbfunctions import (add_gban_user, get_served_chats,
+                                   is_gbanned_user, remove_gban_user)
 from wbb.utils.functions import extract_user, extract_user_and_reason, restart
 
 __MODULE__ = "Sudoers"

+ 1 - 0
wbb/utils/dbfunctions.py

@@ -648,6 +648,7 @@ async def blacklisted_chats() -> list:
         blacklist_chat.append(chat["chat_id"])
     return blacklist_chat
 
+
 async def blacklist_chat(chat_id: int) -> bool:
     if not await blacklist_chatdb.find_one({"chat_id": chat_id}):
         await blacklist_chatdb.insert_one({"chat_id": chat_id})

+ 1 - 1
wbb/utils/functions.py

@@ -94,7 +94,7 @@ def generate_captcha():
 
 def test_speedtest():
     def speed_convert(size):
-        power = 2 ** 10
+        power = 2**10
         zero = 0
         units = {0: "", 1: "Kb/s", 2: "Mb/s", 3: "Gb/s", 4: "Tb/s"}
         while size > power: