antiservice.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Written By [MaskedVirus | swatv3nub] for William and Ryūga
  2. # Kang With Proper Credits
  3. from pyrogram import filters
  4. from wbb import app
  5. from wbb.core.decorators.permissions import adminsOnly
  6. from wbb.utils.dbfunctions import antiservice_off, antiservice_on, is_antiservice_on
  7. __MODULE__ = "AntiService"
  8. __HELP__ = """
  9. Plugin to delete service messages in a chat!
  10. /antiservice [enable|disable]
  11. """
  12. @app.on_message(filters.command("antiservice") & ~filters.private)
  13. @adminsOnly("can_change_info")
  14. async def anti_service(_, message):
  15. if len(message.command) != 2:
  16. return await message.reply_text("Usage: /antiservice [enable | disable]")
  17. status = message.text.split(None, 1)[1].strip()
  18. status = status.lower()
  19. chat_id = message.chat.id
  20. if status == "enable":
  21. await antiservice_on(chat_id)
  22. await message.reply_text(
  23. "Enabled AntiService System. I will Delete Service Messages from Now on."
  24. )
  25. elif status == "disable":
  26. await antiservice_off(chat_id)
  27. await message.reply_text(
  28. "Disabled AntiService System. I won't Be Deleting Service Message from Now on."
  29. )
  30. else:
  31. await message.reply_text("Unknown Suffix, Use /antiservice [enable|disable]")
  32. @app.on_message(filters.service, group=11)
  33. async def delete_service(_, message):
  34. chat_id = message.chat.id
  35. try:
  36. if await is_antiservice_on(chat_id):
  37. return await message.delete()
  38. except Exception:
  39. pass