| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- # Written By [MaskedVirus | swatv3nub] for William and Ryūga
- # Kang With Proper Credits
- from pyrogram import filters
- from wbb import app
- from wbb.core.decorators.permissions import adminsOnly
- from wbb.utils.dbfunctions import (
- antiservice_off,
- antiservice_on,
- is_antiservice_on,
- )
- __MODULE__ = "服务消息清理"
- __HELP__ = """
- 自动删除成员加入、退出、置顶等群服务消息。
- /antiservice [开启|关闭]
- """
- @app.on_message(filters.command("antiservice") & ~filters.private)
- @adminsOnly("can_change_info")
- async def anti_service(_, message):
- if len(message.command) != 2:
- return await message.reply_text(
- "用法:/antiservice [开启|关闭]"
- )
- status = message.text.split(None, 1)[1].strip()
- status = status.lower()
- status = {
- "开启": "enable",
- "打开": "enable",
- "关闭": "disable",
- }.get(status, status)
- chat_id = message.chat.id
- if status == "enable":
- await antiservice_on(chat_id)
- await message.reply_text(
- "服务消息自动清理已开启。"
- )
- elif status == "disable":
- await antiservice_off(chat_id)
- await message.reply_text(
- "服务消息自动清理已关闭。"
- )
- else:
- await message.reply_text(
- "参数无效,用法:/antiservice [开启|关闭]"
- )
- @app.on_message(filters.service, group=11)
- async def delete_service(_, message):
- chat_id = message.chat.id
- try:
- if await is_antiservice_on(chat_id):
- return await message.delete()
- except Exception:
- pass
|