antiservice.py 1.5 KB

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