antiservice.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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,
  7. is_antiservice_on)
  8. __MODULE__ = "AntiService"
  9. __HELP__ = """
  10. Plugin to delete service messages in a chat!
  11. /antiservice [enable|disable]
  12. """
  13. @app.on_message(filters.command("antiservice") & ~filters.private)
  14. @adminsOnly("can_change_info")
  15. async def anti_service(_, message):
  16. if len(message.command) != 2:
  17. await message.reply_text("Usage: /antiservice [enable | disable]")
  18. return
  19. status = message.text.split(None, 1)[1].strip()
  20. status = status.lower()
  21. chat_id = message.chat.id
  22. if status == "enable":
  23. await antiservice_on(chat_id)
  24. await message.reply_text(
  25. "Enabled AntiService System. I will Delete Service Messages from Now on."
  26. )
  27. elif status == "disable":
  28. await antiservice_off(chat_id)
  29. await message.reply_text(
  30. "Disabled AntiService System. I won't Be Deleting Service Message from Now on."
  31. )
  32. else:
  33. await message.reply_text(
  34. "Unknown Suffix, Use /antiservice [enable|disable]"
  35. )
  36. @app.on_message(filters.service, group=11)
  37. async def delete_service(_, message):
  38. chat_id = message.chat.id
  39. try:
  40. if await is_antiservice_on(chat_id):
  41. await message.delete()
  42. return
  43. except Exception:
  44. pass