Explorar o código

fix: add one more check for user_id in sudoers

- in case pyrogram's filters are broken
- Also cleanup code i pushed accidentally in https://github.com/TheHamkerCat/WilliamButcherBot/commit/c795cc1c018c097f213ab4e777f552ecffd00749 2 years ago
TheHamkerCat hai 7 meses
pai
achega
14a188d5b5
Modificáronse 2 ficheiros con 9 adicións e 37 borrados
  1. 8 36
      wbb/modules/userbot.py
  2. 1 1
      wbb/utils/dbfeds.py

+ 8 - 36
wbb/modules/userbot.py

@@ -1,8 +1,8 @@
 """
-    CREDITS:
-        MOST OF THE CODE IN THIS FILE IS WRITTEN BY @Pokurt.
-        SOURCE:
-            https://github.com/pokurt/Nana-Remix/blob/master/nana/plugins/devs.py
+CREDITS:
+    MOST OF THE CODE IN THIS FILE IS WRITTEN BY @Pokurt.
+    SOURCE:
+        https://github.com/pokurt/Nana-Remix/blob/master/nana/plugins/devs.py
 """
 
 import os
@@ -66,6 +66,8 @@ async def iter_edit(message: Message, text: str):
 )
 async def executor(client, message: Message):
     global m, p, r
+    if not message.from_user or message.from_user.id not in SUDOERS:
+        return
     try:
         cmd = message.text.split(" ", maxsplit=1)[1]
     except IndexError:
@@ -157,6 +159,8 @@ async def executor(client, message: Message):
     & filters.command("sh", prefixes=USERBOT_PREFIX),
 )
 async def shellrunner(_, message: Message):
+    if not message.from_user or message.from_user.id not in SUDOERS:
+        return
     if len(message.command) < 2:
         return await eor(message, text="**Usage:**\n/sh git pull")
 
@@ -230,38 +234,6 @@ async def shellrunner(_, message: Message):
             text=f"**INPUT:**\n```{escape(text)}```\n\n**OUTPUT: **\n`No output`",
         )
 
-HISTORY = [
-        {"role": "system", "content": "You are a human, behave and response like a human, don't behave like a bot because you are not an ai bot.\n\nAlways end a message with a question or new topic"}
-    ]
-from wbb.utils.http import post
-from asyncio import sleep
-
-@app2.on_message(
-        filters.chat([-1002139890459, "thehamkercat"])
-        & filters.text
-)
-async def asd_temp(_, message: Message):
-    if (message.from_user.username or "").lower() in ["thehamkercat", "jojiiofficial"]:
-        return
-    text = message.text
-
-    HISTORY.append({"role": "user", "content": text})
-
-    response = await post(
-             "http://localhost:1234/v1/chat/completions",
-             headers={"Content-Type": "application/json"},
-             json={
-                 "messages": HISTORY,
-                  "temperature": 0.7, 
-                  "max_tokens": -1,
-                  "stream": False,
-                }
-            )
-    resp_text = response['choices'][0]['message']['content']
-    HISTORY.append({"role": "assistant", "content": resp_text})
-    await sleep(10)
-    return await message.reply(resp_text)
-
 
 @app2.on_message(
     filters.command("reserve", prefixes=USERBOT_PREFIX)

+ 1 - 1
wbb/utils/dbfeds.py

@@ -69,7 +69,7 @@ async def is_user_fed_owner(fed_id, user_id: int):
     if not getfed:
         return False
     owner_id = getfed["owner_id"]
-    if user_id == owner_id or user_id == SUDOERS:
+    if user_id == owner_id or user_id in SUDOERS:
         return True
     else:
         return False