taglogger.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. """
  2. MIT License
  3. Copyright (c) 2023 TheHamkerCat
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. """
  20. from pykeyboard import InlineKeyboard
  21. from pyrogram import filters
  22. from pyrogram.types import InlineKeyboardButton, Message
  23. from wbb import (
  24. BOT_ID,
  25. LOG_GROUP_ID,
  26. LOG_MENTIONS,
  27. USERBOT_ID,
  28. USERBOT_NAME,
  29. USERBOT_USERNAME,
  30. app,
  31. app2,
  32. )
  33. from wbb.core.decorators.errors import capture_err
  34. from wbb.utils.filter_groups import taglog_group
  35. IS_USERBOT_ONLINE = False
  36. @app2.on_user_status()
  37. async def statusUpdaterFunc(_, update):
  38. if update.id != USERBOT_ID:
  39. return
  40. global IS_USERBOT_ONLINE
  41. if update.status == "online":
  42. IS_USERBOT_ONLINE = True
  43. return
  44. IS_USERBOT_ONLINE = False
  45. async def sendLog(message: Message):
  46. msg = f"""
  47. **User:** {message.from_user.mention if message.from_user else None} [`{message.from_user.id if message.from_user else None}`]
  48. **Text:** {message.text.markdown if message.text else message.caption if message.caption else None}
  49. **Chat:** {message.chat.title} [`{message.chat.id}`]
  50. **Bot:** {message.from_user.is_bot}
  51. """
  52. button = InlineKeyboard(row_width=1)
  53. button.add(InlineKeyboardButton(text="Check Action", url=message.link))
  54. await app.send_message(
  55. LOG_GROUP_ID,
  56. text=msg,
  57. reply_markup=button,
  58. disable_web_page_preview=True,
  59. )
  60. @app2.on_message(
  61. ~filters.me & ~filters.chat([LOG_GROUP_ID, BOT_ID]) & ~filters.private,
  62. group=taglog_group,
  63. )
  64. @capture_err
  65. async def tagLoggerFunc(_, message: Message):
  66. if not LOG_MENTIONS:
  67. return
  68. if IS_USERBOT_ONLINE:
  69. return
  70. if message.reply_to_message:
  71. reply_message = message.reply_to_message
  72. if reply_message.from_user and (reply_message.from_user.id == USERBOT_ID):
  73. return await sendLog(message)
  74. if message.text:
  75. text = message.text
  76. elif message.caption:
  77. text = message.caption
  78. else:
  79. return
  80. if str(USERBOT_ID) in text or str(USERBOT_USERNAME) in text or USERBOT_NAME in text:
  81. await sendLog(message)