Browse Source

Restart notice

thehamkercat 5 years ago
parent
commit
a2248596a4

+ 1 - 0
wbb/__init__.py

@@ -29,6 +29,7 @@ from os import path
 from aiohttp import ClientSession
 from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
 from pyrogram import Client
+from pyromod import listen
 from Python_ARQ import ARQ
 from telegraph import Telegraph
 

+ 8 - 1
wbb/__main__.py

@@ -33,6 +33,7 @@ from wbb import BOT_NAME, BOT_USERNAME, USERBOT_NAME, aiohttpsession, app
 from wbb.modules import ALL_MODULES
 from wbb.modules.sudoers import bot_sys_stats
 from wbb.utils import paginate_modules
+from wbb.utils.dbfunctions import clean_restart_stage
 
 loop = asyncio.get_event_loop()
 
@@ -40,7 +41,13 @@ HELPABLE = {}
 
 
 async def start_bot():
-    global COMMANDS_COUNT
+    restart_data = await clean_restart_stage()
+    if restart_data:
+        await app.edit_message_text(
+                restart_data['chat_id'],
+                restart_data['message_id'],
+                "**Restarted Successfully**"
+                )
     for module in ALL_MODULES:
         imported_module = importlib.import_module("wbb.modules." + module)
         if (

+ 23 - 42
wbb/modules/admin.py

@@ -136,9 +136,10 @@ async def purgeFunc(client, message: Message):
     if message.chat.type not in ("supergroup", "channel"):
         return
     if not message.reply_to_message:
-        await message.reply_text(
-            "Reply To A Message To Delete From," " Don't Make Fun Of Yourself!"
+        return await message.reply_text(
+            "Reply To A Message To Delete From, Don't Make Fun Of Yourself!"
         )
+    await message.delete()
     for a_s_message_id in range(
         message.reply_to_message.message_id, message.message_id
     ):
@@ -167,10 +168,9 @@ async def kickFunc(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user_id = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Provide a username or reply to a user's message to kick."
         )
-        return
     if user_id in SUDOERS:
         await message.reply_text("You Wanna Kick The Elevated One?")
     else:
@@ -191,10 +191,9 @@ async def banFunc(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user_id = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Provide a username or reply to a user's message to ban."
         )
-        return
     if user_id in SUDOERS:
         await message.reply_text("You Wanna Ban The Elevated One?")
     else:
@@ -213,10 +212,9 @@ async def unbanFunc(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Provide a username or reply to a user's message to unban."
         )
-        return
     await message.chat.unban_member(user)
     await message.reply_text("Unbanned!")
 
@@ -228,8 +226,7 @@ async def unbanFunc(_, message: Message):
 @adminsOnly("can_delete_messages")
 async def deleteFunc(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text("Reply To A Message To Delete It")
-        return
+        return await message.reply_text("Reply To A Message To Delete It")
     await message.reply_to_message.delete()
     await message.delete()
 
@@ -248,10 +245,9 @@ async def promoteFunc(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user_id = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply To A User's Message Or Give A Username To Promote."
         )
-        return
     await message.chat.promote_member(
         user_id=user_id,
         can_change_info=bot.can_change_info,
@@ -278,10 +274,9 @@ async def demote(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user_id = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply To A User's Message Or Give A Username To Demote."
         )
-        return
     await message.chat.promote_member(
         user_id=user_id,
         can_change_info=False,
@@ -303,10 +298,8 @@ async def demote(_, message: Message):
 @adminsOnly("can_pin_messages")
 async def pin(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text("Reply To A Message To Pin.")
-        return
-    await message.reply_to_message.pin(disable_notification=True)
-
+        return await message.reply_text("Reply To A Message To Pin.")
+     await message.reply_to_message.pin(disable_notification=True)
 
 # Mute members
 
@@ -319,13 +312,11 @@ async def mute(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user_id = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Provide a username or reply to a user's message to mute."
         )
-        return
     if user_id in SUDOERS:
-        await message.reply_text("You Wanna Mute The Elevated One?")
-        return
+        return await message.reply_text("You Wanna Mute The Elevated One?")
     await message.chat.restrict_member(user_id, permissions=ChatPermissions())
     await message.reply_text("Muted!")
 
@@ -341,10 +332,9 @@ async def unmute(_, message: Message):
     elif len(message.command) == 1 and message.reply_to_message:
         user = message.reply_to_message.from_user.id
     else:
-        await message.reply_text(
+        return await message.reply_text(
             "Provide a username or reply to a user's message to Unmute"
         )
-        return
     await message.chat.unban_member(user)
     await message.reply_text("Unmuted!")
 
@@ -377,8 +367,7 @@ async def ban_deleted_accounts(_, message: Message):
 @adminsOnly("can_restrict_members")
 async def warn_user(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a message to warn a user.")
-        return
+        return await message.reply_text("Reply to a message to warn a user.")
     chat_id = message.chat.id
     user_id = message.reply_to_message.from_user.id
     mention = message.reply_to_message.from_user.mention
@@ -396,10 +385,9 @@ async def warn_user(_, message: Message):
             else:
                 warn = {"warns": 1}
                 await add_warn(chat_id, await int_to_alpha(user_id), warn)
-                await message.reply_text(
+                return await message.reply_text(
                     f"Warned {mention} !, 1/3 warnings now."
                 )
-                return
             if warns >= 2:
                 await message.chat.kick_member(user_id)
                 await message.reply_text(
@@ -423,10 +411,9 @@ async def warn_user(_, message: Message):
 @adminsOnly("can_restrict_members")
 async def remove_warning(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply to a message to remove a user's warning."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     mention = message.reply_to_message.from_user.mention
     chat_id = message.chat.id
@@ -448,10 +435,9 @@ async def remove_warning(_, message: Message):
 @adminsOnly("can_restrict_members")
 async def remove_warnings(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply to a message to remove a user's warnings."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     mention = message.reply_to_message.from_user.mention
     chat_id = message.chat.id
@@ -472,10 +458,9 @@ async def remove_warnings(_, message: Message):
 @capture_err
 async def check_warns(_, message: Message):
     if not message.reply_to_message:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply to a message to check a user's warnings."
         )
-        return
     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
@@ -485,16 +470,13 @@ async def check_warns(_, message: Message):
         if warns:
             warns = warns["warns"]
         else:
-            await message.reply_text(f"{mention_user} have no warnings.")
-            return
-        await message.reply_text(f"{mention_user} have {warns}/3 warnings.")
-        return
+            return await message.reply_text(f"{mention_user} have no warnings.")
+        return await message.reply_text(f"{mention_user} have {warns}/3 warnings.")
     warns = await get_warn(chat_id, await int_to_alpha(user_id))
     if warns:
         warns = warns["warns"]
     else:
-        await message.reply_text(f"{mention_user} have no warnings.")
-        return
+        return await message.reply_text(f"{mention_user} have no warnings.")
     await message.reply_text(f"{mention_from_user} have {warns}/3 warnings.")
 
 
@@ -508,8 +490,7 @@ async def check_warns(_, message: Message):
 @capture_err
 async def report_user(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a message to report user.")
-        return
+        return await message.reply_text("Reply to a message to report user.")
     list_of_admins = await list_admins(message.chat.id)
     user_mention = message.reply_to_message.from_user.mention
     text = f"Reported {user_mention} to admins."

+ 4 - 8
wbb/modules/admin_misc.py

@@ -40,8 +40,7 @@ __HELP__ = """
 @adminsOnly("can_change_info")
 async def set_chat_title(_, message):
     if len(message.command) < 2:
-        await message.reply_text("**Usage:**\n/set_chat_title NEW NAME")
-        return
+        return await message.reply_text("**Usage:**\n/set_chat_title NEW NAME")
     old_title = message.chat.title
     new_title = message.text.split(None, 1)[1]
     await message.chat.set_title(new_title)
@@ -56,10 +55,9 @@ async def set_user_title(_, message):
     chat_id = message.chat.id
     from_user = message.reply_to_message.from_user
     if len(message.command) < 2:
-        await message.reply_text(
+        return await message.reply_text(
             "**Usage:**\n/set_user_title NEW ADMINISTRATOR TITLE"
         )
-        return
     title = message.text.split(None, 1)[1]
     await app.set_administrator_title(chat_id, from_user.id, title)
     await message.reply_text(
@@ -71,14 +69,12 @@ async def set_user_title(_, message):
 @adminsOnly("can_change_info")
 async def set_chat_photo(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a photo to set it as chat_photo")
-        return
+        return await message.reply_text("Reply to a photo to set it as chat_photo")
     if (
         not message.reply_to_message.photo
         and not message.reply_to_message.document
     ):
-        await message.reply_text("Reply to a photo to set it as chat_photo")
-        return
+        return await message.reply_text("Reply to a photo to set it as chat_photo")
     photo = await message.reply_to_message.download()
     await message.chat.set_photo(photo)
     await message.reply_text("Successfully Changed Group Photo")

+ 2 - 4
wbb/modules/antiservice.py

@@ -20,8 +20,7 @@ Plugin to delete service messages in a chat!
 @adminsOnly("can_change_info")
 async def anti_service(_, message):
     if len(message.command) != 2:
-        await message.reply_text("Usage: /antiservice [enable | disable]")
-        return
+        return await message.reply_text("Usage: /antiservice [enable | disable]")
     status = message.text.split(None, 1)[1].strip()
     status = status.lower()
     chat_id = message.chat.id
@@ -46,7 +45,6 @@ async def delete_service(_, message):
     chat_id = message.chat.id
     try:
         if await is_antiservice_on(chat_id):
-            await message.delete()
-            return
+            return await message.delete()
     except Exception:
         pass

+ 1 - 2
wbb/modules/arq.py

@@ -30,8 +30,7 @@ from wbb import ARQ_API_URL, app, arq
 async def arq_stats(_, message):
     data = await arq.stats()
     if not data.ok:
-        await message.reply_text(data.result)
-        return
+        return await message.reply_text(data.result)
     data = data.result
     uptime = data.uptime
     requests = data.requests

+ 5 - 10
wbb/modules/blacklist.py

@@ -49,12 +49,10 @@ __HELP__ = """
 @adminsOnly("can_restrict_members")
 async def save_filters(_, message):
     if len(message.command) < 2:
-        await message.reply_text("Usage:\n/blacklist [WORD|SENTENCE]")
-        return
+        return await message.reply_text("Usage:\n/blacklist [WORD|SENTENCE]")
     word = message.text.split(None, 1)[1].strip()
     if not word:
-        await message.reply_text("**Usage**\n__/blacklist [WORD|SENTENCE]__")
-        return
+        return await message.reply_text("**Usage**\n__/blacklist [WORD|SENTENCE]__")
     chat_id = message.chat.id
     await save_blacklist_filter(chat_id, word)
     await message.reply_text(f"__**Blacklisted {word}.**__")
@@ -81,17 +79,14 @@ async def get_filterss(_, message):
 @adminsOnly("can_restrict_members")
 async def del_filter(_, message):
     if len(message.command) < 2:
-        await message.reply_text("Usage:\n/whitelist [WORD|SENTENCE]")
-        return
+        return await message.reply_text("Usage:\n/whitelist [WORD|SENTENCE]")
     word = message.text.split(None, 1)[1].strip()
     if not word:
-        await message.reply_text("Usage:\n/whitelist [WORD|SENTENCE]")
-        return
+        return await message.reply_text("Usage:\n/whitelist [WORD|SENTENCE]")
     chat_id = message.chat.id
     deleted = await delete_blacklist_filter(chat_id, word)
     if deleted:
-        await message.reply_text(f"**Whitelisted {word}.**")
-        return
+        return await message.reply_text(f"**Whitelisted {word}.**")
     await message.reply_text("**No such blacklist filter.**")
 
 

+ 6 - 12
wbb/modules/blacklist_chat.py

@@ -23,16 +23,13 @@ in which you don't want it to be in.
 @capture_err
 async def blacklist_chat_func(_, message: Message):
     if len(message.command) != 2:
-        await message.reply_text("**Usage:**\n/blacklist_chat [CHAT_ID]")
-        return
+        return await message.reply_text("**Usage:**\n/blacklist_chat [CHAT_ID]")
     chat_id = int(message.text.strip().split()[1])
     if chat_id in await blacklisted_chats():
-        await message.reply_text("Chat is already blacklisted.")
-        return
+        return await message.reply_text("Chat is already blacklisted.")
     blacklisted = await blacklist_chat(chat_id)
     if blacklisted:
-        await message.reply_text("Chat has been successfully blacklisted")
-        return
+        return await message.reply_text("Chat has been successfully blacklisted")
     await message.reply_text("Something wrong happened, check logs.")
 
 
@@ -40,16 +37,13 @@ async def blacklist_chat_func(_, message: Message):
 @capture_err
 async def whitelist_chat_func(_, message: Message):
     if len(message.command) != 2:
-        await message.reply_text("**Usage:**\n/whitelist_chat [CHAT_ID]")
-        return
+        return await message.reply_text("**Usage:**\n/whitelist_chat [CHAT_ID]")
     chat_id = int(message.text.strip().split()[1])
     if chat_id not in await blacklisted_chats():
-        await message.reply_text("Chat is already whitelisted.")
-        return
+        return await message.reply_text("Chat is already whitelisted.")
     whitelisted = await whitelist_chat(chat_id)
     if whitelisted:
-        await message.reply_text("Chat has been successfully whitelisted")
-        return
+        return await message.reply_text("Chat has been successfully whitelisted")
     await message.reply_text("Something wrong happened, check logs.")
 
 

+ 2 - 4
wbb/modules/carbon.py

@@ -14,11 +14,9 @@ __HELP__ = "/carbon - Make Carbon Of Code."
 @capture_err
 async def carbon_func(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a text message to make carbon.")
-        return
+        return await message.reply_text("Reply to a text message to make carbon.")
     if not message.reply_to_message.text:
-        await message.reply_text("Reply to a text message to make carbon.")
-        return
+        return await message.reply_text("Reply to a text message to make carbon.")
     m = await message.reply_text("Preparing Carbon")
     carbon = await make_carbon(message.reply_to_message.text)
     await m.edit("Uploading")

+ 5 - 14
wbb/modules/chatbot.py

@@ -46,8 +46,7 @@ active_chats_ubot = []
 async def chatbot_status(_, message):
     global active_chats_bot
     if len(message.command) != 2:
-        await message.reply_text("**Usage**\n/chatbot [ON|OFF]")
-        return
+        return await message.reply_text("**Usage**\n/chatbot [ON|OFF]")
     status = message.text.split(None, 1)[1]
     chat_id = message.chat.id
 
@@ -58,18 +57,14 @@ async def chatbot_status(_, message):
                 "Chatbot Enabled Reply To Any Message "
                 + "Of Mine To Get A Reply"
             )
-            await message.reply_text(text)
-            return
+            return await message.reply_text(text)
         await message.reply_text("ChatBot Is Already Enabled.")
-        return
 
     elif status == "OFF" or status == "off" or status == "Off":
         if chat_id in active_chats_bot:
             active_chats_bot.remove(chat_id)
-            await message.reply_text("Chatbot Disabled!")
-            return
+            return await message.reply_text("Chatbot Disabled!")
         await message.reply_text("ChatBot Is Already Disabled.")
-        return
 
     else:
         await message.reply_text("**Usage**\n/chatbot [ON|OFF]")
@@ -117,8 +112,7 @@ async def chatbot_talk(_, message):
 async def chatbot_status_ubot(_, message):
     global active_chats_ubot
     if len(message.text.split()) != 2:
-        await edit_or_reply(message, text="**Usage**\n.chatbot [ON|OFF]")
-        return
+        return await edit_or_reply(message, text="**Usage**\n.chatbot [ON|OFF]")
     status = message.text.split(None, 1)[1]
     chat_id = message.chat.id
     if status == "ON" or status == "on" or status == "On":
@@ -128,10 +122,8 @@ async def chatbot_status_ubot(_, message):
                 "Chatbot Enabled Reply To Any Message "
                 + "Of Mine To Get A Reply"
             )
-            await edit_or_reply(message, text=text)
-            return
+            return await edit_or_reply(message, text=text)
         await edit_or_reply(message, text="ChatBot Is Already Enabled.")
-        return
 
     elif status == "OFF" or status == "off" or status == "Off":
         if chat_id in active_chats_ubot:
@@ -139,7 +131,6 @@ async def chatbot_status_ubot(_, message):
             await edit_or_reply(message, text="Chatbot Disabled!")
             return
         await edit_or_reply(message, text="ChatBot Is Already Disabled.")
-        return
 
     else:
         await edit_or_reply(message, text="**Usage**\n/chatbot [ON|OFF]")

+ 2 - 4
wbb/modules/couple.py

@@ -61,8 +61,7 @@ tomorrow = str(dt_tom())
 @capture_err
 async def couple(_, message):
     if message.chat.type == "private":
-        await message.reply_text("This command only works in groups.")
-        return
+        return await message.reply_text("This command only works in groups.")
     try:
         chat_id = message.chat.id
         is_selected = await get_couple(chat_id, today)
@@ -72,8 +71,7 @@ async def couple(_, message):
                 if not i.user.is_bot:
                     list_of_users.append(i.user.id)
             if len(list_of_users) < 2:
-                await message.reply_text("Not enough users")
-                return
+                return await message.reply_text("Not enough users")
             c1_id = random.choice(list_of_users)
             c2_id = random.choice(list_of_users)
             while c1_id == c2_id:

+ 1 - 3
wbb/modules/covid.py

@@ -39,12 +39,10 @@ async def covid(_, message):
     if len(message.command) == 1:
         data = await fetch("https://corona.lmao.ninja/v2/all")
         data = await json_prettify(data)
-        await app.send_message(message.chat.id, text=data)
-        return
+        return await app.send_message(message.chat.id, text=data)
     if len(message.command) != 1:
         country = message.text.split(None, 1)[1].strip()
         country = country.replace(" ", "")
         data = await fetch(f"https://corona.lmao.ninja/v2/countries/{country}")
         data = await json_prettify(data)
         await app.send_message(message.chat.id, text=data)
-        return

+ 4 - 8
wbb/modules/devs.py

@@ -47,8 +47,7 @@ async def executor(client, message):
     try:
         cmd = message.text.split(" ", maxsplit=1)[1]
     except IndexError:
-        await message.delete()
-        return
+        return await message.delete()
     t1 = time()
     old_stderr = sys.stderr
     old_stdout = sys.stdout
@@ -124,8 +123,7 @@ async def runtime_func_cq(_, cq):
 )
 async def shellrunner(client, message):
     if len(message.command) < 2:
-        await edit_or_reply(message, text="**Usage:**\n/sh git pull")
-        return
+        return await edit_or_reply(message, text="**Usage:**\n/sh git pull")
     text = message.text.split(None, 1)[1]
     if "\n" in text:
         code = text.split("\n")
@@ -162,10 +160,9 @@ async def shellrunner(client, message):
                 value=exc_obj,
                 tb=exc_tb,
             )
-            await edit_or_reply(
+            return await edit_or_reply(
                 message, text=f"**ERROR:**\n```{''.join(errors)}```"
             )
-            return
         output = process.stdout.read()[:-1].decode("utf-8")
     if str(output) == "\n":
         output = None
@@ -179,8 +176,7 @@ async def shellrunner(client, message):
                 reply_to_message_id=message.message_id,
                 caption="`Output`",
             )
-            os.remove("output.txt")
-            return
+            return os.remove("output.txt")
         await edit_or_reply(message, text=f"**OUTPUT:**\n```{output}```")
     else:
         await edit_or_reply(message, text="**OUTPUT: **\n`No output`")

+ 8 - 16
wbb/modules/filters.py

@@ -47,22 +47,19 @@ You can use markdown or html to save text too."""
 @adminsOnly("can_change_info")
 async def save_filters(_, message):
     if len(message.command) < 2 or not message.reply_to_message:
-        await message.reply_text(
+        return await message.reply_text(
             "**Usage:**\nReply to a text or sticker with /filter [FILTER_NAME] to save it."
         )
-        return
     if (
         not message.reply_to_message.text
         and not message.reply_to_message.sticker
     ):
-        await message.reply_text(
+        return await message.reply_text(
             "__**You can only save text or stickers in filters.**__"
         )
-        return
     name = message.text.split(None, 1)[1].strip()
     if not name:
-        await message.reply_text("**Usage**\n__/filter [FILTER_NAME]__")
-        return
+        return await message.reply_text("**Usage**\n__/filter [FILTER_NAME]__")
     chat_id = message.chat.id
     _type = "text" if message.reply_to_message.text else "sticker"
     _filter = {
@@ -94,12 +91,10 @@ async def get_filterss(_, message):
 @adminsOnly("can_change_info")
 async def del_filter(_, message):
     if len(message.command) < 2:
-        await message.reply_text("**Usage**\n__/stop [FILTER_NAME]__")
-        return
+        return await message.reply_text("**Usage**\n__/stop [FILTER_NAME]__")
     name = message.text.split(None, 1)[1].strip()
     if not name:
-        await message.reply_text("**Usage**\n__/stop [FILTER_NAME]__")
-        return
+        return await message.reply_text("**Usage**\n__/stop [FILTER_NAME]__")
     chat_id = message.chat.id
     deleted = await delete_filter(chat_id, name)
     if deleted:
@@ -135,22 +130,19 @@ async def filters_re(_, message):
                         data, disable_web_page_preview=True
                     )
                     if text[0] == "~":
-                        await message.delete()
-                    return
+                        return await message.delete()
                 await message.reply_text(data, disable_web_page_preview=True)
             else:
                 if message.reply_to_message:
                     await message.reply_to_message.reply_sticker(data)
                     if text[0] == "~":
-                        await message.delete()
-                    return
+                        return await message.delete()
                 await message.reply_sticker(data)
 
     """ CHAT WATCHER """
     blacklisted_chats_list = await blacklisted_chats()
     if chat_id in blacklisted_chats_list:
-        await app.leave_chat(chat_id)
-        return
+        return await app.leave_chat(chat_id)
     served_chat = await is_served_chat(chat_id)
     if served_chat:
         return

+ 7 - 15
wbb/modules/genstr.py

@@ -55,8 +55,7 @@ async def genstr(_, message):
         code = await temp_client.send_code(phone)
         await asyncio.sleep(2)
     except PhoneNumberInvalid:
-        await message.reply_text("Phone Number is Invalid")
-        return
+        return await message.reply_text("Phone Number is Invalid")
 
     try:
         otp = await app.ask(
@@ -69,21 +68,18 @@ async def genstr(_, message):
         )
 
     except TimeoutError:
-        await message.reply_text(
+        return await message.reply_text(
             "Time limit reached of 5 min. Process Cancelled."
         )
-        return
     otp_code = otp.text
     try:
         await temp_client.sign_in(
             phone, code.phone_code_hash, phone_code=" ".join(str(otp_code))
         )
     except PhoneCodeInvalid:
-        await message.reply_text("Invalid OTP.")
-        return
+        return await message.reply_text("Invalid OTP.")
     except PhoneCodeExpired:
-        await message.reply_text("OTP is Expired.")
-        return
+        return await message.reply_text("OTP is Expired.")
     except SessionPasswordNeeded:
         try:
             two_step_code = await app.ask(
@@ -92,17 +88,14 @@ async def genstr(_, message):
                 timeout=300,
             )
         except TimeoutError:
-            await message.reply_text("Time limit reached of 5 min.")
-            return
+            return await message.reply_text("Time limit reached of 5 min.")
         new_code = two_step_code.text
         try:
             await temp_client.check_password(new_code)
         except Exception as e:
-            await message.reply_text(f"**ERROR:** `{str(e)}`")
-            return
+            return await message.reply_text(f"**ERROR:** `{str(e)}`")
     except Exception as e:
-        await app.send_message(chat.id, f"**ERROR:** `{str(e)}`")
-        return
+        return await app.send_message(chat.id, f"**ERROR:** `{str(e)}`")
     try:
         session_string = await temp_client.export_session_string()
         await temp_client.disconnect()
@@ -112,4 +105,3 @@ async def genstr(_, message):
         )
     except Exception as e:
         await app.send_message(chat.id, f"**ERROR:** `{str(e)}`")
-        return

+ 1 - 1
wbb/modules/greetings.py

@@ -82,7 +82,7 @@ loop = asyncio.get_running_loop()
 async def get_initial_captcha_cache():
     global answers_dicc
     answers_dicc = await get_captcha_cache()
-    return
+    return answers_dicc
 
 
 loop.create_task(get_initial_captcha_cache())

+ 3 - 6
wbb/modules/info.py

@@ -83,8 +83,7 @@ async def info_func(_, message: Message):
         m = await message.reply_text("Processing")
         info_caption, photo_id = await get_user_info(user)
         if not photo_id:
-            await m.edit(info_caption, disable_web_page_preview=True)
-            return
+            return await m.edit(info_caption, disable_web_page_preview=True)
         photo = await app.download_media(photo_id)
         await message.reply_photo(photo, caption=info_caption, quote=False)
         await m.delete()
@@ -99,8 +98,7 @@ async def info_func(_, message: Message):
 async def chat_info_func(_, message: Message):
     try:
         if len(message.command) > 2:
-            await message.reply_text("**Usage:**/chat_info [USERNAME|ID]")
-            return
+            return await message.reply_text("**Usage:**/chat_info [USERNAME|ID]")
         elif len(message.command) == 1:
             chat = message.chat.id
         elif len(message.command) == 2:
@@ -108,8 +106,7 @@ async def chat_info_func(_, message: Message):
         m = await message.reply_text("Processing")
         info_caption, photo_id = await get_chat_info(chat)
         if not photo_id:
-            await m.edit(info_caption, disable_web_page_preview=True)
-            return
+            return await m.edit(info_caption, disable_web_page_preview=True)
         photo = await app.download_media(photo_id)
         await message.reply_photo(photo, caption=info_caption, quote=False)
         await m.delete()

+ 25 - 55
wbb/modules/inline.py

@@ -50,13 +50,12 @@ async def inline_query_handler(client, query):
             )
         elif text.split()[0] == "tr":
             if len(text.split()) < 3:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Translator | tr [LANG] [TEXT]",
                     switch_pm_parameter="inline",
                 )
-                return
             lang = text.split()[1]
             tex = text.split(None, 2)[2].strip()
             answerss = await translate_func(answers, lang, tex)
@@ -66,13 +65,12 @@ async def inline_query_handler(client, query):
             )
         elif text.split()[0] == "ud":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Urban Dictionary | ud [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await urban_func(answers, tex)
             await client.answer_inline_query(
@@ -81,13 +79,12 @@ async def inline_query_handler(client, query):
             )
         elif text.split()[0] == "google":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Google Search | google [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await google_search_func(answers, tex)
             await client.answer_inline_query(
@@ -96,13 +93,12 @@ async def inline_query_handler(client, query):
             )
         elif text.split()[0] == "bitly":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Link Shortener | bitly [LINK]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await shortify(tex)
             await client.answer_inline_query(
@@ -111,53 +107,49 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "wall":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     is_gallery=True,
                     switch_pm_text="Wallpapers Search | wall [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await wall_func(answers, tex)
             await client.answer_inline_query(query.id, results=answerss)
 
         elif text.split()[0] == "saavn":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="JioSaavn Search | saavn [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await saavn_func(answers, tex)
             await client.answer_inline_query(query.id, results=answerss)
 
         elif text.split()[0] == "deezer":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Deezer Search | deezer [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await deezer_func(answers, tex)
             await client.answer_inline_query(query.id, results=answerss)
 
         elif text.split()[0] == "torrent":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Torrent Search | torrent [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await torrent_func(answers, tex)
             await client.answer_inline_query(
@@ -167,39 +159,36 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "yt":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="YouTube Search | yt [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await youtube_func(answers, tex)
             await client.answer_inline_query(query.id, results=answerss)
 
         elif text.split()[0] == "lyrics":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Lyrics Search | lyrics [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await lyrics_func(answers, tex)
             await client.answer_inline_query(query.id, results=answerss)
 
         elif text.split()[0] == "gh_user":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Github User | gh_user [USERNAME/LINK]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await github_user_func(answers, tex)
             await client.answer_inline_query(
@@ -208,13 +197,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "gh_repo":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Github Repo Search | [LINK]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await github_repo_func(answers, tex)
             await client.answer_inline_query(
@@ -223,13 +211,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "search":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Global Message Search. | search [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             user_id = query.from_user.id
             tex = text.split(None, 1)[1].strip()
             answerss = await tg_search_func(answers, tex, user_id)
@@ -239,13 +226,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "music":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Music Search | music [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await music_inline_func(answers, tex)
             await client.answer_inline_query(
@@ -254,13 +240,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "wiki":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Wikipedia | wiki [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await wiki_func(answers, tex)
             await client.answer_inline_query(
@@ -269,42 +254,37 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "speedtest":
             answerss = await speedtest_init(query)
-            await client.answer_inline_query(
+            return await client.answer_inline_query(
                 query.id, results=answerss, cache_time=2
             )
-            return
 
         elif text.split()[0] == "paste":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Pastebin | paste [TG_MESSAGE_LINK]",
                     switch_pm_parameter="inline",
                 )
-                return
             link = text.strip().split()[1]
             answerss = await pastebin_func(answers, link)
             await client.answer_inline_query(
                 query.id, results=answerss, cache_time=2
             )
-            return
 
         elif text.split()[0] == "carbon":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Carbon | carbon [TG_MESSAGE_LINK]",
                     switch_pm_parameter="inline",
                 )
-                return
             link = text.split()[1]
             answerss = await carbon_inline_func(answers, link)
             await client.answer_inline_query(
                 query.id, results=answerss, cache_time=2
             )
-            return
 
         elif text.split()[0] == "pmpermit":
             user_id = query.from_user.id
@@ -313,24 +293,21 @@ async def inline_query_handler(client, query):
             await client.answer_inline_query(
                 query.id, results=answerss, cache_time=2
             )
-            return
 
         elif text.split()[0] == "ping":
             answerss = await ping_func(answers)
             await client.answer_inline_query(
                 query.id, results=answerss, cache_time=2
             )
-            return
 
         elif text.split()[0] == "nsfw_scan":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="NSFW Scan | nsfw_scan [url]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split(None, 1)[1].strip()
             answerss = await nsfw_scan_func(answers, tex)
             await client.answer_inline_query(
@@ -339,13 +316,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "ytmusic":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="YT Music | ytmusic [url]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = query.query.split(None, 1)[1].strip()
             answerss = await yt_music_func(answers, tex)
             await client.answer_inline_query(
@@ -354,13 +330,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "info":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="User Info | info [USERNAME|ID]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split()[1].strip()
             answerss = await user_info_inline_func(answers, tex)
             await client.answer_inline_query(
@@ -369,13 +344,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "chat_info":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Chat Info | chat_info [USERNAME|ID]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split()[1].strip()
             answerss = await chat_info_inline_func(answers, tex)
             await client.answer_inline_query(
@@ -385,13 +359,12 @@ async def inline_query_handler(client, query):
         elif text.split()[0] == "tmdb":
             if len(text.split()) < 2:
                 answerss = await tmdb_func(answers, "")
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answerss,
                     switch_pm_text="TMDB Search | tmdb [QUERY]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split()[1].strip()
             answerss = await tmdb_func(answers, tex)
             await client.answer_inline_query(
@@ -400,13 +373,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "pypi":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Pypi Search | pypi [Package Name]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split()[1].strip()
             answerss = await pypiSearchFunc(answers, tex)
             await client.answer_inline_query(
@@ -415,13 +387,12 @@ async def inline_query_handler(client, query):
 
         elif text.split()[0] == "audio":
             if len(text.split()) < 2:
-                await client.answer_inline_query(
+                return await client.answer_inline_query(
                     query.id,
                     results=answers,
                     switch_pm_text="Random Audio Search | audio [Query]",
                     switch_pm_parameter="inline",
                 )
-                return
             tex = text.split()[1].strip()
             answerss = await randomAudioFunc(answers, tex)
             await client.answer_inline_query(
@@ -430,4 +401,3 @@ async def inline_query_handler(client, query):
     except Exception as e:
         e = traceback.format_exc()
         print(e, " InLine")
-        return

+ 7 - 12
wbb/modules/karma.py

@@ -27,6 +27,7 @@ from pyrogram import filters
 
 from wbb import app
 from wbb.core.decorators.errors import capture_err
+from wbb.core.decorators.permissions import adminsOnly
 from wbb.modules.admin import member_permissions
 from wbb.utils.dbfunctions import (alpha_to_int, get_karma, get_karmas,
                                    int_to_alpha, is_karma_on, karma_off,
@@ -36,7 +37,7 @@ from wbb.utils.filter_groups import karma_negative_group, karma_positive_group
 __MODULE__ = "Karma"
 __HELP__ = """[UPVOTE] - Use upvote keywords like "+", "+1", "thanks" etc to upvote a message.
 [DOWNVOTE] - Use downvote keywords like "-", "-1", etc to downvote a message.
-/karma_toggle [ON|OFF] - Enable or Disable Karma System In Your Chat.
+/karma_toggle [ENABLE|DISABLE] - Enable or Disable Karma System In Your Chat.
 Reply to a message with /karma to check a user's karma
 Send /karma without replying to any message to chek karma list of top 10 users"""
 
@@ -178,24 +179,18 @@ async def karma(_, message):
 
 
 @app.on_message(filters.command("karma_toggle") & ~filters.private)
-@capture_err
+@adminsOnly("can_change_info")
 async def captcha_state(_, message):
-    usage = "**Usage:**\n/karma_toggle [ON|OFF]"
+    usage = "**Usage:**\n/karma_toggle [ENABLE|DISABLE]"
     if len(message.command) != 2:
-        await message.reply_text(usage)
-        return
-    user_id = message.from_user.id
+        return await message.reply_text(usage)
     chat_id = message.chat.id
-    permissions = await member_permissions(chat_id, user_id)
-    if "can_restrict_members" not in permissions:
-        await message.reply_text("You don't have enough permissions.")
-        return
     state = message.text.split(None, 1)[1].strip()
     state = state.lower()
-    if state == "on":
+    if state == "enable":
         await karma_on(chat_id)
         await message.reply_text("Enabled karma system.")
-    elif state == "off":
+    elif state == "disable":
         await karma_off(chat_id)
         await message.reply_text("Disabled karma system.")
     else:

+ 7 - 14
wbb/modules/locks.py

@@ -64,12 +64,10 @@ data = {
 async def tg_lock(message, permissions: list, perm: str, lock: bool):
     if lock:
         if perm not in permissions:
-            await message.reply_text("Already locked.")
-            return
+            return await message.reply_text("Already locked.")
     else:
         if perm in permissions:
-            await message.reply_text("Already Unlocked.")
-            return
+            return await message.reply_text("Already Unlocked.")
     (permissions.remove(perm) if lock else permissions.append(perm))
     permissions = {perm: True for perm in list(set(permissions))}
     try:
@@ -77,10 +75,9 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
             message.chat.id, ChatPermissions(**permissions)
         )
     except ChatNotModified:
-        await message.reply_text(
+        return await message.reply_text(
             "To unlock this, you have to unlock 'messages' first."
         )
-        return
     await message.reply_text(("Locked." if lock else "Unlocked."))
 
 
@@ -88,23 +85,20 @@ async def tg_lock(message, permissions: list, perm: str, lock: bool):
 @adminsOnly("can_restrict_members")
 async def locks_func(_, message):
     if len(message.command) != 2:
-        await message.reply_text(incorrect_parameters)
-        return
+        return await message.reply_text(incorrect_parameters)
     chat_id = message.chat.id
     parameter = message.text.strip().split(None, 1)[1].lower()
     state = message.command[0].lower()
     if parameter not in data and parameter != "all":
-        await message.reply_text(incorrect_parameters)
-        return
+        return await message.reply_text(incorrect_parameters)
     permissions = await current_chat_permissions(chat_id)
     if parameter in data:
-        await tg_lock(
+        return await tg_lock(
             message,
             permissions,
             data[parameter],
             True if state == "lock" else False,
         )
-        return
     elif parameter == "all" and state == "lock":
         await app.set_chat_permissions(chat_id, ChatPermissions())
         await message.reply_text("Locked Everything.")
@@ -115,8 +109,7 @@ async def locks_func(_, message):
 async def locktypes(_, message):
     permissions = await current_chat_permissions(message.chat.id)
     if not permissions:
-        await message.reply_text("No Permissions.")
-        return
+        return await message.reply_text("No Permissions.")
     perms = ""
     for i in permissions:
         perms += f"__**{i}**__\n"

+ 13 - 26
wbb/modules/misc.py

@@ -61,8 +61,7 @@ async def commit(_, message):
 async def rtfm(_, message):
     await message.delete()
     if not message.reply_to_message:
-        await message.reply_text("Reply To A Message lol")
-        return
+        return await message.reply_text("Reply To A Message lol")
     await message.reply_to_message.reply_text(
         "Are You Lost? READ THE FUCKING DOCS!"
     )
@@ -78,8 +77,7 @@ async def getid(_, message):
     if len(message.command) == 2:
         id = (await app.get_users(message.text.split(None, 1)[1])).id
         text = f"**ID:** `{id}`"
-        await message.reply_text(text, parse_mode="html")
-        return
+        return await message.reply_text(text, parse_mode="html")
     text_unping = "<b>Chat ID:</b>"
     if message.chat.username:
         text_unping = (
@@ -134,10 +132,9 @@ async def getid(_, message):
 @capture_err
 async def random(_, message):
     if len(message.command) != 2:
-        await message.reply_text(
+        return await message.reply_text(
             '"/random" Needs An Argurment.' " Ex: `/random 5`"
         )
-        return
     length = message.text.split(None, 1)[1]
 
     try:
@@ -162,8 +159,7 @@ async def random(_, message):
 @capture_err
 async def encrypt(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply To A Message To Encrypt It.")
-        return
+        return await message.reply_text("Reply To A Message To Encrypt It.")
     text = message.reply_to_message.text
     text_in_bytes = bytes(text, "utf-8")
     cipher_suite = Fernet(FERNET_ENCRYPTION_KEY)
@@ -179,8 +175,7 @@ async def encrypt(_, message):
 @capture_err
 async def decrypt(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply To A Message To Decrypt It.")
-        return
+        return await message.reply_text("Reply To A Message To Decrypt It.")
     text = message.reply_to_message.text
     text_in_bytes = bytes(text, "utf-8")
     cipher_suite = Fernet(FERNET_ENCRYPTION_KEY)
@@ -205,8 +200,7 @@ async def fetch_text(url):
 @capture_err
 async def cheat(_, message):
     if len(message.command) < 3:
-        await message.reply_text("/cheat [language] [query]")
-        return
+        return await message.reply_text("/cheat [language] [query]")
     text = message.text.split(None, 1)[1]
     m = await message.reply_text("Searching")
     try:
@@ -215,8 +209,7 @@ async def cheat(_, message):
         query = ftext[1]
         data = await fetch_text(f"http://cht.sh/{language}/{query}?QT")
         if not data:
-            await m.edit("Found Literally Nothing!")
-            return
+            return await m.edit("Found Literally Nothing!")
         await m.edit(f"`{data}`")
     except Exception as e:
         await m.edit(str(e))
@@ -230,8 +223,7 @@ async def cheat(_, message):
 @capture_err
 async def weather(_, message):
     if len(message.command) != 2:
-        await message.reply_text("/weather [city]")
-        return
+        return await message.reply_text("/weather [city]")
     city = message.text.split(None, 1)[1]
     m = await message.reply_text("Fetching Data")
     data = await fetch_text(f"https://wttr.in/{city}?mnTC0")
@@ -245,25 +237,22 @@ async def weather(_, message):
 @capture_err
 async def tr(_, message):
     if len(message.command) != 2:
-        await message.reply_text("/tr [LANGUAGE_CODE]")
-        return
+        return await message.reply_text("/tr [LANGUAGE_CODE]")
     lang = message.text.split(None, 1)[1]
     if not message.reply_to_message or not lang:
-        await message.reply_text(
+        return await message.reply_text(
             "Reply to a message with /tr [language code]"
             + "\nGet supported language list from here -"
             + " https://py-googletrans.readthedocs.io/en"
             + "/latest/#googletrans-languages"
         )
-        return
     if message.reply_to_message.text:
         text = message.reply_to_message.text
     elif message.reply_to_message.caption:
         text = message.reply_to_message.caption
     result = await arq.translate(text, lang)
     if not result.ok:
-        await message.reply_text(result.result)
-        return
+        return await message.reply_text(result.result)
     await message.reply_text(result.result.translatedText)
 
 
@@ -272,8 +261,7 @@ async def tr(_, message):
 async def json_fetch(_, message):
     global fetch_limit
     if len(message.command) != 2:
-        await message.reply_text("/json [URL]")
-        return
+        return await message.reply_text("/json [URL]")
     url = message.text.split(None, 1)[1]
     try:
         data = await fetch(url)
@@ -297,8 +285,7 @@ async def bunn(_, message):
         await message.reply_to_message.reply_sticker(
             "CAACAgUAAx0CWIlO9AABARyRYBhyjKXFATVhu7AGQwip3TzSFiMAAuMBAAJ7usBUIu2xBtXTmuweBA"
         )
-        await app.send_message(message.chat.id, text="Eat Bun")
-        return
+        return await app.send_message(message.chat.id, text="Eat Bun")
     if not message.reply_to_message:
         await message.reply_sticker(
             "CAACAgUAAx0CWIlO9AABARyRYBhyjKXFATVhu7AGQwip3TzSFiMAAuMBAAJ7usBUIu2xBtXTmuweBA"

+ 11 - 22
wbb/modules/music.py

@@ -92,14 +92,12 @@ def download_youtube_audio(url: str, m=0):
 async def music(_, message):
     global is_downloading
     if len(message.command) != 2:
-        await message.reply_text("/ytmusic needs a link as argument")
-        return
+        return await message.reply_text("/ytmusic needs a link as argument")
     url = message.text.split(None, 1)[1]
     if is_downloading:
-        await message.reply_text(
+        return await message.reply_text(
             "Another download is in progress, try again after sometime."
         )
-        return
     is_downloading = True
     m = await message.reply_text(
         f"Downloading {url}", disable_web_page_preview=True
@@ -120,8 +118,7 @@ async def music(_, message):
         ) = music
     except Exception as e:
         is_downloading = False
-        await m.edit(str(e))
-        return
+        return await m.edit(str(e))
     await message.reply_audio(
         audio_file,
         duration=duration,
@@ -155,13 +152,11 @@ async def download_song(url):
 async def jssong(_, message):
     global is_downloading
     if len(message.command) < 2:
-        await message.reply_text("/saavn requires an argument.")
-        return
+        return await message.reply_text("/saavn requires an argument.")
     if is_downloading:
-        await message.reply_text(
+        return await message.reply_text(
             "Another download is in progress, try again after sometime."
         )
-        return
     is_downloading = True
     text = message.text.split(None, 1)[1]
     m = await message.reply_text("Searching...")
@@ -186,8 +181,7 @@ async def jssong(_, message):
         await m.delete()
     except Exception as e:
         is_downloading = False
-        await m.edit(str(e))
-        return
+        return await m.edit(str(e))
     is_downloading = False
 
 
@@ -199,13 +193,11 @@ async def jssong(_, message):
 async def deezsong(_, message):
     global is_downloading
     if len(message.command) < 2:
-        await message.reply_text("/deezer requires an argument.")
-        return
+        return await message.reply_text("/deezer requires an argument.")
     if is_downloading:
-        await message.reply_text(
+        return await message.reply_text(
             "Another download is in progress, try again after sometime."
         )
-        return
     is_downloading = True
     text = message.text.split(None, 1)[1]
     m = await message.reply_text("Searching...")
@@ -230,8 +222,7 @@ async def deezsong(_, message):
         await m.delete()
     except Exception as e:
         is_downloading = False
-        await m.edit(str(e))
-        return
+        return await m.edit(str(e))
     is_downloading = False
 
 
@@ -241,14 +232,12 @@ async def deezsong(_, message):
 @app.on_message(filters.command("lyrics"))
 async def lyrics_func(_, message):
     if len(message.command) < 2:
-        await message.reply_text("**Usage:**\n/lyrics [QUERY]")
-        return
+        return await message.reply_text("**Usage:**\n/lyrics [QUERY]")
     m = await message.reply_text("**Searching**")
     query = message.text.strip().split(None, 1)[1]
     song = await arq.lyrics(query)
     lyrics = song.result
     if len(lyrics) < 4095:
-        await m.edit(f"__{lyrics}__")
-        return
+        return await m.edit(f"__{lyrics}__")
     lyrics = await paste(lyrics)
     await m.edit(f"**LYRICS_TOO_LONG:** [URL]({lyrics})")

+ 4 - 8
wbb/modules/notes.py

@@ -54,8 +54,7 @@ async def save_notee(_, message):
     else:
         name = message.text.split(None, 1)[1].strip()
         if not name:
-            await message.reply_text("**Usage**\n__/save [NOTE_NAME]__")
-            return
+            return await message.reply_text("**Usage**\n__/save [NOTE_NAME]__")
         _type = "text" if message.reply_to_message.text else "sticker"
         note = {
             "type": _type,
@@ -90,8 +89,7 @@ async def get_one_note(_, message):
     else:
         name = message.text.split(None, 1)[1].strip()
         if not name:
-            await message.reply_text("**Usage**\n__/get [NOTE_NAME]__")
-            return
+            return await message.reply_text("**Usage**\n__/get [NOTE_NAME]__")
         _note = await get_note(message.chat.id, name)
         if not _note:
             await message.reply_text("**No such note.**")
@@ -108,12 +106,10 @@ async def get_one_note(_, message):
 @adminsOnly("can_change_info")
 async def del_note(_, message):
     if len(message.command) < 2:
-        await message.reply_text("**Usage**\n__/delete [NOTE_NAME]__")
-        return
+        return await message.reply_text("**Usage**\n__/delete [NOTE_NAME]__")
     name = message.text.split(None, 1)[1].strip()
     if not name:
-        await message.reply_text("**Usage**\n__/delete [NOTE_NAME]__")
-        return
+        return await message.reply_text("**Usage**\n__/delete [NOTE_NAME]__")
     chat_id = message.chat.id
     deleted = await delete_note(chat_id, name)
     if deleted:

+ 3 - 6
wbb/modules/paste.py

@@ -64,11 +64,9 @@ async def paste_func(_, message):
         elif message.reply_to_message.document:
             document = message.reply_to_message.document
             if document.file_size > 1048576:
-                await m.edit("You can only paste files smaller than 1MB.")
-                return
+                return await m.edit("You can only paste files smaller than 1MB.")
             if "text" not in document.mime_type:
-                await m.edit("Only text files can be pasted.")
-                return
+                return await m.edit("Only text files can be pasted.")
             doc = await message.reply_to_message.download()
             async with aiofiles.open(doc, mode="r") as f:
                 content = await f.read()
@@ -82,8 +80,7 @@ async def paste_func(_, message):
             await message.reply_photo(
                 photo=preview, quote=False, reply_markup=button
             )
-            await m.delete()
-            return
+            return await m.delete()
         await m.edit(link)
     else:
         await message.reply_text("Reply To A Message With /paste")

+ 9 - 18
wbb/modules/pmpermit.py

@@ -54,8 +54,7 @@ async def pmpermit_func(_, message):
         flood[str(user_id)] = 1
     if flood[str(user_id)] > 5:
         await message.reply_text("SPAM DETECTED, USER BLOCKED.")
-        await app2.block_user(user_id)
-        return
+        return await app2.block_user(user_id)
     results = await app2.get_inline_bot_results(BOT_ID, f"pmpermit {user_id}")
     await app2.send_inline_bot_result(
         user_id, results.query_id, results.results[0].id, hide_via=True
@@ -70,14 +69,12 @@ async def pmpermit_func(_, message):
 @capture_err
 async def pm_approve(_, message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="Reply to a user's message to approve."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     if await is_pmpermit_approved(user_id):
-        await edit_or_reply(message, text="User is already approved to pm")
-        return
+        return await edit_or_reply(message, text="User is already approved to pm")
     await approve_pmpermit(user_id)
     await edit_or_reply(message, text="User is approved to pm")
 
@@ -89,10 +86,9 @@ async def pm_approve(_, message):
 )
 async def pm_disapprove(_, message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="Reply to a user's message to approve."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     if not await is_pmpermit_approved(user_id):
         await edit_or_reply(message, text="User is already disapproved to pm")
@@ -115,10 +111,9 @@ async def pm_disapprove(_, message):
 @capture_err
 async def block_user_func(_, message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="Reply to a user's message to block."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     await app2.block_user(user_id)
     await edit_or_reply(message, text="Successfully blocked the user")
@@ -131,10 +126,9 @@ async def block_user_func(_, message):
 )
 async def unblock_user_func(_, message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="Reply to a user's message to unblock."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     await app2.unblock_user(user_id)
     await edit_or_reply(message, text="Successfully Unblocked the user")
@@ -151,16 +145,14 @@ async def pmpermit_cq(_, cq):
     data, victim = cq.data.split(None, 2)[1], cq.data.split(None, 2)[2]
     if data == "approve":
         if user_id != USERBOT_ID:
-            await cq.answer("This Button Is Not For You")
-            return
+            return await cq.answer("This Button Is Not For You")
         await approve_pmpermit(int(victim))
         await app.edit_inline_text(
             cq.inline_message_id, "User Has Been Approved To PM."
         )
         return
     if user_id == USERBOT_ID:
-        await cq.answer("It's For The Other Person.")
-        return
+        return await cq.answer("It's For The Other Person.")
 
     if data == "to_scam_you":
         async for m in app2.iter_history(user_id, limit=6):
@@ -176,8 +168,7 @@ async def pmpermit_cq(_, cq):
             flood2[str(user_id)] = 1
         if flood2[str(user_id)] > 5:
             await app2.send_message(user_id, "SPAM DETECTED, USER BLOCKED.")
-            await app2.block_user(user_id)
-            return
+            return await app2.block_user(user_id)
         await app2.send_message(
             user_id,
             "I'm busy right now, will approve you shortly, DO NOT SPAM.",

+ 3 - 7
wbb/modules/quotly.py

@@ -57,8 +57,7 @@ async def quotly_func(_, message: Message):
         arg = isArgInt(message)
         if arg[0]:
             if arg[1] < 2 or arg[1] > 10:
-                await m.edit("Argument must be between 2-10.")
-                return
+                return await m.edit("Argument must be between 2-10.")
             count = arg[1]
             messages = await app.get_messages(
                 message.chat.id,
@@ -73,10 +72,9 @@ async def quotly_func(_, message: Message):
             )
         else:
             if getArg(message) != "r":
-                await m.edit(
+                return await m.edit(
                     "Incorrect Argument, Pass **'r'** or **'INT'**, **EX:** __/q 2__"
                 )
-                return
             reply_message = await app.get_messages(
                 message.chat.id,
                 message.reply_to_message.message_id,
@@ -92,8 +90,7 @@ async def quotly_func(_, message: Message):
         sticker = await quotify(messages)
         if not sticker[0]:
             await message.rely_text(sticker[1])
-            await m.delete()
-            return
+            return await m.delete()
         sticker = sticker[1]
         await message.reply_sticker(sticker)
         await m.delete()
@@ -107,4 +104,3 @@ async def quotly_func(_, message: Message):
         await m.delete()
         e = format_exc()
         print(e)
-        return

+ 3 - 6
wbb/modules/reddit.py

@@ -34,13 +34,11 @@ __HELP__ = "/reddit [query] - results something from reddit"
 @capture_err
 async def reddit(_, message):
     if len(message.command) != 2:
-        await message.reply_text("/reddit needs an argument")
-        return
+        return await message.reply_text("/reddit needs an argument")
     subreddit = message.text.split(None, 1)[1]
     reddit = await arq.reddit(subreddit)
     if not reddit.ok:
-        await message.reply_text(reddit.result)
-        return
+        return await message.reply_text(reddit.result)
     reddit = reddit.result
     nsfw = reddit.nsfw
     sreddit = reddit.subreddit
@@ -48,8 +46,7 @@ async def reddit(_, message):
     image = reddit.url
     link = reddit.postLink
     if nsfw:
-        await message.reply_text("NSFW RESULTS COULD NOT BE SHOWN.")
-        return
+        return await message.reply_text("NSFW RESULTS COULD NOT BE SHOWN.")
     caption = f"""**Title:** `{title}`
 **Subreddit:** {sreddit}
 **PostLink:** {link}

+ 2 - 4
wbb/modules/regex.py

@@ -57,16 +57,14 @@ async def sed(_, message):
             return
 
         if not repl:
-            await message.reply_text(
+            return await message.reply_text(
                 "You're trying to replace... " "nothing with something?"
             )
-            return
 
         try:
 
             if infinite_checker(repl):
-                await message.reply_text("Nice try -_-")
-                return
+                return await message.reply_text("Nice try -_-")
 
             if "i" in flags and "g" in flags:
                 text = re.sub(repl, repl_with, to_fix, flags=re.I).strip()

+ 8 - 16
wbb/modules/reverse.py

@@ -18,11 +18,9 @@ __HELP__ = "/reverse  - Reverse search an image. [SUDOERS ONLY]"
 @capture_err
 async def reverse_image_search(_, message):
     if message.from_user.id not in SUDOERS:
-        await message.reply_text("THIS FEATURE IS ONLY FOR SUDO USERS.")
-        return
+        return await message.reply_text("THIS FEATURE IS ONLY FOR SUDO USERS.")
     if not message.reply_to_message:
-        await message.reply_text("Reply to a message to reverse search it.")
-        return
+        return await message.reply_text("Reply to a message to reverse search it.")
     reply = message.reply_to_message
     if (
         not reply.document
@@ -31,25 +29,21 @@ async def reverse_image_search(_, message):
         and not reply.animation
         and not reply.video
     ):
-        await message.reply_text(
+        return await message.reply_text(
             "Reply to an image/document/sticker/animation to reverse search it."
         )
-        return
     m = await message.reply_text("Searching")
     if reply.document:
         if int(reply.document.file_size) > 3145728:
-            await m.edit("File too large")
-            return
+            return await m.edit("File too large")
         mime_type = reply.document.mime_type
         if mime_type != "image/png" and mime_type != "image/jpeg":
-            await m.edit("Document Mimetype Invalid")
-            return
+            return await m.edit("Document Mimetype Invalid")
         file_id = reply.document.file_id
     if reply.sticker:
         if reply.sticker.is_animated:
             if not reply.sticker.thumbs:
-                await m.edit("Sticker Has No Thumb")
-                return
+                return await m.edit("Sticker Has No Thumb")
             file_id = reply.sticker.thumbs[0].file_id
         else:
             file_id = reply.sticker.file_id
@@ -59,10 +53,9 @@ async def reverse_image_search(_, message):
 
     if reply.animation:
         if not reply.animation.thumbs:
-            await m.edit(
+            return await m.edit(
                 "Gif Has No Thumbnail, so it cannot be reverse searched"
             )
-            return
         file_id = reply.animation.thumbs[0].file_id
 
     if reply.video:
@@ -83,8 +76,7 @@ async def reverse_image_search(_, message):
             location = response.headers.get("Location")
             os.remove(image)
         else:
-            await m.edit("Something wrong happened.")
-            return
+            return await m.edit("Something wrong happened.")
     headers = {
         "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
     }

+ 1 - 2
wbb/modules/rice.py

@@ -118,6 +118,5 @@ async def callback_query_ignore_rice(_, callback_query):
     elif disprover_status in ("creator", "administrator"):
         await m_op.reply_text(f"{u_disprover.mention} ignored this rice")
     else:
-        await callback_query.answer("Only admin or OP could ignore it")
-        return
+        return await callback_query.answer("Only admin or OP could ignore it")
     await callback_query.message.delete()

+ 6 - 12
wbb/modules/stickers.py

@@ -54,11 +54,9 @@ SUPPORTED_TYPES = ["jpeg", "png", "webp"]
 @capture_err
 async def sticker_id(_, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a sticker.")
-        return
+        return await message.reply_text("Reply to a sticker.")
     if not message.reply_to_message.sticker:
-        await message.reply_text("Reply to a sticker.")
-        return
+        return await message.reply_text("Reply to a sticker.")
     file_id = message.reply_to_message.sticker.file_id
     await message.reply_text(f"`{file_id}`")
 
@@ -67,8 +65,7 @@ async def sticker_id(_, message):
 @capture_err
 async def kang(client, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a sticker/image to kang it.")
-        return
+        return await message.reply_text("Reply to a sticker/image to kang it.")
     msg = await message.reply_text("Kanging Sticker..")
 
     # Find the proper emoji
@@ -97,8 +94,7 @@ async def kang(client, message):
             temp_file_path = await app.download_media(doc)
             image_type = imghdr.what(temp_file_path)
             if image_type not in SUPPORTED_TYPES:
-                await msg.edit("Format not supported! ({})".format(image_type))
-                return
+                return await msg.edit("Format not supported! ({})".format(image_type))
             try:
                 temp_file_path = await resize_file_to_sticker_size(
                     temp_file_path
@@ -116,8 +112,7 @@ async def kang(client, message):
             if os.path.isfile(temp_file_path):
                 os.remove(temp_file_path)
         else:
-            await msg.edit("Nope, can't kang that.")
-            return
+            return await msg.edit("Nope, can't kang that.")
     except ShortnameOccupyFailed:
         await message.reply_text("Change Your Name Or Username")
         return
@@ -125,8 +120,7 @@ async def kang(client, message):
     except Exception as e:
         await message.reply_text(str(e))
         e = format_exc()
-        print(e)
-        return
+        return print(e)
 
     # Find an available pack & add the sticker to the pack; create a new pack if needed
     # Would be a good idea to cache the number instead of searching it every single time...

+ 7 - 14
wbb/modules/sudo.py

@@ -53,28 +53,24 @@ can even delete your account.
 @capture_err
 async def useradd(_, message: Message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="Reply to someone's message to add him to sudoers."
         )
-        return
     user_id = message.reply_to_message.from_user.id
     sudoers = await get_sudoers()
     if user_id in sudoers:
-        await edit_or_reply(message, text="User is already in sudoers.")
-        return
+        return await edit_or_reply(message, text="User is already in sudoers.")
     if user_id == BOT_ID:
-        await edit_or_reply(
+        return await edit_or_reply(
             message, text="You can't add assistant bot in sudoers."
         )
-        return
     added = await add_sudo(user_id)
     if added:
         await edit_or_reply(
             message,
             text="Successfully added user in sudoers, Bot will be restarted now.",
         )
-        os.execvp("python3", ["python3", "-m", "wbb"])
-        return
+        return os.execvp("python3", ["python3", "-m", "wbb"])
     await edit_or_reply(message, text="Something wrong happened, check logs.")
 
 
@@ -84,23 +80,20 @@ async def useradd(_, message: Message):
 @capture_err
 async def userdel(_, message: Message):
     if not message.reply_to_message:
-        await edit_or_reply(
+        return await edit_or_reply(
             message,
             text="Reply to someone's message to remove him to sudoers.",
         )
-        return
     user_id = message.reply_to_message.from_user.id
     if user_id not in await get_sudoers():
-        await edit_or_reply(message, text="User is not in sudoers.")
-        return
+        return await edit_or_reply(message, text="User is not in sudoers.")
     removed = await remove_sudo(user_id)
     if removed:
         await edit_or_reply(
             message,
             text="Successfully removed user from sudoers, Bot will be restarted now.",
         )
-        os.execvp("python3", ["python3", "-m", "wbb"])
-        return
+        return os.execvp("python3", ["python3", "-m", "wbb"])
     await edit_or_reply(message, text="Something wrong happened, check logs.")
 
 

+ 7 - 8
wbb/modules/sudoers.py

@@ -34,7 +34,8 @@ from wbb import (BOT_ID, GBAN_LOG_GROUP_ID, SUDOERS, USERBOT_USERNAME, app,
 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)
+                                   is_gbanned_user, remove_gban_user,
+                                   start_restart_stage)
 
 __MODULE__ = "Sudoers"
 __HELP__ = """
@@ -81,10 +82,9 @@ async def get_stats(_, message):
 async def ban_globally(_, message):
     if not message.reply_to_message:
         if len(message.command) < 3:
-            await message.reply_text(
+            return await message.reply_text(
                 "**Usage:**\n/gban [USERNAME | USER_ID] [REASON]"
             )
-            return
         user = message.text.split(None, 2)[1]
         reason = message.text.split(None, 2)[2]
         if "@" in user:
@@ -214,7 +214,6 @@ __**New Global Ban**__
                 await message.reply_text(
                     "User Gbanned, But This Gban Wasn't Logged, Add Bot In GBAN_LOG_GROUP"
                 )
-                return
 
 
 # Ungban
@@ -225,10 +224,9 @@ __**New Global Ban**__
 async def unban_globally(_, message):
     if not message.reply_to_message:
         if len(message.command) != 2:
-            await message.reply_text(
+            return await message.reply_text(
                 "Reply to a user's message or give username/user_id."
             )
-            return
         user = message.text.split(None, 1)[1]
         if "@" in user:
             user = user.replace("@", "")
@@ -280,8 +278,7 @@ async def unban_globally(_, message):
 @capture_err
 async def broadcast_message(_, message):
     if len(message.command) < 2:
-        await message.reply_text("**Usage**:\n/broadcast [MESSAGE]")
-        return
+        return await message.reply_text("**Usage**:\n/broadcast [MESSAGE]")
     text = message.text.split(None, 1)[1]
     sent = 0
     chats = []
@@ -305,4 +302,6 @@ async def update_restart(_, message):
     await message.reply_text(
         f'```{subprocess.check_output(["git", "pull"]).decode("UTF-8")}```'
     )
+    m = await message.reply_text("**Updated with default branch, restarting now**")
+    await start_restart_stage(m.chat.id, m.message_id)
     os.execvp("python3", ["python3", "-m", "wbb"])

+ 1 - 3
wbb/modules/taglogger.py

@@ -57,8 +57,7 @@ async def tagLoggerFunc(_, message: Message):
         reply_message = message.reply_to_message
         if reply_message.from_user:
             if reply_message.from_user.id == USERBOT_ID:
-                await sendLog(message)
-                return
+                return await sendLog(message)
 
     if message.text:
         text = message.text
@@ -72,4 +71,3 @@ async def tagLoggerFunc(_, message: Message):
         or USERBOT_NAME in text
     ):
         await sendLog(message)
-        return

+ 4 - 8
wbb/modules/telegraph.py

@@ -23,11 +23,9 @@ Usage:
 @capture_err
 async def tgphoto(client, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a photo.")
-        return
+        return await message.reply_text("Reply to a photo.")
     if not message.reply_to_message.photo:
-        await message.reply_text("Works only for Photos")
-        return
+        return await message.reply_text("Works only for Photos")
     msg = await message.reply_text("`Uploading to Telegraph...`")
     userid = str(message.chat.id)
     path = f"./DOWNLOADS/{userid}.jpg"
@@ -49,11 +47,9 @@ async def tgphoto(client, message):
 @capture_err
 async def tgvideo(client, message):
     if not message.reply_to_message:
-        await message.reply_text("Reply to a Video.")
-        return
+        return await message.reply_text("Reply to a Video.")
     if not message.reply_to_message.video:
-        await message.reply_text("Works only for Videos")
-        return
+        return await message.reply_text("Works only for Videos")
     if message.reply_to_message.video.file_size < 5242880:
         msg = await message.reply_text("Uploading to Telegraph...")
         userid = str(message.chat.id)

+ 1 - 4
wbb/modules/tts.py

@@ -30,14 +30,12 @@ from pyrogram import filters
 from pyrogram.types import Message
 
 from wbb import app
-from wbb.core.decorators.errors import capture_err
 
 __MODULE__ = "TTS"
 __HELP__ = "/tts - Convert Text To Speech."
 
 
 @app.on_message(filters.command("tts"))
-@capture_err
 async def text_to_speech(_, message: Message):
     try:
         if message.reply_to_message:
@@ -52,8 +50,7 @@ async def text_to_speech(_, message: Message):
                 tts.write_to_fp(audio)
                 await m.delete()
                 await message.reply_audio(audio)
-                audio.close()
-                return
+                return audio.close()
         await message.reply_text("Reply to some text ffs.")
     except Exception as e:
         await message.reply_text(e)

+ 7 - 14
wbb/modules/userbot.py

@@ -58,8 +58,7 @@ async def executor(client, message: Message):
     try:
         cmd = message.text.split(" ", maxsplit=1)[1]
     except IndexError:
-        await message.delete()
-        return
+        return await message.delete()
     old_stderr = sys.stderr
     old_stdout = sys.stdout
     redirected_output = sys.stdout = StringIO()
@@ -106,8 +105,7 @@ async def executor(client, message: Message):
 )
 async def shellrunner(client, message: Message):
     if len(message.command) < 2:
-        await edit_or_reply(message, text="**Usage:**\n/sh git pull")
-        return
+        return await edit_or_reply(message, text="**Usage:**\n/sh git pull")
     text = message.text.split(None, 1)[1]
     if "\n" in text:
         code = text.split("\n")
@@ -147,11 +145,10 @@ async def shellrunner(client, message: Message):
                 value=exc_obj,
                 tb=exc_tb,
             )
-            await edit_or_reply(
+            return await edit_or_reply(
                 message,
                 text=f"**INPUT:**\n```{escape(text)}```\n\n**ERROR:**\n```{''.join(errors)}```",
             )
-            return
         output = process.stdout.read()[:-1].decode("utf-8")
     if str(output) == "\n":
         output = None
@@ -165,8 +162,7 @@ async def shellrunner(client, message: Message):
                 reply_to_message_id=message.message_id,
                 caption="`Output`",
             )
-            os.remove("output.txt")
-            return
+            return os.remove("output.txt")
         await edit_or_reply(
             message,
             text=f"**INPUT:**\n```{escape(text)}```\n\n**OUTPUT:**\n```{escape(output)}```",
@@ -212,10 +208,8 @@ async def cEval(_, message: Message):
 ```{escape(err)}```
 """
         if len(text) > 4090:
-            await sendFile(message, text)
-            return
-        await edit_or_reply(message, text=text)
-        return
+            return await sendFile(message, text)
+        return await edit_or_reply(message, text=text)
     pRun = subprocess.run(cmdRun, capture_output=True)
     t2 = time()
     os.remove("exec")
@@ -232,6 +226,5 @@ async def cEval(_, message: Message):
 `Compiled and executed in {round(t2-t1, 5)} seconds`
 """
     if len(text) > 4090:
-        await sendFile(message, text)
-        return
+        return await sendFile(message, text)
     await edit_or_reply(message, text=text)

+ 2 - 4
wbb/modules/webss.py

@@ -35,8 +35,7 @@ __HELP__ = "/webss | .webss [URL] - Take A Screenshot Of A Webpage"
 async def take_ss(_, message):
     try:
         if len(message.command) != 2:
-            await message.reply_text("Give A Url To Fetch Screenshot.")
-            return
+            return await message.reply_text("Give A Url To Fetch Screenshot.")
         url = message.text.split(None, 1)[1]
         m = await message.reply_text("**Taking Screenshot**")
         await m.edit("**Uploading**")
@@ -46,8 +45,7 @@ async def take_ss(_, message):
                 photo=f"https://webshot.amanoteam.com/print?q={url}",
             )
         except TypeError:
-            await m.edit("No Such Website.")
-            return
+            return await m.edit("No Such Website.")
         await m.delete()
     except Exception as e:
         await message.reply_text(str(e))

+ 2 - 4
wbb/modules/ytdl.py

@@ -23,14 +23,12 @@ VIDEO_DATA = {}
 @capture_err
 async def ytdl_func(_, message):
     if len(message.command) != 2:
-        await message.reply_text("**Usage:**/ytdl [VIDEO_LINK]")
-        return
+        return await message.reply_text("**Usage:**/ytdl [VIDEO_LINK]")
     m = await message.reply_text("Processing")
     url = message.text.split(None, 1)[1]
     results = await arq.ytdl(url)
     if not results.ok:
-        await message.reply_text(results.result)
-        return
+        return await m.edit(results.result)
     result = results.result
     title = result.title
     thumbnail = result.thumbnail

+ 27 - 0
wbb/utils/dbfunctions.py

@@ -43,6 +43,7 @@ blacklist_filtersdb = db.blacklistFilters
 pipesdb = db.pipes
 sudoersdb = db.sudoers
 blacklist_chatdb = db.blacklistChat
+restart_stagedb = db.restart_stage
 
 """ Notes functions """
 
@@ -674,3 +675,29 @@ async def whitelist_chat(chat_id: int) -> bool:
         await blacklist_chatdb.delete_one({"chat_id": chat_id})
         return True
     return False
+
+
+""" Restart stage """
+
+async def start_restart_stage(chat_id: int, message_id: int):
+    await restart_stagedb.update_one(
+        {
+            "something": "something"
+        },
+        {
+            "$set": {
+                "chat_id": chat_id,
+                "message_id": message_id,
+                }
+            },
+        upsert=True
+    ) 
+
+async def clean_restart_stage() -> dict:
+    data = await restart_stagedb.find_one({"something": "something"})
+    if not data:
+        return {}
+    await restart_stagedb.delete_one({"something": "something"})
+    return {"chat_id": data['chat_id'], "message_id": data['message_id']}
+
+