소스 검색

Added .id in userbot

TheHamkerCat 5 년 전
부모
커밋
4a71a98e5d
3개의 변경된 파일과 34개의 추가작업 그리고 20개의 파일을 삭제
  1. 2 3
      wbb/core/filters.py
  2. 19 6
      wbb/modules/misc.py
  3. 13 11
      wbb/utils/constants.py

+ 2 - 3
wbb/core/filters.py

@@ -33,7 +33,7 @@ def url(_, __, message: Message) -> bool:
     # Can't use entities to check for url because
     # monospace removes url entity
 
-    # TODO Fix undetection of those urls which
+    # TODO Fix detection of those urls which
     # doesn't have schema, ex-facebook.com
 
     text = message.text or message.caption
@@ -50,8 +50,7 @@ async def admin(_, __, message: Message) -> bool:
             return False
         return True
     # Calling iter_chat_members again and again
-    # doesn't causes floodwaits, idk why, maybe it's
-    # cached or something, that's why using it.
+    # doesn't cause floodwait, that's why i'm using it here.
     return message.from_user.id in [
         member.user.id
         async for member in message._client.iter_chat_members(

+ 19 - 6
wbb/modules/misc.py

@@ -27,7 +27,7 @@ from asyncio import Lock
 
 from pyrogram import filters
 
-from wbb import app, arq
+from wbb import SUDOERS, USERBOT_PREFIX, app, app2, arq, eor
 from wbb.core.decorators.errors import capture_err
 from wbb.utils import random_line
 from wbb.utils.http import get
@@ -128,29 +128,42 @@ async def runs(_, message):
     await message.reply_text((await random_line("wbb/utils/runs.txt")))
 
 
+@app2.on_message(
+    filters.command("id", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS)
+)
 @app.on_message(filters.command("id"))
-async def getid(_, message):
+async def getid(client, message):
     chat = message.chat
     your_id = message.from_user.id
     message_id = message.message_id
     reply = message.reply_to_message
+
     text = f"**[Message ID:]({message.link})** `{message_id}`\n"
     text += f"**[Your ID:](tg://user?id={your_id})** `{your_id}`\n"
+
+    if not message.command:
+        message.command = message.text.split()
+
     if len(message.command) == 2:
         try:
             split = message.text.split(None, 1)[1].strip()
-            user_id = (await app.get_users(split)).id
+            user_id = (await client.get_users(split)).id
             text += f"**[User ID:](tg://user?id={user_id})** `{user_id}`\n"
         except Exception:
-            return await message.reply_text("This user doesn't exist.")
+            return await eor(message, text="This user doesn't exist.")
+
     text += f"**[Chat ID:](https://t.me/{chat.username})** `{chat.id}`\n\n"
     if not getattr(reply, "empty", True):
         text += (
             f"**[Replied Message ID:]({reply.link})** `{reply.message_id}`\n"
         )
         text += f"**[Replied User ID:](tg://user?id={reply.from_user.id})** `{reply.from_user.id}`"
-    await message.reply_text(
-        text, disable_web_page_preview=True, parse_mode="md"
+
+    await eor(
+        message,
+        text=text,
+        disable_web_page_preview=True,
+        parse_mode="md",
     )
 
 

+ 13 - 11
wbb/utils/constants.py

@@ -1,10 +1,9 @@
 # New file
 
-from wbb import app, BOT_USERNAME
-
 from pyrogram.filters import command, edited
-from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
+from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
 
+from wbb import BOT_USERNAME, app
 
 MARKDOWN = """
 Read the below text carefully to find out how formatting works!
@@ -42,17 +41,20 @@ NOTE: Fillings only works in greetings module.
 @app.on_message(command("markdownhelp") & ~edited)
 async def mkdwnhelp(_, m: Message):
     keyb = InlineKeyboardMarkup(
+        [
             [
-                [
-                    InlineKeyboardButton(
-                        text="Click Here!",
-                        url=f"http://t.me/{BOT_USERNAME}?start=mkdwn_help",
-                    )
-                ]
+                InlineKeyboardButton(
+                    text="Click Here!",
+                    url=f"http://t.me/{BOT_USERNAME}?start=mkdwn_help",
+                )
             ]
-        )
+        ]
+    )
     if m.chat.type != "private":
-        await m.reply("Click on the below button to get markdown usage syntax in pm!", reply_markup=keyb)
+        await m.reply(
+            "Click on the below button to get markdown usage syntax in pm!",
+            reply_markup=keyb,
+        )
     else:
         await m.reply(MARKDOWN, parse_mode="html")
     return