taglogger.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from pykeyboard import InlineKeyboard
  2. from pyrogram import filters
  3. from pyrogram.types import InlineKeyboardButton, Message
  4. from wbb import (BOT_ID, LOG_GROUP_ID, LOG_MENTIONS, USERBOT_ID,
  5. USERBOT_NAME, USERBOT_USERNAME, app, app2)
  6. from wbb.core.decorators.errors import capture_err
  7. from wbb.utils.filter_groups import taglog_group
  8. __MODULE__ = "Tag Logger"
  9. __HELP__ = """
  10. THIS MODULE IS ONLY FOR SUDOERS
  11. This module logs every action that contains your id, name, username, mention.
  12. """
  13. IS_USERBOT_ONLINE = False
  14. @app2.on_user_status()
  15. async def statusUpdaterFunc(_, update):
  16. if update.id != USERBOT_ID:
  17. return
  18. global IS_USERBOT_ONLINE
  19. if update.status == "online":
  20. IS_USERBOT_ONLINE = True
  21. return
  22. IS_USERBOT_ONLINE = False
  23. async def sendLog(message: Message):
  24. msg = f"""
  25. 「 ✨ TAG LOGGER 」
  26. **User:** {message.from_user.mention} [`{message.from_user.id if message.from_user else None}`]
  27. **Text:** {message.text if message.text else None}
  28. **Chat:** {message.chat.title} [`{message.chat.id}`]
  29. **Bot:** {message.from_user.is_bot}
  30. """
  31. button = InlineKeyboard(row_width=1)
  32. button.add(InlineKeyboardButton(text="Check Action", url=message.link))
  33. await app.send_message(LOG_GROUP_ID, text=msg, reply_markup=button)
  34. @app2.on_message(
  35. ~filters.me & ~filters.chat([LOG_GROUP_ID, BOT_ID]), group=taglog_group
  36. )
  37. @capture_err
  38. async def tagLoggerFunc(_, message: Message):
  39. if not LOG_MENTIONS:
  40. return
  41. if IS_USERBOT_ONLINE:
  42. return
  43. if message.reply_to_message:
  44. reply_message = message.reply_to_message
  45. if reply_message.from_user:
  46. if reply_message.from_user.id == USERBOT_ID:
  47. await sendLog(message)
  48. return
  49. if message.text:
  50. text = message.text
  51. elif message.caption:
  52. text = message.caption
  53. else:
  54. return
  55. if (
  56. str(USERBOT_ID) in text
  57. or str(USERBOT_USERNAME) in text
  58. or USERBOT_NAME in text
  59. ):
  60. await sendLog(message)
  61. return