antiservice.py 1.5 KB

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