TheHamkerCat 5 лет назад
Родитель
Сommit
fbd5ae6ad9
6 измененных файлов с 139 добавлено и 45 удалено
  1. 10 8
      wbb/__init__.py
  2. 4 2
      wbb/modules/music.py
  3. 7 4
      wbb/modules/paste.py
  4. 71 0
      wbb/modules/taglogger.py
  5. 1 0
      wbb/utils/filter_groups.py
  6. 46 31
      wbb/utils/inlinefuncs.py

+ 10 - 8
wbb/__init__.py

@@ -119,18 +119,20 @@ def get_info(app, app2):
     getme2 = app2.get_me()
     getme2 = app2.get_me()
     BOT_ID = getme.id
     BOT_ID = getme.id
     USERBOT_ID = getme2.id
     USERBOT_ID = getme2.id
-    if getme.last_name:
-        BOT_NAME = getme.first_name + " " + getme.last_name
-    else:
-        BOT_NAME = getme.first_name
+    BOT_NAME = (
+        f"{getme.first_name} {getme.last_name}"
+        if getme.last_name
+        else getme.first_name
+    )
     BOT_USERNAME = getme.username
     BOT_USERNAME = getme.username
     BOT_MENTION = getme.mention
     BOT_MENTION = getme.mention
     BOT_DC_ID = getme.dc_id
     BOT_DC_ID = getme.dc_id
 
 
-    if getme2.last_name:
-        USERBOT_NAME = getme2.first_name + " " + getme2.last_name
-    else:
-        USERBOT_NAME = getme2.first_name
+    USERBOT_NAME = (
+        f"{getme2.first_name} {getme2.last_name}"
+        if getme2.last_name
+        else getme2.first_name
+    )
     USERBOT_USERNAME = getme2.username
     USERBOT_USERNAME = getme2.username
     USERBOT_MENTION = getme2.mention
     USERBOT_MENTION = getme2.mention
     USERBOT_DC_ID = getme2.dc_id
     USERBOT_DC_ID = getme2.dc_id

+ 4 - 2
wbb/modules/music.py

@@ -106,7 +106,9 @@ async def music(_, message):
     )
     )
     try:
     try:
         loop = get_running_loop()
         loop = get_running_loop()
-        music = await loop.run_in_executor(None, partial(download_youtube_audio, url, message))
+        music = await loop.run_in_executor(
+            None, partial(download_youtube_audio, url, message)
+        )
         if not music:
         if not music:
             await m.edit("Too Long, Can't Download.")
             await m.edit("Too Long, Can't Download.")
         (
         (
@@ -115,7 +117,7 @@ async def music(_, message):
             duration,
             duration,
             audio_file,
             audio_file,
             thumbnail_file,
             thumbnail_file,
-        ) = music 
+        ) = music
     except Exception as e:
     except Exception as e:
         is_downloading = False
         is_downloading = False
         await m.edit(str(e))
         await m.edit(str(e))

+ 7 - 4
wbb/modules/paste.py

@@ -21,17 +21,18 @@ 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.
 """
 """
-import aiohttp
-import aiofiles
 import asyncio
 import asyncio
 import os
 import os
 
 
+import aiofiles
+import aiohttp
 from pykeyboard import InlineKeyboard
 from pykeyboard import InlineKeyboard
 from pyrogram import filters
 from pyrogram import filters
 from pyrogram.errors.exceptions.bad_request_400 import WebpageCurlFailed
 from pyrogram.errors.exceptions.bad_request_400 import WebpageCurlFailed
 from pyrogram.types import InlineKeyboardButton
 from pyrogram.types import InlineKeyboardButton
 
 
-from wbb import aiohttpsession as session, app
+from wbb import aiohttpsession as session
+from wbb import app
 from wbb.core.decorators.errors import capture_err
 from wbb.core.decorators.errors import capture_err
 from wbb.utils.functions import get_http_status_code
 from wbb.utils.functions import get_http_status_code
 from wbb.utils.pastebin import paste
 from wbb.utils.pastebin import paste
@@ -81,7 +82,9 @@ async def paste_func(_, message):
         button.add(InlineKeyboardButton(text="Paste Link", url=link))
         button.add(InlineKeyboardButton(text="Paste Link", url=link))
 
 
         if await isPreviewUp(preview):
         if await isPreviewUp(preview):
-            await message.reply_photo(photo=preview, quote=False, reply_markup=button)
+            await message.reply_photo(
+                photo=preview, quote=False, reply_markup=button
+            )
             await m.delete()
             await m.delete()
             return
             return
         await m.edit(link)
         await m.edit(link)

+ 71 - 0
wbb/modules/taglogger.py

@@ -0,0 +1,71 @@
+from pykeyboard import InlineKeyboard
+from pyrogram import filters
+from pyrogram.types import InlineKeyboardButton, Message
+
+from wbb import (BOT_ID, LOG_GROUP_ID, USERBOT_ID, USERBOT_NAME,
+                 USERBOT_USERNAME, app, app2)
+from wbb.core.decorators.errors import capture_err
+from wbb.utils.filter_groups import taglog_group
+
+__MODULE__ = "Tag Logger"
+__HELP__ = """
+THIS MODULE IS ONLY FOR SUDOERS
+
+This module logs every action that contains your id, name, username, mention.
+"""
+
+IS_USERBOT_ONLINE = False
+
+
+@app2.on_user_status()
+async def statusUpdaterFunc(_, update):
+    if update.id != USERBOT_ID:
+        return
+    global IS_USERBOT_ONLINE
+    if update.status == "online":
+        IS_USERBOT_ONLINE = True
+        return
+    IS_USERBOT_ONLINE = False
+
+
+async def sendLog(message: Message):
+    msg = f"""
+「 ✨ TAG LOGGER 」
+
+**User:** {message.from_user.mention} [`{message.from_user.id if message.from_user else None}`]
+**Text:** {message.text if message.text else None}
+**Chat:** {message.chat.title} [`{message.chat.id}`]
+**Bot:** {message.from_user.is_bot}
+"""
+    button = InlineKeyboard(row_width=1)
+    button.add(InlineKeyboardButton(text="Check Action", url=message.link))
+    await app.send_message(LOG_GROUP_ID, text=msg, reply_markup=button)
+
+
+@app2.on_message(
+    ~filters.me & ~filters.chat([LOG_GROUP_ID, BOT_ID]), group=taglog_group
+)
+@capture_err
+async def tagLoggerFunc(_, message: Message):
+    if IS_USERBOT_ONLINE:
+        return
+    if message.reply_to_message:
+        reply_message = message.reply_to_message
+        if reply_message.from_user:
+            if reply_message.from_user.id == USERBOT_ID:
+                await sendLog(message)
+                return
+
+    if message.text:
+        text = message.text
+    elif message.caption:
+        text = message.caption
+    else:
+        return
+    if (
+        str(USERBOT_ID) in text
+        or str(USERBOT_USERNAME) in text
+        or USERBOT_NAME in text
+    ):
+        await sendLog(message)
+        return

+ 1 - 0
wbb/utils/filter_groups.py

@@ -31,3 +31,4 @@ antiflood_group = 7
 nsfw_detect_group = 8
 nsfw_detect_group = 8
 blacklist_filters_group = 9
 blacklist_filters_group = 9
 pipes_group = 10
 pipes_group = 10
+taglog_group = 11

+ 46 - 31
wbb/utils/inlinefuncs.py

@@ -36,25 +36,12 @@ from pykeyboard import InlineKeyboard
 from pyrogram import __version__ as pyrover
 from pyrogram import __version__ as pyrover
 from pyrogram import filters
 from pyrogram import filters
 from pyrogram.raw.functions import Ping
 from pyrogram.raw.functions import Ping
-from pyrogram.types import (
-    InlineKeyboardButton,
-    InlineQueryResultArticle,
-    InlineQueryResultPhoto,
-    InputTextMessageContent,
-)
+from pyrogram.types import (InlineKeyboardButton, InlineQueryResultArticle,
+                            InlineQueryResultPhoto, InputTextMessageContent)
 from search_engine_parser import GoogleSearch
 from search_engine_parser import GoogleSearch
 
 
-from wbb import (
-    BOT_USERNAME,
-    MESSAGE_DUMP_CHAT,
-    SUDOERS,
-    USERBOT_ID,
-    USERBOT_NAME,
-    USERBOT_USERNAME,
-    app,
-    app2,
-    arq,
-)
+from wbb import (BOT_USERNAME, MESSAGE_DUMP_CHAT, SUDOERS, USERBOT_ID,
+                 USERBOT_NAME, USERBOT_USERNAME, app, app2, arq)
 from wbb.core.types import InlineQueryResultCachedDocument
 from wbb.core.types import InlineQueryResultCachedDocument
 from wbb.modules.info import get_chat_info, get_user_info
 from wbb.modules.info import get_chat_info, get_user_info
 from wbb.modules.music import download_youtube_audio
 from wbb.modules.music import download_youtube_audio
@@ -131,7 +118,9 @@ async def alive_function(answers):
     ubot_state = "Dead" if not await app2.get_me() else "Alive"
     ubot_state = "Dead" if not await app2.get_me() else "Alive"
     buttons.add(
     buttons.add(
         InlineKeyboardButton("Stats", callback_data="stats_callback"),
         InlineKeyboardButton("Stats", callback_data="stats_callback"),
-        InlineKeyboardButton("Go Inline!", switch_inline_query_current_chat=""),
+        InlineKeyboardButton(
+            "Go Inline!", switch_inline_query_current_chat=""
+        ),
     )
     )
 
 
     msg = f"""
     msg = f"""
@@ -187,7 +176,9 @@ __**Translated from {result.src} to {result.dest}**__
             ),
             ),
             InlineQueryResultArticle(
             InlineQueryResultArticle(
                 title=result.translatedText,
                 title=result.translatedText,
-                input_message_content=InputTextMessageContent(result.translatedText),
+                input_message_content=InputTextMessageContent(
+                    result.translatedText
+                ),
             ),
             ),
         ]
         ]
     )
     )
@@ -445,7 +436,9 @@ async def youtube_func(answers, text):
 **Duration:** {i.duration}
 **Duration:** {i.duration}
 **Uploaded:** {i.publish_time}
 **Uploaded:** {i.publish_time}
 **Description:** {i.long_desc}"""
 **Description:** {i.long_desc}"""
-        description = f"{i.views} | {i.channel} | {i.duration} | {i.publish_time}"
+        description = (
+            f"{i.views} | {i.channel} | {i.duration} | {i.publish_time}"
+        )
         answers.append(
         answers.append(
             InlineQueryResultArticle(
             InlineQueryResultArticle(
                 title=i.title,
                 title=i.title,
@@ -496,7 +489,9 @@ async def github_user_func(answers, text):
     result = await fetch(URL)
     result = await fetch(URL)
     buttons = InlineKeyboard(row_width=1)
     buttons = InlineKeyboard(row_width=1)
     buttons.add(
     buttons.add(
-        InlineKeyboardButton(text="Open On Github", url=f"https://github.com/{text}")
+        InlineKeyboardButton(
+            text="Open On Github", url=f"https://github.com/{text}"
+        )
     )
     )
     caption = f"""
     caption = f"""
 **Info Of {result['name']}**
 **Info Of {result['name']}**
@@ -535,7 +530,9 @@ async def github_repo_func(answers, text):
         commits += developer["contributions"]
         commits += developer["contributions"]
     buttons = InlineKeyboard(row_width=1)
     buttons = InlineKeyboard(row_width=1)
     buttons.add(
     buttons.add(
-        InlineKeyboardButton("Open On Github", url=f"https://github.com/{text}")
+        InlineKeyboardButton(
+            "Open On Github", url=f"https://github.com/{text}"
+        )
     )
     )
     caption = f"""
     caption = f"""
 **Info Of {r['full_name']}**
 **Info Of {r['full_name']}**
@@ -599,7 +596,9 @@ async def tg_search_func(answers, text, user_id):
             ),
             ),
         )
         )
         name = (
         name = (
-            message.from_user.first_name if message.from_user.first_name else "NO NAME"
+            message.from_user.first_name
+            if message.from_user.first_name
+            else "NO NAME"
         )
         )
         caption = f"""
         caption = f"""
 **Query:** {text}
 **Query:** {text}
@@ -653,7 +652,9 @@ async def music_inline_func(answers, query):
                 "duration": f_.audio.duration if f_.audio.duration else 0,
                 "duration": f_.audio.duration if f_.audio.duration else 0,
             }
             }
         )
         )
-    messages = list({v["duration"]: v for v in messages_ids_and_duration}.values())
+    messages = list(
+        {v["duration"]: v for v in messages_ids_and_duration}.values()
+    )
     messages_ids = []
     messages_ids = []
     for ff_ in messages:
     for ff_ in messages:
         messages_ids.append(ff_["message_id"])
         messages_ids.append(ff_["message_id"])
@@ -710,7 +711,9 @@ async def speedtest_init(query):
         return answers
         return answers
     msg = "**Click The Button Below To Perform A Speedtest**"
     msg = "**Click The Button Below To Perform A Speedtest**"
     button = InlineKeyboard(row_width=1)
     button = InlineKeyboard(row_width=1)
-    button.add(InlineKeyboardButton(text="Test", callback_data="test_speedtest"))
+    button.add(
+        InlineKeyboardButton(text="Test", callback_data="test_speedtest")
+    )
     answers.append(
     answers.append(
         InlineQueryResultArticle(
         InlineQueryResultArticle(
             title="Click Here",
             title="Click Here",
@@ -761,7 +764,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
@@ -776,7 +781,9 @@ async def pastebin_func(answers, link):
     await app.send_photo(MESSAGE_DUMP_CHAT, preview)  # To Pre-cache the media
     await app.send_photo(MESSAGE_DUMP_CHAT, preview)  # To Pre-cache the media
     buttons = InlineKeyboard(row_width=1)
     buttons = InlineKeyboard(row_width=1)
     buttons.add(InlineKeyboardButton(text="Paste Link", url=link))
     buttons.add(InlineKeyboardButton(text="Paste Link", url=link))
-    answers.append(InlineQueryResultPhoto(photo_url=preview, reply_markup=buttons))
+    answers.append(
+        InlineQueryResultPhoto(photo_url=preview, reply_markup=buttons)
+    )
     return answers
     return answers
 
 
 
 
@@ -792,7 +799,9 @@ async def pmpermit_func(answers, user_id, victim):
         InlineKeyboardButton(
         InlineKeyboardButton(
             text="For promotion", callback_data="pmpermit to_scam_you a"
             text="For promotion", callback_data="pmpermit to_scam_you a"
         ),
         ),
-        InlineKeyboardButton(text="Approve me", callback_data="pmpermit approve_me a"),
+        InlineKeyboardButton(
+            text="Approve me", callback_data="pmpermit approve_me a"
+        ),
         InlineKeyboardButton(
         InlineKeyboardButton(
             text="Approve", callback_data=f"pmpermit approve {victim}"
             text="Approve", callback_data=f"pmpermit approve {victim}"
         ),
         ),
@@ -912,7 +921,9 @@ async def carbon_inline_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
@@ -999,7 +1010,9 @@ async def tmdb_func(answers, query):
         )
         )
         answers.append(
         answers.append(
             InlineQueryResultPhoto(
             InlineQueryResultPhoto(
-                photo_url=result.backdrop if result.backdrop else result.poster,
+                photo_url=result.backdrop
+                if result.backdrop
+                else result.poster,
                 caption=caption,
                 caption=caption,
                 title=result.title,
                 title=result.title,
                 description=f"{genre} • {result.releaseDate} • {result.rating} • {description}",
                 description=f"{genre} • {result.releaseDate} • {result.rating} • {description}",
@@ -1021,7 +1034,9 @@ async def pypiSearchFunc(answers: list, query: str) -> list:
         )
         )
         return answers
         return answers
     result = result.result
     result = result.result
-    pURLS = [f"**{key}**: {value}" for key, value in result.projectURLS.items()]
+    pURLS = [
+        f"**{key}**: {value}" for key, value in result.projectURLS.items()
+    ]
     pURLS = ("\n" + "\n".join(pURLS)) if pURLS else None
     pURLS = ("\n" + "\n".join(pURLS)) if pURLS else None
     caption = f"""
     caption = f"""
 **Name:** {result.name}
 **Name:** {result.name}