TheHamkerCat 5 yıl önce
ebeveyn
işleme
3c94ae2dca

+ 1 - 0
sample_config.py

@@ -1,6 +1,7 @@
 BOT_TOKEN = "1455:AAE4qFS3nF-0Tn"
 API_ID = 69
 API_HASH = "e46b6c854d2bf580"
+PHONE_NUMBER = "+910000000000" # Need for Helper Userbot
 OWNER_ID = 1243703097
 MAIN_CHATS = [-1001485393652]  # NOTE These are the chats where main functions of bot will work, like music downloading etc.
 SUDO_USER_ID = [51635132416, 1342121354245, 23452465243]

+ 14 - 3
wbb/__init__.py

@@ -1,7 +1,8 @@
 from config import (
     BOT_TOKEN, API_ID, API_HASH, OWNER_ID, SUDO_USER_ID,
     LOG_GROUP_ID, FERNET_ENCRYPTION_KEY, MONGO_DB_URI,
-    WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API
+    WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API,
+    PHONE_NUMBER
 )
 from pyrogram import Client
 from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
@@ -46,9 +47,19 @@ mongo_client = MongoClient(MONGO_DB_URI)
 db = mongo_client.wbb
 
 print("\nStarting Helper Userbot")
-app2 = Client("userbot", api_id=API_ID, api_hash=API_HASH)
+app2 = Client(
+    "userbot",
+    phone_number=PHONE_NUMBER,
+    api_id=API_ID,
+    api_hash=API_HASH
+)
 
 print("\nStarting Main Bot\n")
-app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
+app = Client(
+    "wbb",
+    bot_token=BOT_TOKEN,
+    api_id=API_ID,
+    api_hash=API_HASH
+)
 
 arq = ARQ(ARQ_API)

+ 1 - 1
wbb/modules/anime.py

@@ -35,6 +35,7 @@ initial_keyboard = InlineKeyboardMarkup(
 
 
 @app.on_message(filters.command("anime") & ~filters.edited)
+@capture_err
 async def anime_search(_, message):
     if len(message.command) < 2:
         await message.reply_text("**Usage:**\n/anime [Query]")
@@ -119,4 +120,3 @@ async def delete_callbacc(_, CallbackQuery):
     data = None
     DATA_LEN = 0
     await m.delete()
-

+ 3 - 3
wbb/modules/bay.py

@@ -3,7 +3,7 @@ import requests
 import aiohttp
 import aiofiles
 from wbb import app, OWNER_ID
-from pyrogram import Client, filters
+from pyrogram import filters
 from random import randint
 
 __MODULE__ = "BAYFILES"
@@ -20,7 +20,7 @@ async def url(_, message):
     lenk = message.text.split(None, 1)[1]
     try:
         filename = await download(lenk)
-        files = { 'file': open(filename, 'rb')}
+        files = {'file': open(filename, 'rb')}
         await m.edit("Uploading....")
         r = requests.post("https://api.bayfiles.com/upload", files=files)
         text = r.json()
@@ -49,7 +49,7 @@ async def tg(_, message):
     m = await message.reply_text("Downloading Document.")
     fn = await message.reply_to_message.download()
     try:
-        files = { 'file': open(fn, 'rb')}
+        files = {'file': open(fn, 'rb')}
         await m.edit("Uploading....")
         r = requests.post("https://api.bayfiles.com/upload", files=files)
         text = r.json()

+ 11 - 11
wbb/modules/couple.py

@@ -1,6 +1,6 @@
 from wbb import app
 from wbb.utils.errors import capture_err
-from wbb.utils.dbfunctions import _get_lovers, get_couple, save_couple
+from wbb.utils.dbfunctions import get_couple, save_couple
 from pyrogram import filters
 import random
 from datetime import datetime
@@ -22,6 +22,7 @@ def dt_tom():
         dt()[0].split('/')[1]+"/" + dt()[0].split('/')[2]
     return a
 
+
 today = str(dt()[0])
 tomorrow = str(dt_tom())
 
@@ -55,13 +56,13 @@ async def couple(_, message):
 
 __New couple of the day may be chosen at 12AM {tomorrow}__"""
             await app.send_message(
-                    message.chat.id,
-                    text=couple_selection_message
-                    )
+                message.chat.id,
+                text=couple_selection_message
+            )
             couple = {
-                    "c1_id": c1_id,
-                    "c2_id": c2_id
-                    }
+                "c1_id": c1_id,
+                "c2_id": c2_id
+            }
             await save_couple(chat_id, today, couple)
 
         elif is_selected:
@@ -74,10 +75,9 @@ __New couple of the day may be chosen at 12AM {tomorrow}__"""
 
 __New couple of the day may be chosen at 12AM {tomorrow}__"""
             await app.send_message(
-                    message.chat.id,
-                    text=couple_selection_message
-                    )
+                message.chat.id,
+                text=couple_selection_message
+            )
     except Exception as e:
         print(e)
         await message.reply_text(e)
-

+ 22 - 18
wbb/modules/karma.py

@@ -16,15 +16,17 @@ regex_upvote = r"^((?i)\+|\+\+|\+1|thx|tnx|ty|thank you|thanx|thanks|pro|cool|go
 regex_downvote = r"^(\-|\-\-|\-1|👎)$"
 
 
-@app.on_message(filters.text
-                & filters.group
-                & filters.incoming
-                & filters.reply
-                & filters.regex(regex_upvote)
-                & ~filters.via_bot
-                & ~filters.bot
-                & ~filters.edited,
-                group=karma_positive_group)
+@app.on_message(
+    filters.text
+    & filters.group
+    & filters.incoming
+    & filters.reply
+    & filters.regex(regex_upvote)
+    & ~filters.via_bot
+    & ~filters.bot
+    & ~filters.edited,
+    group=karma_positive_group
+)
 @capture_err
 async def upvote(_, message):
     if message.reply_to_message.from_user.id == message.from_user.id:
@@ -47,15 +49,17 @@ async def upvote(_, message):
     )
 
 
-@app.on_message(filters.text
-                & filters.group
-                & filters.incoming
-                & filters.reply
-                & filters.regex(regex_downvote)
-                & ~filters.via_bot
-                & ~filters.bot
-                & ~filters.edited,
-                group=karma_negative_group)
+@app.on_message(
+    filters.text
+    & filters.group
+    & filters.incoming
+    & filters.reply
+    & filters.regex(regex_downvote)
+    & ~filters.via_bot
+    & ~filters.bot
+    & ~filters.edited,
+    group=karma_negative_group
+)
 @capture_err
 async def downvote(_, message):
     if message.reply_to_message.from_user.id == message.from_user.id:

+ 4 - 3
wbb/modules/userbot.py

@@ -30,7 +30,7 @@ async def edit_or_reply(msg: Message, **kwargs):
 
 
 @app2.on_message(filters.user(OWNER_ID) & ~filters.forwarded &
-                ~filters.via_bot & filters.command("l","."))
+                 ~filters.via_bot & filters.command("l", "."))
 async def executor(client, message):
     try:
         cmd = message.text.split(" ", maxsplit=1)[1]
@@ -62,7 +62,8 @@ async def executor(client, message):
         evaluation = stdout
     else:
         evaluation = "Success"
-    final_output = (f"**INPUT:**\n```{cmd}```\n\n**OUTPUT**:\n```{evaluation.strip()}```")
+    final_output = (
+        f"**INPUT:**\n```{cmd}```\n\n**OUTPUT**:\n```{evaluation.strip()}```")
     if len(final_output) > 4096:
         filename = "output.txt"
         with open(filename, "w+", encoding="utf8") as out_file:
@@ -83,7 +84,7 @@ async def executor(client, message):
     filters.user(OWNER_ID)
     & ~filters.forwarded
     & ~filters.via_bot
-    & filters.command('sh',"."),
+    & filters.command('sh', "."),
 )
 async def shellrunner(client, message):
     if len(message.command) < 2:

+ 1 - 1
wbb/utils/botinfo.py

@@ -21,7 +21,7 @@ async def get_info(app, app2):
         BOT_NAME = getme.first_name
     BOT_USERNAME = getme.username
     BOT_DC_ID = getme.dc_id
-    
+
     if getme2.last_name:
         USERBOT_NAME = getme2.first_name + " " + getme2.last_name
     else:

+ 1 - 0
wbb/utils/dbfunctions.py

@@ -377,6 +377,7 @@ async def _get_lovers(chat_id: int):
         lovers = {}
     return lovers
 
+
 async def get_couple(chat_id: int, date: str):
     lovers = await _get_lovers(chat_id)
     if date in lovers: