thehamkercat 5 anni fa
parent
commit
9b81d66433

+ 1 - 1
README.md

@@ -23,7 +23,7 @@
 
 ## Requirements
 
-- Python >= 3.7
+- Python >= 3.9
 - A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).
 - A [Telegram bot token](https://t.me/botfather).
 - A [MongoDB URI](https://telegra.ph/How-To-get-Mongodb-URI-04-06)

+ 1 - 1
requirements.txt

@@ -11,7 +11,7 @@ pillow
 psutil
 pykeyboard
 pyrogram
-pyromod
+git+git://github.com/TheHamkerCat/pyromod
 python-arq
 requests
 search_engine_parser

+ 24 - 3
wbb/__init__.py

@@ -24,6 +24,7 @@ SOFTWARE.
 """
 print("[INFO]: INITIALIZING")
 import asyncio
+import logging
 import time
 from os import path
 
@@ -33,7 +34,24 @@ from pyrogram import Client
 from pyromod import listen
 from Python_ARQ import ARQ
 
+# Setup logging
+log_file = "error.log"
+
+with open(log_file, "w") as f:
+    f.write("PEAK OF LOG FILE")
+logging.basicConfig(
+    level=logging.ERROR,
+    format="[%(asctime)s.%(msecs)03d] %(filename)s:%(lineno)s %(levelname)s: %(message)s",
+    datefmt="%m-%d %H:%M",
+    filename=log_file,
+    filemode="w",
+)
+console = logging.StreamHandler()
+logging.getLogger("").addHandler(console)
+log = logging.getLogger()
+
 is_config = path.exists("config.py")
+
 if is_config:
     from config import *
 else:
@@ -84,15 +102,17 @@ else:
     print("[INFO]: INITIALIZING USERBOT CLIENT")
     app2 = Client(SESSION_STRING, api_id=API_ID, api_hash=API_HASH)
 
-# Bot client
-print("[INFO]: INITIALIZING BOT CLIENT")
-app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
 # Aiohttp Client
 print("[INFO]: INITIALZING AIOHTTP SESSION")
 aiohttpsession = ClientSession()
 # ARQ Client
 print("[INFO]: INITIALIZING ARQ CLIENT")
 arq = ARQ(ARQ_API_URL, ARQ_API_KEY, aiohttpsession)
+listen.listen.PyroARQ(arq)
+# Bot client
+print("[INFO]: INITIALIZING BOT CLIENT")
+app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
+
 
 BOT_ID = 0
 BOT_NAME = ""
@@ -132,6 +152,7 @@ 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()

+ 2 - 1
wbb/modules/__init__.py

@@ -26,7 +26,7 @@ import importlib
 import sys
 from os.path import basename, dirname, isfile
 
-from wbb import MOD_LOAD, MOD_NOLOAD
+from wbb import MOD_LOAD, MOD_NOLOAD, log
 
 
 def __list_all_modules():
@@ -49,6 +49,7 @@ def __list_all_modules():
                 any(mod == module_name for module_name in all_modules)
                 for mod in to_load
             ):
+                log.error("Invalid Module name!")
                 sys.exit()
 
         else:

+ 3 - 2
wbb/modules/flood.py

@@ -35,8 +35,9 @@ from wbb.utils.filter_groups import flood_group
 
 __MODULE__ = "Flood"
 __HELP__ = """
-Anti-Flood system, the one who sends more than 7 messages in a row, gets muted for an hour.
-Except for admins ofc, and no, you can't change the number of messages or action type.
+Anti-Flood system, the one who sends more than 7 messages in a row, gets muted for an hour (Except for admins).
+
+And no, you can't change the number of messages or action type.
 """
 
 

+ 2 - 2
wbb/modules/images.py

@@ -32,8 +32,8 @@ from wbb.core.decorators.errors import capture_err
 
 __MODULE__ = "Images"
 __HELP__ = """/cat  - Get Cute Cats Images
-For more images like wallpapers, use inline mode.
-send /inline for inline help."""
+For more images search like wallpapers etc, use inline mode.
+"""
 
 
 async def delete_message_with_delay(delay, message):

+ 4 - 1
wbb/modules/info.py

@@ -124,7 +124,10 @@ async def info_func(_, message: Message):
     elif not message.reply_to_message and len(message.command) != 1:
         user = message.text.split(None, 1)[1]
     m = await message.reply_text("Processing")
-    info_caption, photo_id = await get_user_info(user)
+    try:
+        info_caption, photo_id = await get_user_info(user)
+    except Exception as e:
+        return await m.edit(str(e))
     if not photo_id:
         return await m.edit(info_caption, disable_web_page_preview=True)
     photo = await app.download_media(photo_id)

+ 41 - 0
wbb/modules/log.py

@@ -0,0 +1,41 @@
+from datetime import datetime
+
+import aiofiles
+from pyrogram import filters
+from pyrogram.types import CallbackQuery, Message
+from pyromod.helpers import ikb
+
+from wbb import SUDOERS, app, log_file
+from wbb.utils.pastebin import paste
+
+callback = "log_paste"
+
+
+@app.on_message(filters.command("logs") & filters.user(SUDOERS))
+async def logs_chat(_, message):
+    keyboard = ikb([[("📎   Pastebin   📎", callback)]])
+    time = (datetime.now()).strftime("%d/%m/%Y %H:%M:%S")
+    caption = f"""
+**Time:** {time}
+**Log Type:** ERROR
+"""
+    try:
+        await message.reply_document(
+            log_file, caption=caption, reply_markup=keyboard
+        )
+    except ValueError:
+        await message.reply_text("**LOGS ARE EMPTY**")
+
+
+@app.on_callback_query(filters.regex(callback))
+async def paste_log_neko(_, cq: CallbackQuery):
+    if cq.from_user.id not in SUDOERS:
+        return await cq.answer(
+            "Stop clicking at whatever thing you come across."
+        )
+    async with aiofiles.open(log_file, mode="r") as f:
+        link = await paste(await f.read())
+    message: Message = cq.message
+    return await message.edit_caption(
+        f"{message.caption.markdown}\n**Paste:** {link}"
+    )

+ 4 - 6
wbb/modules/spam.py

@@ -32,21 +32,19 @@ from wbb.utils.filter_groups import spam_protection_group
 
 __MODULE__ = "AntiSpam"
 __HELP__ = """
-**Antispam helps from protect your group from spam.**
+**Antispam helps protect your group from spam.**
 
-- It's still new so it might be a bit less accurate.
-
-- You can enable or disable it according to your needs.
+- It's still new so it might be a bit inaccurate.
 
 - Currently, it only alerts for spam and gives you a button to delete the message,
   but in the future, it will delete the spam message automatically.
 
 **Commands:**
-    - /spam_protection [ENABLE|DISABLE]
-        To enable or disable this service.
     - /spam
         To mark a message as spam, this will help devs to 
         improve spam protection algorithm.
+
+As of now, you cannot turn this off, but we'll add an enable/disable command in the future
 """
 
 

+ 0 - 7
wbb/modules/taglogger.py

@@ -30,13 +30,6 @@ from wbb import (BOT_ID, LOG_GROUP_ID, LOG_MENTIONS, USERBOT_ID, USERBOT_NAME,
 from wbb.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import taglog_group
 
-__MODULE__ = "Tag Logger"
-__HELP__ = """
-THIS MODULE IS ONLY FOR SUDOERS
-
-This module logs every action that contains your id, name, username, mention.
-"""
-
 IS_USERBOT_ONLINE = False