antiservice.py 1.5 KB

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