TheHamkerCat před 5 roky
rodič
revize
495964d358
5 změnil soubory, kde provedl 159 přidání a 65 odebrání
  1. 117 0
      wbb/modules/info.py
  2. 17 0
      wbb/modules/inline.py
  3. 4 4
      wbb/modules/misc.py
  4. 0 58
      wbb/modules/user_info.py
  5. 21 3
      wbb/utils/inlinefuncs.py

+ 117 - 0
wbb/modules/info.py

@@ -0,0 +1,117 @@
+from wbb import app, SUDOERS, spamwatch
+from pyrogram import filters
+from pyrogram.types import Message
+from wbb.core.decorators.errors import capture_err
+from wbb.utils.dbfunctions import is_gbanned_user, user_global_karma
+import os
+
+__MODULE__ = "Info"
+__HELP__ = """
+/info [USERNAME|ID] - Get info about a user.
+/chat_info [USERNAME|ID] - Get info about a chat.
+"""
+
+
+async def get_user_info(user):
+    user = await app.get_users(user)
+    user_id = user.id
+    username = user.username
+    first_name = user.first_name
+    mention = user.mention("Link")
+    status = user.status
+    dc_id = user.dc_id
+    photo_id = user.photo.big_file_id if user.photo else None
+    is_gbanned = await is_gbanned_user(user_id)
+    is_sudo = user_id in SUDOERS
+    karma = await user_global_karma(user_id)
+    banned_in_spamwatch = False if not spamwatch.get_ban(user_id) else True
+    caption = f"""
+**ID:** `{user_id}`
+**DC:** {dc_id}
+**Name:** {first_name}
+**Username:** {("@" + username) if username else None}
+**Permalink:** {mention}
+**Status:** {status}
+**Sudo:** {is_sudo}
+**Karma:** {karma}
+**Gbanned:** {is_gbanned}
+**Spamwatch Restricted:** {banned_in_spamwatch}
+"""
+    return [caption, photo_id]
+
+
+async def get_chat_info(chat):
+    chat = await app.get_chat(chat)
+    chat_id = chat.id
+    username = chat.username
+    title = chat.title
+    type = chat.type
+    is_scam = chat.is_scam
+    description = chat.description
+    members = chat.members_count
+    is_restricted = chat.is_restricted
+    link = f"[Link](t.me/{username})" if username else None
+    dc_id = chat.dc_id
+    photo_id = chat.photo.big_file_id if chat.photo else None
+    caption = f"""
+**ID:** `{chat_id}`
+**DC:** {dc_id}
+**Type:** {type}
+**Name:** {title}
+**Username:** {("@" + username) if username else None}
+**Permalink:** {link}
+**Members:** {members}
+**Scam:** {is_scam}
+**Restricted:** {is_restricted}
+**Description:** {description}
+"""
+    return [caption, photo_id]
+
+
+@app.on_message(filters.command("info"))
+@capture_err
+async def info_func(_, message: Message):
+    try:
+        if message.reply_to_message:
+            user = message.reply_to_message.from_user.id
+        elif not message.reply_to_message and len(message.command) == 1:
+            user = message.from_user.id
+        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)
+        if not photo_id:
+            await m.edit(info_caption, disable_web_page_preview=True)
+            return
+        photo = await app.download_media(photo_id)
+        await message.reply_photo(photo, caption=info_caption, quote=False)
+        await m.delete()
+        os.remove(photo)
+    except Exception as e:
+        await message.reply_text(str(e))
+        print(e)
+
+
+@app.on_message(filters.command("chat_info"))
+@capture_err
+async def chat_info_func(_, message: Message):
+    try:
+        if len(message.command) > 2:
+            await message.reply_text("**Usage:**/chat_info [USERNAME|ID]")
+            return
+        elif len(message.command) == 1:
+            chat = message.chat.id
+        elif len(message.command) == 2:
+            chat = message.text.split(None, 1)[1]
+        m = await message.reply_text("Processing")
+        info_caption, photo_id = await get_chat_info(chat)
+        if not photo_id:
+            await m.edit(info_caption, disable_web_page_preview=True)
+            return
+        photo = await app.download_media(photo_id)
+        await message.reply_photo(photo, caption=info_caption, quote=False)
+        await m.delete()
+        os.remove(photo)
+    except Exception as e:
+        await message.reply_text(e)
+        print(e)

+ 17 - 0
wbb/modules/inline.py

@@ -412,6 +412,23 @@ async def inline_query_handler(client, query):
                 results=answerss,
                 cache_time=2
             )
+
+        elif text.split()[0] == "chat_info":
+            if len(text.split()) < 2:
+                await client.answer_inline_query(
+                    query.id,
+                    results=answers,
+                    switch_pm_text='Chat Info | chat_info [USERNAME|ID]',
+                    switch_pm_parameter='inline',
+                )
+                return
+            tex = text.split()[1].strip()
+            answerss = await chat_info_inline_func(answers, tex)
+            await client.answer_inline_query(
+                query.id,
+                results=answerss,
+                cache_time=2
+            )
     except Exception as e:
         e = traceback.format_exc()
         print(e, " InLine")

+ 4 - 4
wbb/modules/misc.py

@@ -75,8 +75,8 @@ async def runs(_, message):
 async def getid(_, message):
     if len(message.command) == 2:
         id = (await app.get_users(message.text.split(None, 1)[1])).id
-        text = f"<b>ID:</b> {id}"
-        await message.reply_text(text)
+        text = f"**ID:** `{id}`"
+        await message.reply_text(text, parse_mode="html")
         return
     text_unping = "<b>Chat ID:</b>"
     if message.chat.username:
@@ -118,9 +118,9 @@ async def getid(_, message):
             text += f" <code>{reply.forward_from.id}</code>\n"
             text_unping += text
             text_ping += f'\n<b><a href="tg://user?id={reply.forward_from.id}">Forwarded User ID:</a></b> <code>{reply.forward_from.id}</code>\n'
-    reply = await message.reply_text(text_unping, disable_web_page_preview=True)
+    reply = await message.reply_text(text_unping, disable_web_page_preview=True, parse_mode="html")
     if text_unping != text_ping:
-        await reply.edit_text(text_ping, disable_web_page_preview=True)
+        await reply.edit_text(text_ping, disable_web_page_preview=True, parse_mode="html")
 
 # Random
 

+ 0 - 58
wbb/modules/user_info.py

@@ -1,58 +0,0 @@
-from wbb import app, SUDOERS, spamwatch
-from pyrogram import filters
-from wbb.utils.dbfunctions import is_gbanned_user, user_global_karma
-import os
-import traceback
-
-__MODULE__ = "Info"
-__HELP__ = "/info [USERNAME|ID] - Get info about a user."
-
-
-async def get_user_info(user):
-    user = await app.get_users(user)
-    user_id = user.id
-    username = user.username
-    first_name = user.first_name
-    mention = user.mention("Link")
-    status = user.status
-    dc_id = user.dc_id
-    photo_id = user.photo.big_file_id if user.photo else None
-    is_gbanned = await is_gbanned_user(user_id)
-    is_sudo = user_id in SUDOERS
-    karma = await user_global_karma(user_id)
-    banned_in_spamwatch = False if not spamwatch.get_ban(user_id) else True
-    caption = f"""
-**ID:** `{user_id}`
-**DC:** {dc_id}
-**Name:** {first_name}
-**Username:** {("@" + username) if username else None}
-**Permalink:** {mention}
-**Status:** {status}
-**Sudo:** {is_sudo}
-**Karma:** {karma}
-**Gbanned:** {is_gbanned}
-**Spamwatch Restricted:** {banned_in_spamwatch}
-"""
-    return [caption, photo_id]
-
-
-@app.on_message(filters.command("info"))
-async def info_func(_, message):
-    try:
-        if message.reply_to_message:
-            user = message.reply_to_message.from_user.id
-        elif not message.reply_to_message and len(message.command) == 1:
-            user = message.from_user.id
-        elif not message.reply_to_message and len(message.command) != 1:
-            user = message.text.split(None, 1)[1]
-        info_caption, photo_id = await get_user_info(user)
-        if not photo_id:
-            await app.send_message(message.chat.id, text=info_caption)
-            return
-        photo = await app.download_media(photo_id)
-        await app.send_photo(message.chat.id, photo=photo, caption=info_caption)
-        os.remove(photo)
-    except Exception as e:
-        await message.reply_text(str(e))
-        e = traceback.format_exc()
-        print(e)

+ 21 - 3
wbb/utils/inlinefuncs.py

@@ -43,7 +43,7 @@ from pyrogram import __version__ as pyrover, filters
 from time import time, ctime
 from random import randint
 from wbb.utils.fetch import fetch
-from wbb.modules.user_info import get_user_info
+from wbb.modules.info import get_user_info, get_chat_info
 from wbb.modules.music import download_youtube_audio
 from wbb.utils.functions import test_speedtest, get_http_status_code, make_carbon
 from wbb.utils.formatter import convert_seconds_to_minutes as time_convert
@@ -60,7 +60,8 @@ keywords_list = [
     "wall", "yt", "torrent", "lyrics", "wiki",
     "speedtest", "music", "saavn", "deezer",
     "gh_repo", "gh_user", "search", "paste",
-    "nsfw_scan", "ytmusic", "carbon", "info"
+    "nsfw_scan", "ytmusic", "carbon", "info",
+    "chat_info"
 ]
 
 
@@ -877,7 +878,24 @@ async def user_info_inline_func(answers, user):
     answers.append(
         InlineQueryResultArticle(
             title="Found User.",
-            input_message_content=InputTextMessageContent(caption)
+            input_message_content=InputTextMessageContent(
+                caption,
+                disable_web_page_preview=True
+            )
+        )
+    )
+    return answers
+
+
+async def chat_info_inline_func(answers, chat):
+    caption, photo_id = await get_chat_info(chat)
+    answers.append(
+        InlineQueryResultArticle(
+            title="Found Chat.",
+            input_message_content=InputTextMessageContent(
+                caption,
+                disable_web_page_preview=True
+            )
         )
     )
     return answers