فهرست منبع

Userbot prefix

TheHamkerCat 5 سال پیش
والد
کامیت
6e36ce7a4b
9فایلهای تغییر یافته به همراه76 افزوده شده و 73 حذف شده
  1. 6 4
      sample_config.py
  2. 15 22
      wbb/__init__.py
  3. 8 7
      wbb/modules/alive.py
  4. 5 2
      wbb/modules/chatbot.py
  5. 5 5
      wbb/modules/pmpermit.py
  6. 1 2
      wbb/modules/sudoers.py
  7. 2 0
      wbb/utils/formatter.py
  8. 32 31
      wbb/utils/inlinefuncs.py
  9. 2 0
      wbb/utils/json_prettify.py

+ 6 - 4
sample_config.py

@@ -6,20 +6,22 @@ if HEROKU:
     API_ID = int(environ.get("API_ID", 6))
     API_ID = int(environ.get("API_ID", 6))
     API_HASH = environ.get("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
     API_HASH = environ.get("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
     SESSION_STRING = environ.get("SESSION_STRING", None)
     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())
     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))
     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)
     FERNET_ENCRYPTION_KEY = environ.get("FERNET_ENCRYPTION_KEY", None)
     WELCOME_DELAY_KICK_SEC = int(environ.get("WELCOME_DELAY_KICK_SEC", None))
     WELCOME_DELAY_KICK_SEC = int(environ.get("WELCOME_DELAY_KICK_SEC", None))
     MONGO_DB_URI = environ.get("MONGO_DB_URI", None)
     MONGO_DB_URI = environ.get("MONGO_DB_URI", None)
     ARQ_API_BASE_URL = environ.get("ARQ_API_BASE_URL", None)
     ARQ_API_BASE_URL = environ.get("ARQ_API_BASE_URL", None)
 
 
-if not HEROKU:
+else:
     BOT_TOKEN = "467677575:YZfaakjwd545dfg-N6JStihhuw5gQeZHntc"
     BOT_TOKEN = "467677575:YZfaakjwd545dfg-N6JStihhuw5gQeZHntc"
     API_ID = 123456
     API_ID = 123456
     API_HASH = "dfxcgs5s12hdcxfgdfz"
     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.
     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
     SUDO_USERS_ID = [4543744343, 543214651351] # Sudo users have full access to everythin, don't trust anyone
     LOG_GROUP_ID = -100125431255
     LOG_GROUP_ID = -100125431255

+ 15 - 22
wbb/__init__.py

@@ -1,3 +1,4 @@
+# flake8: noqa F405
 """
 """
 MIT License
 MIT License
 
 
@@ -34,6 +35,8 @@ if is_config:
 else:
 else:
     from sample_config import *
     from sample_config import *
 
 
+listen = listen
+USERBOT_PREFIX = USERBOT_PREFIX
 SUDOERS = SUDO_USERS_ID
 SUDOERS = SUDO_USERS_ID
 MAIN_CHATS = MAIN_CHATS
 MAIN_CHATS = MAIN_CHATS
 GBAN_LOG_GROUP_ID = GBAN_LOG_GROUP_ID
 GBAN_LOG_GROUP_ID = GBAN_LOG_GROUP_ID
@@ -43,29 +46,21 @@ LOG_GROUP_ID = LOG_GROUP_ID
 MOD_LOAD = []
 MOD_LOAD = []
 MOD_NOLOAD = []
 MOD_NOLOAD = []
 bot_start_time = time.time()
 bot_start_time = time.time()
-mongo_client = MongoClient(MONGO_DB_URI)
-db = mongo_client.wbb
+
 
 
 if not HEROKU:
 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:
 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_ID = 0
 BOT_NAME = ""
 BOT_NAME = ""
@@ -107,5 +102,3 @@ app.start()
 app2.start()
 app2.start()
 get_info(app, app2)
 get_info(app, app2)
 SUDOERS.append(USERBOT_ID)
 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.
 SOFTWARE.
 """
 """
 
 
-from wbb import app2, BOT_ID, SUDOERS
+from wbb import app2, BOT_ID, SUDOERS, USERBOT_PREFIX
 from pyrogram import filters
 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):
 async def alive_command_func(_, message):
     await message.delete()
     await message.delete()
     results = await app2.get_inline_bot_results(BOT_ID, "alive")
     results = await app2.get_inline_bot_results(BOT_ID, "alive")
     await app2.send_inline_bot_result(
     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
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 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.core.decorators.errors import capture_err
 from wbb.utils.filter_groups import chatbot_group
 from wbb.utils.filter_groups import chatbot_group
 from pyrogram import filters
 from pyrogram import filters
@@ -90,7 +93,7 @@ async def chatbot_talk(_, message):
 """ FOR USERBOT """
 """ 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
 @capture_err
 async def chatbot_status_ubot(_, message):
 async def chatbot_status_ubot(_, message):
     global active_chats_ubot
     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.
 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 pyrogram import filters
 from wbb.utils.dbfunctions import is_pmpermit_approved, approve_pmpermit, disapprove_pmpermit
 from wbb.utils.dbfunctions import is_pmpermit_approved, approve_pmpermit, disapprove_pmpermit
 import asyncio
 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):
 async def pm_approve(_, message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
         await message.edit("Reply to a user's message to approve.")
@@ -70,7 +70,7 @@ async def pm_approve(_, message):
     await m.delete()
     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):
 async def pm_disapprove(_, message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
         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")
     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):
 async def block_user_func(_, message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
         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")
     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):
 async def unblock_user_func(_, message):
     if not message.reply_to_message:
     if not message.reply_to_message:
         await message.edit("Reply to a user's message to approve.")
         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
 import asyncio
 from sys import version as pyver
 from sys import version as pyver
 from wbb import (
 from wbb import (
-    app, app2, SUDOERS, bot_start_time, BOT_ID,
+    app, SUDOERS, bot_start_time, BOT_ID,
     USERBOT_USERNAME, GBAN_LOG_GROUP_ID
     USERBOT_USERNAME, GBAN_LOG_GROUP_ID
 )
 )
 from wbb.utils import formatter
 from wbb.utils import formatter
@@ -265,7 +265,6 @@ async def broadcast_message(_, message):
 
 
 # Update
 # Update
 
 
-@app2.on_message(filters.command("update", prefixes=".") & filters.user(SUDOERS))
 @app.on_message(filters.command("update") & filters.user(SUDOERS))
 @app.on_message(filters.command("update") & filters.user(SUDOERS))
 async def update_restart(_, message):
 async def update_restart(_, message):
     await message.reply_text(f'```{subprocess.check_output(["git", "pull"]).decode("UTF-8")}```')
     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
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 SOFTWARE.
 """
 """
+
+
 def get_readable_time(seconds: int) -> str:
 def get_readable_time(seconds: int) -> str:
     count = 0
     count = 0
     ping_time = ""
     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):
 async def github_repo_func(answers, text):
-    url = text
     text = text.replace("https://github.com/", "")
     text = text.replace("https://github.com/", "")
     text = text.replace("http://github.com/", "")
     text = text.replace("http://github.com/", "")
     if text[-1] == "/":
     if text[-1] == "/":
@@ -718,8 +717,9 @@ async def pastebin_func(answers, link):
                 InlineQueryResultArticle(
                 InlineQueryResultArticle(
                     title="DOCUMENT TOO BIG",
                     title="DOCUMENT TOO BIG",
                     description="Maximum supported size is 1MB",
                     description="Maximum supported size is 1MB",
-                    input_message_content=InputTextMessageContent("DOCUMENT TOO BIG")
-                    
+                    input_message_content=InputTextMessageContent(
+                        "DOCUMENT TOO BIG")
+
                 )
                 )
             )
             )
             return answers
             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."
     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 = InlineKeyboard(row_width=2)
     buttons.add(
     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(
     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
     return answers
 
 
 
 
@@ -789,9 +789,10 @@ async def ping_func(answers):
     t2 = time()
     t2 = time()
     ping = f"{str(round((t2 - t1), 2))} Seconds"
     ping = f"{str(round((t2 - t1), 2))} Seconds"
     answers.append(
     answers.append(
-            InlineQueryResultArticle(
-                title=ping,
-                input_message_content=InputTextMessageContent(f"__**{ping}**__")
-                )
-            )
+        InlineQueryResultArticle(
+            title=ping,
+            input_message_content=InputTextMessageContent(
+                f"__**{ping}**__")
+        )
+    )
     return answers
     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
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 SOFTWARE.
 """
 """
+
+
 async def json_object_prettify(objecc):
 async def json_object_prettify(objecc):
     dicc = objecc.__dict__
     dicc = objecc.__dict__
     output = ""
     output = ""