fuckmessage 删除最近 200 条消息中包含指定关键字的消息。

This commit is contained in:
xtaodada 2021-07-28 17:53:59 +08:00
parent a968bfb0cc
commit cb5714addd
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 46 additions and 0 deletions

36
fuckmessage.py Normal file
View File

@ -0,0 +1,36 @@
""" Module to automate sticker deletion. """
from pagermaid import log
from pagermaid.listener import listener
from pagermaid.utils import alias_command, lang
@listener(is_plugin=True, outgoing=True, command=alias_command("fuckmessage"),
description="删除最近 200 条消息中包含指定关键字的消息。",
parameters="<关键词>")
async def fuck_message(context):
""" Deletes specific amount of messages in chat. """
if not context.arguments:
await context.edit(lang('arg_error'))
return
input_chat = await context.get_input_chat()
count_buffer = 0
count = 0
messages = []
async for message in context.client.iter_messages(context.chat_id):
if count_buffer == 200:
break
if context.arguments in message.text:
messages.append(message)
count += 1
if len(messages) > 50:
try:
await context.client.delete_messages(input_chat, messages)
except Exception as e:
await log(f'插件 fuckmessage 发生错误:\n{e}')
count_buffer += 1
text = f"删除了 {count} / {count_buffer} 条 消息 。"
try:
await context.client.delete_messages(input_chat, messages)
except Exception as e:
await log(f'插件 fuckmessage 发生错误:\n{e}')
await log(text)

View File

@ -649,6 +649,16 @@
"supported": true,
"des-short": "删除某人的消息并踢出/禁言",
"des": "回复你要删除消息和踢的人或者要禁言的人\n指令\n-kickanddm 直接删除消息并踢人\n-kickanddm 100 禁言100秒tg不支持60秒以下的时间少于60变成永久并删除最近999条消息\n⚠kickanddm 后面带时间的只是禁言,不带时间的直接踢。"
},
{
"name": "fuckmessage",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada",
"size": "1.3 kb",
"supported": true,
"des-short": "删除烦人的消息",
"des": "删除最近 200 条消息中包含指定关键字的消息。"
}
]
}