Browse Source

refactor: format

TheHamkerCat 2 years ago
parent
commit
6aa954dc96

+ 12 - 6
wbb/__main__.py

@@ -45,13 +45,14 @@ from wbb.modules import ALL_MODULES
 from wbb.modules.sudoers import bot_sys_stats
 from wbb.utils import paginate_modules
 from wbb.utils.constants import MARKDOWN
-from wbb.utils.functions import extract_text_and_keyb
 from wbb.utils.dbfunctions import clean_restart_stage, get_rules
+from wbb.utils.functions import extract_text_and_keyb
 
 loop = asyncio.get_event_loop()
 
 HELPABLE = {}
 
+
 async def start_bot():
     global HELPABLE
 
@@ -174,8 +175,12 @@ keyboard = InlineKeyboardMarkup(
 FED_MARKUP = InlineKeyboardMarkup(
     [
         [
-            InlineKeyboardButton("Fed Owner Commands", callback_data="fed_owner"),
-            InlineKeyboardButton("Fed Admin Commands", callback_data="fed_admin"),
+            InlineKeyboardButton(
+                "Fed Owner Commands", callback_data="fed_owner"
+            ),
+            InlineKeyboardButton(
+                "Fed Admin Commands", callback_data="fed_admin"
+            ),
         ],
         [
             InlineKeyboardButton("User Commands", callback_data="fed_user"),
@@ -196,7 +201,7 @@ async def start(_, message):
     if len(message.text.split()) > 1:
         user = await app.get_users(message.from_user.id)
         name = (message.text.split(None, 1)[1]).lower()
-        match = re.match(r"rules_(.*)", name)  
+        match = re.match(r"rules_(.*)", name)
         if match:
             chat_id = match.group(1)
             user_id = message.from_user.id
@@ -217,7 +222,7 @@ async def start(_, message):
                 return await app.send_message(
                     user_id,
                     "The group admins haven't set any rules for this chat yet. "
-                    "This probably doesn't mean it's lawless though...!"
+                    "This probably doesn't mean it's lawless though...!",
                 )
         if name == "mkdwn_help":
             await message.reply(
@@ -242,7 +247,8 @@ async def start(_, message):
                 reply_markup=InlineKeyboardMarkup(
                     [[InlineKeyboardButton("back", callback_data="help_back")]]
                 ),
-                disable_web_page_preview=True)
+                disable_web_page_preview=True,
+            )
         elif name == "help":
             text, keyb = await help_parser(message.from_user.first_name)
             await message.reply(

+ 6 - 4
wbb/modules/admin.py

@@ -27,7 +27,7 @@ from contextlib import suppress
 from time import time
 
 from pyrogram import filters
-from pyrogram.enums import ChatMembersFilter, ChatType, ChatMemberStatus
+from pyrogram.enums import ChatMembersFilter, ChatMemberStatus, ChatType
 from pyrogram.errors import FloodWait
 from pyrogram.types import (
     CallbackQuery,
@@ -521,7 +521,7 @@ async def demote(_, message: Message):
         )
     try:
         member = await app.get_chat_member(message.chat.id, user_id)
-        if member.status ==  ChatMemberStatus.ADMINISTRATOR:
+        if member.status == ChatMemberStatus.ADMINISTRATOR:
             await message.chat.promote_member(
                 user_id=user_id,
                 privileges=ChatPrivileges(
@@ -538,7 +538,9 @@ async def demote(_, message: Message):
             umention = (await app.get_users(user_id)).mention
             await message.reply_text(f"Demoted! {umention}")
         else:
-            await message.reply_text("The person you mentioned is not an admin.")
+            await message.reply_text(
+                "The person you mentioned is not an admin."
+            )
     except Exception as e:
         await message.reply_text(e)
 
@@ -610,7 +612,7 @@ async def mute(_, message: Message):
                 )
                 replied_message = message.reply_to_message
                 if replied_message:
-                   message = replied_message
+                    message = replied_message
                 await message.reply_text(msg, reply_markup=keyboard)
             else:
                 await message.reply_text("You can't use more than 99")

+ 22 - 13
wbb/modules/autoapprove.py

@@ -22,22 +22,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
 
-from wbb import app, SUDOERS
-from wbb import db
 from pyrogram import filters
 from pyrogram.enums import ChatMembersFilter
 from pyrogram.types import (
-    InlineKeyboardButton,
-    InlineKeyboardMarkup,
     CallbackQuery,
-    Message,
     Chat,
     ChatJoinRequest,
+    InlineKeyboardButton,
+    InlineKeyboardMarkup,
+    Message,
 )
-from wbb.modules.greetings import handle_new_member, send_welcome_message
-from wbb.core.keyboard import ikb
+
+from wbb import SUDOERS, app, db
 from wbb.core.decorators.permissions import adminsOnly
+from wbb.core.keyboard import ikb
 from wbb.modules.admin import member_permissions
+from wbb.modules.greetings import handle_new_member, send_welcome_message
 
 approvaldb = db.autoapprove
 
@@ -69,12 +69,15 @@ async def approval_command(client, message):
                 {"chat_id": chat_id},
                 {"$set": {"mode": mode}},
                 upsert=True,
-                   )
+            )
         if mode == "automatic":
             switch = "manual"
         else:
             switch = "automatic"
-        buttons = {"Turn OFF": "approval_off", f"{(mode.upper())}": f"approval_{switch}"}
+        buttons = {
+            "Turn OFF": "approval_off",
+            f"{(mode.upper())}": f"approval_{switch}",
+        }
         keyboard = ikb(buttons, 1)
         await message.reply(
             "**Autoapproval for this chat: Enabled.**", reply_markup=keyboard
@@ -107,7 +110,8 @@ async def approval_cb(client, cb):
             buttons = {"Turn ON": "approval_on"}
             keyboard = ikb(buttons, 1)
             return await cb.edit_message_text(
-                "**Autoapproval for this chat: Disabled.**", reply_markup=keyboard
+                "**Autoapproval for this chat: Disabled.**",
+                reply_markup=keyboard,
             )
     if option == "on":
         switch = "manual"
@@ -154,7 +158,9 @@ async def accept(client, message: ChatJoinRequest):
     if chat_id:
         mode = chat_id["mode"]
         if mode == "automatic":
-            await app.approve_chat_join_request(chat_id=chat.id, user_id=user.id)
+            await app.approve_chat_join_request(
+                chat_id=chat.id, user_id=user.id
+            )
             return await handle_new_member(message, user, chat_id)
         if mode == "manual":
             is_user_in_pending = await approvaldb.count_documents(
@@ -175,14 +181,17 @@ async def accept(client, message: ChatJoinRequest):
                 admin_data = [
                     i
                     async for i in app.get_chat_members(
-                        chat_id=message.chat.id, filter=ChatMembersFilter.ADMINISTRATORS
+                        chat_id=message.chat.id,
+                        filter=ChatMembersFilter.ADMINISTRATORS,
                     )
                 ]
                 for admin in admin_data:
                     if admin.user.is_bot or admin.user.is_deleted:
                         continue
                     text += f"[\u2063](tg://user?id={admin.user.id})"
-                return await app.send_message(chat.id, text, reply_markup=keyboard)
+                return await app.send_message(
+                    chat.id, text, reply_markup=keyboard
+                )
 
 
 @app.on_callback_query(filters.regex("manual_(.*)"))

+ 85 - 32
wbb/modules/feds.py

@@ -22,16 +22,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
 
-import uuid
 import asyncio
-from wbb.utils.dbfeds import *
-from wbb import app, SUDOERS, LOG_GROUP_ID, BOT_ID
+import uuid
+
 from pyrogram import filters
 from pyrogram.enums import ChatMemberStatus, ChatType, ParseMode
-from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from wbb.utils.functions import extract_user, extract_user_and_reason
 from pyrogram.errors import FloodWait
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
+
+from wbb import BOT_ID, LOG_GROUP_ID, SUDOERS, app
 from wbb.core.decorators.errors import capture_err
+from wbb.utils.dbfeds import *
+from wbb.utils.functions import extract_user, extract_user_and_reason
 
 __MODULE__ = "Federation"
 __HELP__ = """
@@ -94,13 +96,17 @@ async def new_fed(client, message):
         try:
             await app.send_message(
                 LOG_GROUP_ID,
-                "New Federation: <b>{}</b>\nID: <pre>{}</pre>".format(fed_name, fed_id),
+                "New Federation: <b>{}</b>\nID: <pre>{}</pre>".format(
+                    fed_name, fed_id
+                ),
                 parse_mode=ParseMode.HTML,
             )
         except:
             log.info("Cannot send a message to EVENT_LOGS")
     else:
-        await message.reply_text("Please write down the name of the federation")
+        await message.reply_text(
+            "Please write down the name of the federation"
+        )
 
 
 @app.on_message(filters.command("delfed"))
@@ -162,7 +168,9 @@ async def fedtransfer(client, message):
         return
     is_feds = await get_feds_by_owner(int(user.id))
     if not is_feds:
-        return await message.reply_text("**You haven't created any federations.**")
+        return await message.reply_text(
+            "**You haven't created any federations.**"
+        )
     if len(message.command) < 2:
         return await message.reply_text(
             "**You needed to specify a user or reply to their message!**"
@@ -236,7 +244,9 @@ async def rename_fed(client, message):
             {"$set": {"fed_name": str(newname), "owner_id": int(user.id)}},
             upsert=True,
         )
-        await msg.reply_text(f"Successfully renamed your fed name to {newname}!")
+        await msg.reply_text(
+            f"Successfully renamed your fed name to {newname}!"
+        )
     else:
         await msg.reply_text("Only federation owner can do this!")
 
@@ -272,7 +282,9 @@ async def fed_log(client, message):
                 log_group_id = chat.id
             loged = await set_log_chat(fed_id, log_group_id)
             if "/unsetfedlog" in message.text:
-                return await message.reply_text("log channel removed successfully.")
+                return await message.reply_text(
+                    "log channel removed successfully."
+                )
             else:
                 await message.reply_text("log channel set successfully.")
     else:
@@ -295,7 +307,9 @@ async def fed_chat(client, message):
     ):
         pass
     else:
-        await message.reply_text("You must be an admin to execute this command")
+        await message.reply_text(
+            "You must be an admin to execute this command"
+        )
         return
 
     if not fed_id:
@@ -329,10 +343,14 @@ async def join_fed(client, message):
         if member.status == ChatMemberStatus.OWNER:
             pass
         else:
-            await message.reply_text("Only group creators can use this command!")
+            await message.reply_text(
+                "Only group creators can use this command!"
+            )
             return
     if fed_id:
-        await message.reply_text("You cannot join two federations from one chat")
+        await message.reply_text(
+            "You cannot join two federations from one chat"
+        )
         return
     args = message.text.split(" ", 1)
     if len(args) > 1:
@@ -360,7 +378,9 @@ async def join_fed(client, message):
             )
 
         await message.reply_text(
-            "This group has joined the federation: {}!".format(getfed["fed_name"])
+            "This group has joined the federation: {}!".format(
+                getfed["fed_name"]
+            )
         )
     else:
         await message.reply_text(
@@ -396,7 +416,9 @@ async def leave_fed(client, message):
                     parse_mode=ParseMode.MARKDOWN,
                 )
             await message.reply_text(
-                "This group has left the federation {}!".format(fed_info["fed_name"]),
+                "This group has left the federation {}!".format(
+                    fed_info["fed_name"]
+                ),
             )
         else:
             await message.reply_text(
@@ -437,7 +459,9 @@ async def fed_chat(client, message):
 
         chat_ids, chat_names = await chat_id_and_names_in_fed(fed_id)
         if not chat_ids:
-            return await message.reply_text("There are no chats in this federation!")
+            return await message.reply_text(
+                "There are no chats in this federation!"
+            )
         text = "\n".join(
             [
                 f"${chat_name} [`{chat_id}`]"
@@ -453,7 +477,9 @@ async def fed_chat(client, message):
 @capture_err
 async def fed_info(client, message):
     if len(message.command) < 2:
-        return await message.reply_text("Please provide the Fed Id to get information!")
+        return await message.reply_text(
+            "Please provide the Fed Id to get information!"
+        )
 
     fed_id = message.text.split(" ", 1)[1].strip()
     fed_info = await get_fed_info(fed_id)
@@ -477,8 +503,8 @@ async def fed_info(client, message):
     )
 
     await message.reply_text(reply_text)
-    
-    
+
+
 @app.on_message(filters.command("fedadmins"))
 @capture_err
 async def get_all_fadmins_mentions(client, message):
@@ -493,7 +519,9 @@ async def get_all_fadmins_mentions(client, message):
 
     fadmin_ids = fed_info.get("fadmins", [])
     if not fadmin_ids:
-        return await message.reply_text(f"**Owner: {fed_info['owner_mention']}\n\nNo fadmins found in the federation.")
+        return await message.reply_text(
+            f"**Owner: {fed_info['owner_mention']}\n\nNo fadmins found in the federation."
+        )
 
     user_mentions = []
     for user_id in fadmin_ids:
@@ -502,7 +530,10 @@ async def get_all_fadmins_mentions(client, message):
             user_mentions.append(f"● {user.mention}[`{user.id}`]")
         except Exception:
             user_mentions.append(f"● `Admin🥷`[`{user_id}`]")
-    reply_text = f"**Owner: {fed_info['owner_mention']}\n\nList of fadmins:**\n" + "\n".join(user_mentions)
+    reply_text = (
+        f"**Owner: {fed_info['owner_mention']}\n\nList of fadmins:**\n"
+        + "\n".join(user_mentions)
+    )
 
     await message.reply_text(reply_text)
 
@@ -530,7 +561,9 @@ async def fpromote(client, message):
         user_id = await extract_user(msg)
 
         if user_id is None:
-            await message.reply_text("Failed to extract user from the message.")
+            await message.reply_text(
+                "Failed to extract user from the message."
+            )
             return
         check_user = await check_banned_user(fed_id, user_id)
         if check_user:
@@ -594,7 +627,9 @@ async def fdemote(client, message):
         user_id = await extract_user(msg)
 
         if user_id is None:
-            await message.reply_text("Failed to extract user from the message.")
+            await message.reply_text(
+                "Failed to extract user from the message."
+            )
             return
 
         if user_id == BOT_ID:
@@ -625,11 +660,15 @@ async def fban_user(client, message):
     chat = message.chat
     from_user = message.from_user
     if message.chat.type == ChatType.PRIVATE:
-        await message.reply_text("This command is specific to groups, not our pm!.")
+        await message.reply_text(
+            "This command is specific to groups, not our pm!."
+        )
         return
     fed_id = await get_fed_id(chat.id)
     if not fed_id:
-        return await message.reply_text("**This chat is not a part of any federation.")
+        return await message.reply_text(
+            "**This chat is not a part of any federation."
+        )
     info = await get_fed_info(fed_id)
     fed_owner = info["owner_id"]
     fed_admins = info["fadmins"]
@@ -722,11 +761,15 @@ async def funban_user(client, message):
     chat = message.chat
     from_user = message.from_user
     if message.chat.type == ChatType.PRIVATE:
-        await message.reply_text("This command is specific to groups, not our pm!.")
+        await message.reply_text(
+            "This command is specific to groups, not our pm!."
+        )
         return
     fed_id = await get_fed_id(chat.id)
     if not fed_id:
-        return await message.reply_text("**This chat is not a part of any federation.")
+        return await message.reply_text(
+            "**This chat is not a part of any federation."
+        )
     info = await get_fed_info(fed_id)
     fed_owner = info["owner_id"]
     fed_admins = info["fadmins"]
@@ -746,7 +789,9 @@ async def funban_user(client, message):
     if not user_id:
         return await message.reply_text("I can't find that user.")
     if user_id in all_admins or user_id in SUDOERS:
-        return await message.reply_text("**How can an admin ever be banned!.**")
+        return await message.reply_text(
+            "**How can an admin ever be banned!.**"
+        )
     check_user = await check_banned_user(fed_id, user_id)
     if not check_user:
         return await message.reply_text(
@@ -855,11 +900,15 @@ async def fbroadcast_message(client, message):
     from_user = message.from_user
     reply_message = message.reply_to_message
     if message.chat.type == ChatType.PRIVATE:
-        await message.reply_text("This command is specific to groups, not our pm!.")
+        await message.reply_text(
+            "This command is specific to groups, not our pm!."
+        )
         return
     fed_id = await get_fed_id(chat.id)
     if not fed_id:
-        return await message.reply_text("**This chat is not a part of any federation.")
+        return await message.reply_text(
+            "**This chat is not a part of any federation."
+        )
     info = await get_fed_info(fed_id)
     fed_owner = info["owner_id"]
     fed_admins = info["fadmins"]
@@ -879,11 +928,15 @@ async def fbroadcast_message(client, message):
     if reply_message.text:
         text = reply_message.text.markdown
     else:
-        return await message.reply_text("You can only Broadcast text messages.")
+        return await message.reply_text(
+            "You can only Broadcast text messages."
+        )
 
     reply_markup = None
     if reply_message.reply_markup:
-        reply_markup = InlineKeyboardMarkup(reply_message.reply_markup.inline_keyboard)
+        reply_markup = InlineKeyboardMarkup(
+            reply_message.reply_markup.inline_keyboard
+        )
     sent = 0
     chats, _ = await chat_id_and_names_in_fed(fed_id)
     m = await message.reply_text(

+ 10 - 3
wbb/modules/filters.py

@@ -45,7 +45,11 @@ from wbb.utils.dbfunctions import (
     save_filter,
 )
 from wbb.utils.filter_groups import chat_filters_group
-from wbb.utils.functions import check_format, extract_text_and_keyb, get_data_and_name
+from wbb.utils.functions import (
+    check_format,
+    extract_text_and_keyb,
+    get_data_and_name,
+)
 
 __MODULE__ = "Filters"
 __HELP__ = """/filters To Get All The Filters In The Chat.
@@ -79,8 +83,8 @@ async def save_filters(_, message):
         data, name = await get_data_and_name(replied_message, message)
         if data == "error":
             return await message.reply_text(
-                    "**Usage:**\n__/filter [FILTER_NAME] [CONTENT]__\n`-----------OR-----------`\nReply to a message with.\n/filter [FILTER_NAME]."
-                )
+                "**Usage:**\n__/filter [FILTER_NAME] [CONTENT]__\n`-----------OR-----------`\nReply to a message with.\n/filter [FILTER_NAME]."
+            )
         if replied_message.text:
             _type = "text"
             file_id = None
@@ -212,6 +216,9 @@ async def filters_re(_, message):
                     reply_markup=keyb,
                     disable_web_page_preview=True,
                 )
+            else:
+                if not file_id:
+                    continue
             if data_type == "sticker":
                 await message.reply_sticker(
                     sticker=file_id,

+ 6 - 4
wbb/modules/greetings.py

@@ -47,6 +47,7 @@ from wbb.core.decorators.errors import capture_err
 from wbb.core.decorators.permissions import adminsOnly
 from wbb.core.keyboard import ikb
 from wbb.modules.notes import extract_urls
+from wbb.utils.dbfeds import check_banned_user, get_fed_id
 from wbb.utils.dbfunctions import (
     captcha_off,
     captcha_on,
@@ -66,7 +67,6 @@ from wbb.utils.functions import (
     extract_text_and_keyb,
     generate_captcha,
 )
-from wbb.utils.dbfeds import get_fed_id, check_banned_user
 
 __MODULE__ = "Greetings"
 __HELP__ = """
@@ -122,7 +122,7 @@ async def handle_new_member(message: Message, member, chat):
     # Mute new member and send message with button
     try:
         if member.id in SUDOERS:
-            return# Ignore sudo users
+            return  # Ignore sudo users
         fed_id = await get_fed_id(chat.id)
         if fed_id:
             check_user = await check_banned_user(fed_id, member.id)
@@ -132,7 +132,7 @@ async def handle_new_member(message: Message, member, chat):
                 await message.chat.ban_member(member.id)
                 return await app.send_message(
                     chat.id,
-                    f"**User {member.mention} was Fed Banned.\n\nReason: {reason}.\nDate: {date}.**"
+                    f"**User {member.mention} was Fed Banned.\n\nReason: {reason}.\nDate: {date}.**",
                 )
         if await is_gbanned_user(member.id):
             await message.chat.ban_member(member.id)
@@ -146,7 +146,9 @@ async def handle_new_member(message: Message, member, chat):
         if member.is_bot:
             return  # Ignore bots
         if not await is_captcha_on(message.chat.id):
-            return await send_welcome_message(message.chat, message.from_user.id)
+            return await send_welcome_message(
+                message.chat, message.from_user.id
+            )
 
         # Ignore user if he has already solved captcha in this group
         # someday

+ 5 - 1
wbb/modules/notes.py

@@ -43,7 +43,11 @@ from wbb.utils.dbfunctions import (
     get_note_names,
     save_note,
 )
-from wbb.utils.functions import check_format, extract_text_and_keyb, get_data_and_name
+from wbb.utils.functions import (
+    check_format,
+    extract_text_and_keyb,
+    get_data_and_name,
+)
 
 __MODULE__ = "Notes"
 __HELP__ = """/notes To Get All The Notes In The Chat.

+ 25 - 13
wbb/modules/rules.py

@@ -24,14 +24,14 @@ SOFTWARE.
 
 from pyrogram import filters
 from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
-from wbb import app, BOT_USERNAME
-from wbb.core.keyboard import ikb
+
+from wbb import BOT_USERNAME, app
 from wbb.core.decorators.permissions import adminsOnly
-from wbb.utils.dbfunctions import set_chat_rules, get_rules, delete_rules
-from wbb.utils.functions import check_format
-from wbb.modules.notes import extract_urls
+from wbb.core.keyboard import ikb
 from wbb.modules.admin import member_permissions
-
+from wbb.modules.notes import extract_urls
+from wbb.utils.dbfunctions import delete_rules, get_rules, set_chat_rules
+from wbb.utils.functions import check_format
 
 __MODULE__ = "Rules"
 __HELP__ = """
@@ -55,7 +55,8 @@ async def send_rules(_, message):
             [
                 [
                     InlineKeyboardButton(
-                        "rules", url=f"t.me/{BOT_USERNAME}?start=rules_{chat_id}"
+                        "rules",
+                        url=f"t.me/{BOT_USERNAME}?start=rules_{chat_id}",
                     )
                 ]
             ]
@@ -70,7 +71,9 @@ async def set_rules(_, message):
         chat_id = message.chat.id
         replied_message = message.reply_to_message
         if len(message.command) < 2 and not replied_message:
-            return await message.reply("**Reply to a message to set new rules.**")
+            return await message.reply(
+                "**Reply to a message to set new rules.**"
+            )
         if len(message.command) < 2 and replied_message.text:
             rules = replied_message.text.markdown
             if replied_message.reply_markup:
@@ -89,9 +92,13 @@ async def set_rules(_, message):
                 "**Wrong formatting, check the help section.**"
             )
         await set_chat_rules(chat_id, rules)
-        return await message.reply_text("**Successfully set new rules for this chat.**")
+        return await message.reply_text(
+            "**Successfully set new rules for this chat.**"
+        )
     except Exception:
-        await message.reply_text("**You can only set text messages as rules.**")
+        await message.reply_text(
+            "**You can only set text messages as rules.**"
+        )
 
 
 @app.on_message(filters.command("clearrules") & ~filters.private)
@@ -104,13 +111,16 @@ async def delete_rules_cmd(_, message):
         keyboard = InlineKeyboardMarkup(
             [
                 [
-                    InlineKeyboardButton("YES, DO IT", callback_data="drules_yes"),
+                    InlineKeyboardButton(
+                        "YES, DO IT", callback_data="drules_yes"
+                    ),
                     InlineKeyboardButton("Cancel", callback_data="drules_no"),
                 ]
             ]
         )
         await message.reply_text(
-            "**Are you sure to delete the current rules ?.**", reply_markup=keyboard
+            "**Are you sure to delete the current rules ?.**",
+            reply_markup=keyboard,
         )
 
 
@@ -129,7 +139,9 @@ async def delete_rules_cb(_, cb):
     if input == "yes":
         deleted = await delete_rules(chat_id)
         if deleted:
-            return await cb.message.edit("**Successfully deleted rules of this chat.**")
+            return await cb.message.edit(
+                "**Successfully deleted rules of this chat.**"
+            )
     if input == "no":
         await cb.message.reply_to_message.delete()
         await cb.message.delete()

+ 4 - 2
wbb/modules/sudoers.py

@@ -28,9 +28,9 @@ import time
 
 import psutil
 from pyrogram import filters, types
+from pyrogram.enums import ChatMemberStatus
 from pyrogram.errors import FloodWait
 from pyrogram.types import InlineKeyboardMarkup
-from pyrogram.enums import ChatMemberStatus
 
 from wbb import (
     BOT_ID,
@@ -121,7 +121,9 @@ async def ban_globally(_, message):
     number_of_chats = 0
     for served_chat in served_chats:
         try:
-            chat_member = await app.get_chat_member(served_chat["chat_id"], user.id)
+            chat_member = await app.get_chat_member(
+                served_chat["chat_id"], user.id
+            )
             if chat_member.status == ChatMemberStatus.MEMBER:
                 await app.ban_chat_member(served_chat["chat_id"], user.id)
                 number_of_chats += 1

+ 16 - 6
wbb/utils/dbfeds.py

@@ -1,7 +1,8 @@
-import pytz
 from datetime import datetime
-from wbb import SUDOERS, db
 
+import pytz
+
+from wbb import SUDOERS, db
 
 fedsdb = db.feds
 
@@ -86,7 +87,11 @@ async def search_fed_by_id(fed_id):
 def chat_join_fed(fed_id, chat_name, chat_id):
     return fedsdb.update_one(
         {"fed_id": fed_id},
-        {"$push": {"chat_ids": {"chat_id": int(chat_id), "chat_name": chat_name}}},
+        {
+            "$push": {
+                "chat_ids": {"chat_id": int(chat_id), "chat_name": chat_name}
+            }
+        },
     )
 
 
@@ -103,7 +108,9 @@ async def chat_leave_fed(chat_id):
 
 async def user_join_fed(fed_id, user_id):
     result = await fedsdb.update_one(
-        {"fed_id": fed_id}, {"$addToSet": {"fadmins": int(user_id)}}, upsert=True
+        {"fed_id": fed_id},
+        {"$addToSet": {"fadmins": int(user_id)}},
+        upsert=True,
     )
     if result.modified_count > 0:
         return True
@@ -164,12 +171,15 @@ async def add_fban_user(fed_id, user_id, reason):
 
 async def remove_fban_user(fed_id, user_id):
     await fedsdb.update_one(
-        {"fed_id": fed_id}, {"$pull": {"banned_users": {"user_id": int(user_id)}}}
+        {"fed_id": fed_id},
+        {"$pull": {"banned_users": {"user_id": int(user_id)}}},
     )
 
 
 async def check_banned_user(fed_id, user_id):
-    result = await fedsdb.find_one({"fed_id": fed_id, "banned_users.user_id": user_id})
+    result = await fedsdb.find_one(
+        {"fed_id": fed_id, "banned_users.user_id": user_id}
+    )
     if result and "banned_users" in result:
         for user in result["banned_users"]:
             if user.get("user_id") == user_id:

+ 2 - 2
wbb/utils/dbfunctions.py

@@ -205,8 +205,8 @@ async def get_rules(chat_id: int):
 
 async def set_chat_rules(chat_id: int, rules: str):
     await rulesdb.update_one(
-        {"chat_id": chat_id}, 
-        {"$set": {"rules": rules}}, 
+        {"chat_id": chat_id},
+        {"$set": {"rules": rules}},
         upsert=True,
     )
 

+ 3 - 5
wbb/utils/functions.py

@@ -35,9 +35,9 @@ from sys import executable
 import aiofiles
 import speedtest
 from PIL import Image, ImageDraw, ImageFilter, ImageFont
+from pyrogram import errors
 from pyrogram.enums import MessageEntityType
 from pyrogram.types import Message
-from pyrogram import errors
 
 from wbb import aiohttpsession as aiosession
 from wbb.utils.dbfunctions import start_restart_stage
@@ -340,9 +340,7 @@ async def check_format(ikb, raw_text: str):
 
 
 async def get_data_and_name(replied_message, message):
-    text = (
-        message.text.markdown if message.text else message.caption.markdown
-    )
+    text = message.text.markdown if message.text else message.caption.markdown
     name = text.split(None, 1)[1].strip()
     text = name.split(" ", 1)
     if len(text) > 1:
@@ -373,7 +371,7 @@ async def get_data_and_name(replied_message, message):
             match = f"/{command} " + name
             if not message.reply_to_message and message.text:
                 if match == data:
-                    data ="error"
+                    data = "error"
             elif not message.reply_to_message and not message.text:
                 if match == data:
                     data = None