TheHamkerCat 5 лет назад
Родитель
Сommit
6e36ce7a4b

+ 6 - 4
sample_config.py

@@ -6,20 +6,22 @@ if HEROKU:
     API_ID = int(environ.get("API_ID", 6))
     API_HASH = environ.get("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
     SESSION_STRING = environ.get("SESSION_STRING", None)
-    MAIN_CHATS = int(environ.get("GBAN_LOG_GROUP_ID", None))
+    USERBOT_PREFIX = environ.get("USERBOT_PREFIX", None)
+    MAIN_CHATS = int(environ.get("MAIN_CHATS", None))
     SUDO_USERS_ID = list(int(x) for x in environ.get("SUDO_USERS_ID", "").split())
     LOG_GROUP_ID = int(environ.get("LOG_GROUP_ID", None))
-    GBAN_LOG_GROUP_ID = int(environ.get("MAIN_CHATS", None))
+    GBAN_LOG_GROUP_ID = int(environ.get("GBAN_LOG_GROUP_ID", None))
     FERNET_ENCRYPTION_KEY = environ.get("FERNET_ENCRYPTION_KEY", None)
     WELCOME_DELAY_KICK_SEC = int(environ.get("WELCOME_DELAY_KICK_SEC", None))
     MONGO_DB_URI = environ.get("MONGO_DB_URI", None)
     ARQ_API_BASE_URL = environ.get("ARQ_API_BASE_URL", None)
 
-if not HEROKU:
+else:
     BOT_TOKEN = "467677575:YZfaakjwd545dfg-N6JStihhuw5gQeZHntc"
     API_ID = 123456
     API_HASH = "dfxcgs5s12hdcxfgdfz"
-    PHONE_NUMBER = "+919425965543" # Need for Helper Userbot
+    USERBOT_PREFIX = "."
+    PHONE_NUMBER = "+916969696969" # Need for Helper Userbot
     MAIN_CHATS = [-100125431255]  # NOTE These are the chats where main functions of bot will work, like music downloading etc.
     SUDO_USERS_ID = [4543744343, 543214651351] # Sudo users have full access to everythin, don't trust anyone
     LOG_GROUP_ID = -100125431255

+ 15 - 22
wbb/__init__.py

@@ -1,3 +1,4 @@
+# flake8: noqa F405
 """
 MIT License
 
@@ -34,6 +35,8 @@ if is_config:
 else:
     from sample_config import *
 
+listen = listen
+USERBOT_PREFIX = USERBOT_PREFIX
 SUDOERS = SUDO_USERS_ID
 MAIN_CHATS = MAIN_CHATS
 GBAN_LOG_GROUP_ID = GBAN_LOG_GROUP_ID
@@ -43,29 +46,21 @@ LOG_GROUP_ID = LOG_GROUP_ID
 MOD_LOAD = []
 MOD_NOLOAD = []
 bot_start_time = time.time()
-mongo_client = MongoClient(MONGO_DB_URI)
-db = mongo_client.wbb
+
 
 if not HEROKU:
-    app2 = Client(
-        "userbot",
-        phone_number=PHONE_NUMBER,
-        api_id=API_ID,
-        api_hash=API_HASH
-    )
+    app2 = Client("userbot", phone_number=PHONE_NUMBER, api_id=API_ID, api_hash=API_HASH)
 else:
-    app2 = Client(
-        SESSION_STRING,
-        api_id=API_ID,
-        api_hash=API_HASH
-    )
-
-app = Client(
-    "wbb",
-    bot_token=BOT_TOKEN,
-    api_id=API_ID,
-    api_hash=API_HASH
-)
+    app2 = Client(SESSION_STRING, api_id=API_ID, api_hash=API_HASH)
+
+# Bot client
+app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
+# MongoDB client
+mongo_client = MongoClient(MONGO_DB_URI)
+db = mongo_client.wbb
+# ARQ client
+arq = ARQ(ARQ_API_BASE_URL)
+
 
 BOT_ID = 0
 BOT_NAME = ""
@@ -107,5 +102,3 @@ app.start()
 app2.start()
 get_info(app, app2)
 SUDOERS.append(USERBOT_ID)
-# ARQ client
-arq = ARQ(ARQ_API_BASE_URL)

+ 8 - 7
wbb/modules/alive.py

@@ -22,16 +22,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
 
-from wbb import app2, BOT_ID, SUDOERS
+from wbb import app2, BOT_ID, SUDOERS, USERBOT_PREFIX
 from pyrogram import filters
 
-@app2.on_message(filters.command("alive", prefixes=".") & filters.user(SUDOERS))
+
+@app2.on_message(filters.command("alive", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS))
 async def alive_command_func(_, message):
     await message.delete()
     results = await app2.get_inline_bot_results(BOT_ID, "alive")
     await app2.send_inline_bot_result(
-            message.chat.id,
-            results.query_id,
-            results.results[0].id,
-            hide_via=True
-            )
+        message.chat.id,
+        results.query_id,
+        results.results[0].id,
+        hide_via=True
+    )

+ 5 - 2
wbb/modules/chatbot.py

@@ -21,7 +21,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
-from wbb import app, app2, arq, BOT_ID, SUDOERS, USERBOT_ID, USERBOT_USERNAME
+from wbb import (
+    app, app2, arq, BOT_ID, SUDOERS, USERBOT_ID,
+    USERBOT_USERNAME, USERBOT_PREFIX
+)
 from wbb.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import chatbot_group
 from pyrogram import filters
@@ -90,7 +93,7 @@ async def chatbot_talk(_, message):
 """ FOR USERBOT """
 
 
-@app2.on_message(filters.command("chatbot", prefixes=".") & ~filters.edited & filters.user(SUDOERS))
+@app2.on_message(filters.command("chatbot", prefixes=USERBOT_PREFIX) & ~filters.edited & filters.user(SUDOERS))
 @capture_err
 async def chatbot_status_ubot(_, message):
     global active_chats_ubot

+ 5 - 5
wbb/modules/pmpermit.py

@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
 
-from wbb import app, app2, BOT_ID, USERBOT_ID, SUDOERS
+from wbb import app, app2, BOT_ID, USERBOT_ID, SUDOERS, USERBOT_PREFIX
 from pyrogram import filters
 from wbb.utils.dbfunctions import is_pmpermit_approved, approve_pmpermit, disapprove_pmpermit
 import asyncio
@@ -55,7 +55,7 @@ async def pmpermit_func(_, message):
             )
 
 
-@app2.on_message(filters.command("approve", prefixes=".") & filters.user(SUDOERS) & ~filters.via_bot)
+@app2.on_message(filters.command("approve", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS) & ~filters.via_bot)
 async def pm_approve(_, message):
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
@@ -70,7 +70,7 @@ async def pm_approve(_, message):
     await m.delete()
 
 
-@app2.on_message(filters.command("disapprove", prefixes=".") & filters.user(SUDOERS) & ~filters.via_bot)
+@app2.on_message(filters.command("disapprove", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS) & ~filters.via_bot)
 async def pm_disapprove(_, message):
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
@@ -89,7 +89,7 @@ async def pm_disapprove(_, message):
     await message.edit("User is disapproved to pm")
 
 
-@app2.on_message(filters.command("block", prefixes=".") & filters.user(SUDOERS) & ~filters.via_bot)
+@app2.on_message(filters.command("block", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS) & ~filters.via_bot)
 async def block_user_func(_, message):
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
@@ -99,7 +99,7 @@ async def block_user_func(_, message):
     await message.edit("Successfully blocked the user")
 
 
-@app2.on_message(filters.command("unblock", prefixes=".") & filters.user(SUDOERS) & ~filters.via_bot)
+@app2.on_message(filters.command("unblock", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS) & ~filters.via_bot)
 async def unblock_user_func(_, message):
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")

+ 1 - 2
wbb/modules/sudoers.py

@@ -29,7 +29,7 @@ import psutil
 import asyncio
 from sys import version as pyver
 from wbb import (
-    app, app2, SUDOERS, bot_start_time, BOT_ID,
+    app, SUDOERS, bot_start_time, BOT_ID,
     USERBOT_USERNAME, GBAN_LOG_GROUP_ID
 )
 from wbb.utils import formatter
@@ -265,7 +265,6 @@ async def broadcast_message(_, message):
 
 # Update
 
-@app2.on_message(filters.command("update", prefixes=".") & filters.user(SUDOERS))
 @app.on_message(filters.command("update") & filters.user(SUDOERS))
 async def update_restart(_, message):
     await message.reply_text(f'```{subprocess.check_output(["git", "pull"]).decode("UTF-8")}```')

+ 2 - 0
wbb/utils/formatter.py

@@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
+
+
 def get_readable_time(seconds: int) -> str:
     count = 0
     ping_time = ""

+ 32 - 31
wbb/utils/inlinefuncs.py

@@ -486,7 +486,6 @@ async def github_user_func(answers, text):
 
 
 async def github_repo_func(answers, text):
-    url = text
     text = text.replace("https://github.com/", "")
     text = text.replace("http://github.com/", "")
     if text[-1] == "/":
@@ -718,8 +717,9 @@ async def pastebin_func(answers, link):
                 InlineQueryResultArticle(
                     title="DOCUMENT TOO BIG",
                     description="Maximum supported size is 1MB",
-                    input_message_content=InputTextMessageContent("DOCUMENT TOO BIG")
-                    
+                    input_message_content=InputTextMessageContent(
+                        "DOCUMENT TOO BIG")
+
                 )
             )
             return answers
@@ -755,30 +755,30 @@ async def pmpermit_func(answers, user_id, victim):
     caption = f"Hi, I'm {USERBOT_NAME}, What are you here for?, You'll be blocked if you send more than 5 messages."
     buttons = InlineKeyboard(row_width=2)
     buttons.add(
-            InlineKeyboardButton(
-                text="To Scam You",
-                callback_data="pmpermit to_scam_you"
-                ),
-            InlineKeyboardButton(
-                text="For promotion",
-                callback_data="pmpermit to_scam_you"
-                ),
-            InlineKeyboardButton(
-                text="Approve me",
-                callback_data="pmpermit approve_me"
-                ),
-            InlineKeyboardButton(
-                text="Approve",
-                callback_data=f"pmpermit approve {victim}"
-                )
-            )
+        InlineKeyboardButton(
+            text="To Scam You",
+            callback_data="pmpermit to_scam_you"
+        ),
+        InlineKeyboardButton(
+            text="For promotion",
+            callback_data="pmpermit to_scam_you"
+        ),
+        InlineKeyboardButton(
+            text="Approve me",
+            callback_data="pmpermit approve_me"
+        ),
+        InlineKeyboardButton(
+            text="Approve",
+            callback_data=f"pmpermit approve {victim}"
+        )
+    )
     answers.append(
-            InlineQueryResultArticle(
-                title="do_not_click_here",
-                reply_markup=buttons,
-                input_message_content=InputTextMessageContent(caption)
-                )
-            )
+        InlineQueryResultArticle(
+            title="do_not_click_here",
+            reply_markup=buttons,
+            input_message_content=InputTextMessageContent(caption)
+        )
+    )
     return answers
 
 
@@ -789,9 +789,10 @@ async def ping_func(answers):
     t2 = time()
     ping = f"{str(round((t2 - t1), 2))} Seconds"
     answers.append(
-            InlineQueryResultArticle(
-                title=ping,
-                input_message_content=InputTextMessageContent(f"__**{ping}**__")
-                )
-            )
+        InlineQueryResultArticle(
+            title=ping,
+            input_message_content=InputTextMessageContent(
+                f"__**{ping}**__")
+        )
+    )
     return answers

+ 2 - 0
wbb/utils/json_prettify.py

@@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 """
+
+
 async def json_object_prettify(objecc):
     dicc = objecc.__dict__
     output = ""