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. return await message.reply_text(
  18. "Usage: /antiservice [enable | disable]"
  19. )
  20. status = message.text.split(None, 1)[1].strip()
  21. status = status.lower()
  22. chat_id = message.chat.id
  23. if status == "enable":
  24. await antiservice_on(chat_id)
  25. await message.reply_text(
  26. "Enabled AntiService System. I will Delete Service Messages from Now on."
  27. )
  28. elif status == "disable":
  29. await antiservice_off(chat_id)
  30. await message.reply_text(
  31. "Disabled AntiService System. I won't Be Deleting Service Message from Now on."
  32. )
  33. else:
  34. await message.reply_text(
  35. "Unknown Suffix, Use /antiservice [enable|disable]"
  36. )
  37. @app.on_message(filters.service, group=11)
  38. async def delete_service(_, message):
  39. chat_id = message.chat.id
  40. try:
  41. if await is_antiservice_on(chat_id):
  42. return await message.delete()
  43. except Exception:
  44. pass