Browse Source

Improved reporting (#133)

* Fixed a bug by me.
* Added return for bot admemes and deleted accs
ÁÑÑÍHÌLÅTØR SPÄRK 5 năm trước cách đây
mục cha
commit
f0ea742d60
1 tập tin đã thay đổi với 12 bổ sung và 7 xóa
  1. 12 7
      wbb/modules/admin.py

+ 12 - 7
wbb/modules/admin.py

@@ -609,11 +609,10 @@ async def check_warns(_, message: Message):
 # Report
 
 
-@app.on_message(
-    filters.command(["admins", "admin", "report"], prefixes="@")
-    & ~filters.edited
-    & ~filters.private
-)
+@app.on_message((filters.command("report")
+                 | filters.command(["admins", "admin"], prefixes="@"))
+                & ~filters.edited
+                & ~filters.private)
 @capture_err
 async def report_user(_, message):
     if not message.reply_to_message:
@@ -632,6 +631,12 @@ async def report_user(_, message):
  
     user_mention = message.reply_to_message.from_user.mention
     text = f"Reported {user_mention} to admins!"
-    for admin in list_of_admins:
-        text += f"[\u2063](tg://user?id={admin})"
+    admin_data = await app.get_chat_members(chat_id=message.chat.id,
+                                            filter="administrators") # will it giv floods ?
+    for admin in admin_data:
+        if admin.user.is_bot or admin.user.is_deleted:
+            # return bots or deleted admins
+            continue
+        text += f"[\u2063](tg://user?id={admin.user.id})"
+
     await message.reply_to_message.reply_text(text)