thehamkercat hace 5 años
padre
commit
9f95e62639

+ 5 - 3
sample_config.py

@@ -23,8 +23,8 @@ if HEROKU:
         True if int(environ.get("LOG_MENTIONS", None)) == 1 else False
     )
     SPAM_CHECK_EXCEPTION_GROUPS = list(
-            int(y) for y in environ.get("SPAM_CHECK_EXCEPTION_GROUPS", []).split()
-            )
+        int(y) for y in environ.get("SPAM_CHECK_EXCEPTION_GROUPS", []).split()
+    )
 else:
     BOT_TOKEN = "467677575:YZfaakjwd545dfg-N6JStihhuw5gQeZHntc"
     API_ID = 123456
@@ -46,4 +46,6 @@ else:
     ARQ_API_KEY = "Get this from @ARQRobot"
     ARQ_API_URL = "http://thearq.tech"
     LOG_MENTIONS = True
-    SPAM_CHECK_EXCEPTION_GROUPS = [] #Leave it empty if you don't know about it
+    SPAM_CHECK_EXCEPTION_GROUPS = (
+        []
+    )  # Leave it empty if you don't know about it

+ 14 - 3
wbb/__init__.py

@@ -106,6 +106,7 @@ USERBOT_DC_ID = 0
 USERBOT_MENTION = ""
 USERBOT_BOT_CHAT_DIFFERENCE = []
 
+
 def get_info(app, app2):
     global BOT_ID, BOT_NAME, BOT_USERNAME, BOT_DC_ID, BOT_MENTION
     global USERBOT_ID, USERBOT_NAME, USERBOT_USERNAME, USERBOT_DC_ID, USERBOT_MENTION
@@ -131,10 +132,20 @@ def get_info(app, app2):
     USERBOT_USERNAME = getme2.username
     USERBOT_MENTION = getme2.mention
     USERBOT_DC_ID = getme2.dc_id
-    all_ub_chats = [i.chat.id for i in app2.iter_dialogs() if i.chat.type in ['group', 'supergroup', 'private']]
+    all_ub_chats = [
+        i.chat.id
+        for i in app2.iter_dialogs()
+        if i.chat.type in ["group", "supergroup", "private"]
+    ]
     ub_b_common_chats = [i.id for i in app2.get_common_chats(BOT_ID)]
-    USERBOT_BOT_CHAT_DIFFERENCE = list(set(all_ub_chats).difference(ub_b_common_chats))
-    USERBOT_BOT_CHAT_DIFFERENCE = [x for x in USERBOT_BOT_CHAT_DIFFERENCE if x not in SPAM_CHECK_EXCEPTION_GROUPS]
+    USERBOT_BOT_CHAT_DIFFERENCE = list(
+        set(all_ub_chats).difference(ub_b_common_chats)
+    )
+    USERBOT_BOT_CHAT_DIFFERENCE = [
+        x
+        for x in USERBOT_BOT_CHAT_DIFFERENCE
+        if x not in SPAM_CHECK_EXCEPTION_GROUPS
+    ]
 
 
 print("[INFO]: STARTING BOT CLIENT")

+ 17 - 3
wbb/modules/info.py

@@ -52,9 +52,23 @@ async def get_user_info(user):
     is_sudo = user_id in SUDOERS
     karma = await user_global_karma(user_id)
     spam_probab, n_messages = await get_spam_probability(user_id)
-    isSpammer = True if spam_probab > 70 else False if spam_probab != 0 else "Uncertain"
-    isPotentialSpammer = True if spam_probab > 40 else False if spam_probab != 0 else "Uncertain"
-    spam_probab = str(round(spam_probab)) + " %" if spam_probab != 0 else "Uncertain"
+    isSpammer = (
+        True
+        if spam_probab > 70
+        else False
+        if spam_probab != 0
+        else "Uncertain"
+    )
+    isPotentialSpammer = (
+        True
+        if spam_probab > 40
+        else False
+        if spam_probab != 0
+        else "Uncertain"
+    )
+    spam_probab = (
+        str(round(spam_probab)) + " %" if spam_probab != 0 else "Uncertain"
+    )
     caption = f"""
 **ID:** `{user_id}`
 **DC:** {dc_id}

+ 6 - 2
wbb/modules/inline.py

@@ -116,7 +116,9 @@ async def inline_query_handler(client, query):
                 )
             tex = text.split(None, 1)[1].strip()
             answerss = await wall_func(answers, tex)
-            await client.answer_inline_query(query.id, results=answerss, cache_time=2)
+            await client.answer_inline_query(
+                query.id, results=answerss, cache_time=2
+            )
 
         elif text.split()[0] == "torrent":
             if len(text.split()) < 2:
@@ -330,7 +332,9 @@ async def inline_query_handler(client, query):
                 )
             tex = text.split(None, 1)[1].strip()
             answerss = await image_func(answers, tex)
-            await client.answer_inline_query(query.id, results=answerss, cache_time=3600)
+            await client.answer_inline_query(
+                query.id, results=answerss, cache_time=3600
+            )
 
     except Exception as e:
         e = traceback.format_exc()

+ 16 - 14
wbb/modules/trust.py

@@ -24,24 +24,26 @@ SOFTWARE.
 from pyrogram import filters
 from pyrogram.types import Message
 
-from wbb import app, app2, arq, MESSAGE_DUMP_CHAT, USERBOT_BOT_CHAT_DIFFERENCE, BOT_ID
-from wbb.utils.dbfunctions import update_trust_db, get_trust_db
+from wbb import (BOT_ID, MESSAGE_DUMP_CHAT, USERBOT_BOT_CHAT_DIFFERENCE, app,
+                 app2, arq)
+from wbb.utils.dbfunctions import get_trust_db, update_trust_db
 from wbb.utils.filter_groups import trust_group
 
+
 @app2.on_message(
-        (filters.text | filters.caption)
-        & ~filters.chat([MESSAGE_DUMP_CHAT, BOT_ID])
-        & filters.chat(USERBOT_BOT_CHAT_DIFFERENCE)
-        & ~filters.me,
-        group=trust_group
-    )
+    (filters.text | filters.caption)
+    & ~filters.chat([MESSAGE_DUMP_CHAT, BOT_ID])
+    & filters.chat(USERBOT_BOT_CHAT_DIFFERENCE)
+    & ~filters.me,
+    group=trust_group,
+)
 @app.on_message(
-        (filters.text | filters.caption)
-        & ~filters.chat(MESSAGE_DUMP_CHAT)
-        & ~filters.me
-        & ~filters.private,
-        group=trust_group
-    )
+    (filters.text | filters.caption)
+    & ~filters.chat(MESSAGE_DUMP_CHAT)
+    & ~filters.me
+    & ~filters.private,
+    group=trust_group,
+)
 async def trust_watcher_func(_, message: Message):
     if message.command:
         return

+ 4 - 3
wbb/utils/dbfunctions.py

@@ -732,16 +732,17 @@ async def clean_restart_stage() -> dict:
 
 """ TRUST DB """
 
+
 async def get_trust_db(user_id: int) -> list:
     user = await trustdb.find_one({"user_id": user_id})
     if not user:
         return []
-    return user['data']
-    
+    return user["data"]
+
 
 async def update_trust_db(user_id: int, new_data: float):
     user = await trustdb.find_one({"user_id": user_id})
-    data = user['data'] if user else []
+    data = user["data"] if user else []
     if len(data) >= 2000:
         data.remove(data[0])
     data.append(new_data)

+ 1 - 4
wbb/utils/functions.py

@@ -127,10 +127,7 @@ async def get_http_status_code(url: str) -> int:
 
 async def make_carbon(code):
     url = "https://carbonara.vercel.app/api/cook"
-    async with aiosession.post(
-            url,
-            json={"code": code}
-            ) as resp:
+    async with aiosession.post(url, json={"code": code}) as resp:
         data = await resp.read()
     image = f"{randint(100, 10000)}.png"
     async with aiofiles.open(image, mode="wb") as f:

+ 4 - 4
wbb/utils/inlinefuncs.py

@@ -886,10 +886,10 @@ async def image_func(answers, query):
     results = results.result[0:48]
     buttons = InlineKeyboard(row_width=2)
     buttons.add(
-            InlineKeyboardButton(
-                text="Search again", switch_inline_query_current_chat="image"
-            ),
-        )
+        InlineKeyboardButton(
+            text="Search again", switch_inline_query_current_chat="image"
+        ),
+    )
     for i in results:
         answers.append(
             InlineQueryResultPhoto(

+ 4 - 1
wbb/utils/pastebin.py

@@ -25,6 +25,7 @@ import socket
 from asyncio import get_running_loop
 from functools import partial
 
+
 def _netcat(host, port, content):
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.connect((host, port))
@@ -40,5 +41,7 @@ def _netcat(host, port, content):
 
 async def paste(content):
     loop = get_running_loop()
-    link = await loop.run_in_executor(None, partial(_netcat, "ezup.dev", 9999, content))
+    link = await loop.run_in_executor(
+        None, partial(_netcat, "ezup.dev", 9999, content)
+    )
     return link