Kaynağa Gözat

Some fixes and stuff

TheHamkerCat 5 yıl önce
ebeveyn
işleme
2a866e233a

+ 2 - 0
wbb/modules/flood.py

@@ -64,6 +64,8 @@ def reset_flood(chat_id, user_id=0):
 )
 @capture_err
 async def flood_control_func(_, message: Message):
+    if not message.chat:
+        return
     chat_id = message.chat.id
     if not (await is_flood_on(chat_id)):
         return

+ 15 - 12
wbb/modules/locks.py

@@ -27,10 +27,9 @@ from pyrogram.types import ChatPermissions
 
 from wbb import SUDOERS, app
 from wbb.core.decorators.errors import capture_err
-from wbb.utils.functions import get_urls_from_text
 from wbb.core.decorators.permissions import adminsOnly
 from wbb.modules.admin import current_chat_permissions, list_admins
-
+from wbb.utils.functions import get_urls_from_text
 
 __MODULE__ = "Locks"
 __HELP__ = """
@@ -51,7 +50,7 @@ incorrect_parameters = (
     "Incorrect Parameters, Check Locks Section In Help."
 )
 # Using disable_preview as a switch for url checker
-# That way we won't need an additional db to check 
+# That way we won't need an additional db to check
 # If url lock is enabled/disabled for a chat
 data = {
     "messages": "can_send_messages",
@@ -123,25 +122,29 @@ async def locktypes(_, message):
     for i in permissions:
         perms += f"__**{i}**__\n"
     await message.reply_text(perms)
-    
 
-@app.on_message(filters.text & ~filters.private)
+
+@app.on_message(filters.text & ~filters.private, group=69)
 async def url_detector(_, message):
     user = message.from_user
     chat_id = message.chat.id
     text = message.text.lower().strip()
-    if not text: return
-    if not user: return
-    if user.id in SUDOERS: return
-    if user.id in await list_admins(chat_id): return
+    if not text:
+        return
+    if not user:
+        return
+    if user.id in SUDOERS:
+        return
+    if user.id in await list_admins(chat_id):
+        return
     check = get_urls_from_text(text)
     if check:
         permissions = await current_chat_permissions(chat_id)
-        if 'can_add_web_page_previews' not in permissions:
+        if "can_add_web_page_previews" not in permissions:
             try:
                 await message.delete()
             except Exception:
                 await message.reply_text(
-                         "This message contains a URL, "
-                         + "but i don't have enough permissions to delete it"
+                    "This message contains a URL, "
+                    + "but i don't have enough permissions to delete it"
                 )

+ 8 - 3
wbb/modules/misc.py

@@ -91,9 +91,7 @@ async def getid(_, message):
         try:
             split = message.text.split(None, 1)[1].strip()
             user_id = (await app.get_users(split)).id
-            text += (
-                f"**[User ID:](tg://user?id={user_id})** `{user_id}`\n"
-            )
+            text += f"**[User ID:](tg://user?id={user_id})** `{user_id}`\n"
         except Exception:
             return await message.reply_text(
                 "This user doesn't exist."
@@ -265,3 +263,10 @@ async def take_ss(_, message):
     except Exception:
         return await m.edit("No Such Website.")
     await m.delete()
+
+
+@app.on_message(filters.command(["kickme", "banme"]))
+async def kickbanme(_, message):
+    await message.reply_text(
+        "Haha, it doesn't work that way, You're stuck with everyone here."
+    )

+ 1 - 1
wbb/modules/notes.py

@@ -89,7 +89,7 @@ async def get_notes(_, message):
 @app.on_message(
     filters.regex(r"^#.+")
     & filters.text
-    & ~filters.edited 
+    & ~filters.edited
     & ~filters.private
 )
 @capture_err

+ 4 - 2
wbb/modules/paste.py

@@ -61,7 +61,9 @@ async def isPreviewUp(preview: str) -> bool:
 @capture_err
 async def paste_func(_, message):
     if not message.reply_to_message:
-        return await message.reply_text("Reply To A Message With /paste")
+        return await message.reply_text(
+            "Reply To A Message With /paste"
+        )
     m = await message.reply_text("Pasting...")
     if message.reply_to_message.text:
         content = str(message.reply_to_message.text)
@@ -87,7 +89,7 @@ async def paste_func(_, message):
             await message.reply_photo(
                 photo=preview, quote=False, reply_markup=button
             )
-            await m.delete()
+            return await m.delete()
         except Exception:
             pass
     return await m.edit(link)

+ 1 - 1
wbb/modules/reverse.py

@@ -34,7 +34,7 @@ async def reverse_image_search(_, message):
     m = await message.reply_text("Downloading")
     file_id = await get_file_id_from_message(reply)
     if not file_id:
-        return m.edit("Can't reverse that")
+        return await m.edit("Can't reverse that")
     image = await app.download_media(
         file_id, f"{randint(1000, 10000)}.jpg"
     )

+ 3 - 1
wbb/modules/sudo.py

@@ -26,7 +26,7 @@ import os
 from pyrogram import filters
 from pyrogram.types import Message
 
-from wbb import BOT_ID, SUDOERS, USERBOT_PREFIX, app2
+from wbb import BOT_ID, OWNER_ID, SUDOERS, USERBOT_PREFIX, app2
 from wbb.core.decorators.errors import capture_err
 from wbb.modules.userbot import edit_or_reply
 from wbb.utils.dbfunctions import add_sudo, get_sudoers, remove_sudo
@@ -115,6 +115,8 @@ async def userdel(_, message: Message):
 @capture_err
 async def sudoers_list(_, message: Message):
     sudoers = await get_sudoers()
+    if isinstance(sudoers, list):
+        sudoers.append(OWNER_ID)
     text = ""
     for count, user_id in enumerate(sudoers, 1):
         user = await app2.get_users(user_id)