Selaa lähdekoodia

Small fixes and formatting

Signed-off-by: TheHamkerCat <TheHamkerCat@gmail.com>
TheHamkerCat 4 vuotta sitten
vanhempi
sitoutus
f8eddb4420
5 muutettua tiedostoa jossa 46 lisäystä ja 23 poistoa
  1. 3 2
      wbb/__init__.py
  2. 24 10
      wbb/modules/admin.py
  3. 16 8
      wbb/modules/sudoers.py
  4. 1 1
      wbb/modules/telegraph.py
  5. 2 2
      wbb/utils/functions.py

+ 3 - 2
wbb/__init__.py

@@ -144,12 +144,13 @@ class Log:
         print(f"[+]: {msg}")
         if self.save_to_file:
             with open(self.file_name, "a") as f:
-                f.write(f"[INFO]({ctime(time())}): {msg}\n")
+                f.write(f"[INFO]({time.ctime(time.time())}): {msg}\n")
 
     def error(self, msg):
         print(f"[-]: {msg}")
         if self.save_to_file:
             with open(self.file_name, "a") as f:
-                f.write(f"[ERROR]({ctime(time())}): {msg}\n")
+                f.write(f"[ERROR]({time.ctime(time.time())}): {msg}\n")
+
 
 log = Log(True, "bot.log")

+ 24 - 10
wbb/modules/admin.py

@@ -25,15 +25,28 @@ import asyncio
 from time import time
 
 from pyrogram import filters
-from pyrogram.types import CallbackQuery, ChatPermissions, Message, ChatMemberUpdated
+from pyrogram.types import (
+    CallbackQuery,
+    ChatPermissions,
+    Message,
+    ChatMemberUpdated,
+)
 
 from wbb import BOT_ID, SUDOERS, app, log
 from wbb.core.decorators.errors import capture_err
 from wbb.core.keyboard import ikb
-from wbb.utils.dbfunctions import (add_warn, get_warn, int_to_alpha,
-                                   remove_warns, save_filter)
-from wbb.utils.functions import (extract_user, extract_user_and_reason,
-                                 time_converter)
+from wbb.utils.dbfunctions import (
+    add_warn,
+    get_warn,
+    int_to_alpha,
+    remove_warns,
+    save_filter,
+)
+from wbb.utils.functions import (
+    extract_user,
+    extract_user_and_reason,
+    time_converter,
+)
 
 __MODULE__ = "Admin"
 __HELP__ = """/ban - Ban A User
@@ -136,8 +149,9 @@ async def current_chat_permissions(chat_id):
 
 # Admin cache reload
 
-@app.old_chat_member(~filters.private)
-async def admincacheFunc(_, cmu: ChatMemberUpdated):
+
+@app.on_chat_member_updated()
+async def admin_cache_func(_, cmu: ChatMemberUpdated):
     if cmu.old_chat_member and cmu.old_chat_member.promoted_by:
         admins_in_chat[cmu.chat.id] = {
             "last_updated_at": time(),
@@ -149,7 +163,7 @@ async def admincacheFunc(_, cmu: ChatMemberUpdated):
             ],
         }
         log.info(f"Updated admin cache for {cmu.chat.id} [{cmu.chat.title}]")
-      
+
 
 # Purge Messages
 
@@ -295,10 +309,10 @@ async def banFunc(_, message: Message):
 
 @app.on_message(filters.command("unban") & ~filters.edited & ~filters.private)
 @adminsOnly("can_restrict_members")
-async def unbanFunc(_, message: Message):
+async def unban_func(_, message: Message):
     # we don't need reasons for unban, also, we
     # don't need to get "text_mention" entity, because
-    # normal users won't get text_mention if the the user
+    # normal users won't get text_mention if the user
     # they want to unban is not in the group.
     if len(message.command) == 2:
         user = message.text.split(None, 1)[1]

+ 16 - 8
wbb/modules/sudoers.py

@@ -30,12 +30,22 @@ import psutil
 from pyrogram import filters
 from pyrogram.errors import FloodWait
 
-from wbb import (BOT_ID, GBAN_LOG_GROUP_ID, SUDOERS, USERBOT_USERNAME, app,
-                 bot_start_time)
+from wbb import (
+    BOT_ID,
+    GBAN_LOG_GROUP_ID,
+    SUDOERS,
+    USERBOT_USERNAME,
+    app,
+    bot_start_time,
+)
 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)
+from wbb.utils.dbfunctions import (
+    add_gban_user,
+    get_served_chats,
+    is_gbanned_user,
+    remove_gban_user,
+)
 from wbb.utils.functions import extract_user, extract_user_and_reason, restart
 
 __MODULE__ = "Sudoers"
@@ -69,7 +79,7 @@ async def bot_sys_stats():
     stats = f"""
 {USERBOT_USERNAME}@William
 ------------------
-UPTIME: {formatter.get_readable_time((bot_uptime))}
+UPTIME: {formatter.get_readable_time(bot_uptime)}
 BOT: {round(process.memory_info()[0] / 1024 ** 2)} MB
 CPU: {cpu}%
 RAM: {mem}%
@@ -167,9 +177,7 @@ async def unban_globally(_, message):
 # Broadcast
 
 
-@app.on_message(
-    filters.command("broadcast") & SUDOERS & ~filters.edited
-)
+@app.on_message(filters.command("broadcast") & SUDOERS & ~filters.edited)
 @capture_err
 async def broadcast_message(_, message):
     if len(message.command) < 2:

+ 1 - 1
wbb/modules/telegraph.py

@@ -21,7 +21,7 @@ async def paste(_, message: Message):
 
     page_name = message.text.split(None, 1)[1]
     page = telegraph.create_page(
-        page_name, html_content=(reply.text.html).replace("\n", "<br>")
+        page_name, html_content=reply.text.html.replace("\n", "<br>")
     )
     return await message.reply(
         f"**Posted:** {page['url']}",

+ 2 - 2
wbb/utils/functions.py

@@ -53,10 +53,10 @@ def generate_captcha():
         return chr(randint(65, 90))
 
     def rndColor():
-        return (randint(64, 255), randint(64, 255), randint(64, 255))
+        return randint(64, 255), randint(64, 255), randint(64, 255)
 
     def rndColor2():
-        return (randint(32, 127), randint(32, 127), randint(32, 127))
+        return randint(32, 127), randint(32, 127), randint(32, 127)
 
     # Generate a 4 letter word
     def gen_wrong_answer():