From a332857e4853f9d17dd729fe8a7f30b580f2efac Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 5 Jul 2021 23:10:05 +0800 Subject: [PATCH] =?UTF-8?q?fucksticker=20=E5=88=A0=E9=99=A4=E7=83=A6?= =?UTF-8?q?=E4=BA=BA=E7=9A=84=E8=B4=B4=E7=BA=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fucksticker.py | 34 ++++++++++++++++++++++++++++++++++ list.json | 10 ++++++++++ 2 files changed, 44 insertions(+) create mode 100644 fucksticker.py diff --git a/fucksticker.py b/fucksticker.py new file mode 100644 index 0000000..190b316 --- /dev/null +++ b/fucksticker.py @@ -0,0 +1,34 @@ +""" Module to automate sticker deletion. """ +from asyncio import sleep +from pagermaid import log +from pagermaid.listener import listener +from pagermaid.utils import alias_command + + +@listener(is_plugin=True, outgoing=True, command=alias_command("fucksticker"), + description="删除最近 50 条消息中的 sticker 。" + "无管理员权限将只删除自己发送的 sticker 。") +async def fucksticker(context): + """ Deletes specific amount of stickers in chat. """ + 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 == 50: + break + if message.sticker: + count += 1 + messages.append(message) + else: + pass + count_buffer += 1 + text = f"删除了 {count} / {count_buffer} 条 sticker 。" + try: + await context.client.delete_messages(input_chat, messages) + except Exception as e: + text = f"删除了 {count_buffer} 条消息中的 sticker 。" + await log(f'插件 fucksticker 发生错误:\n{e}') + await context.edit(text) + await sleep(1) + await context.delete() diff --git a/list.json b/list.json index 5e08483..bd951a3 100644 --- a/list.json +++ b/list.json @@ -539,6 +539,16 @@ "supported": true, "des-short": "贴纸包批量导出", "des": "可选 pypi 前置 lottie[gif] 。" + }, + { + "name": "fucksticker", + "version": "1.0", + "section": "chat", + "maintainer": "xtaodada", + "size": "1.14 kb", + "supported": true, + "des-short": "删除烦人的贴纸", + "des": "删除最近 50 条消息中的 sticker 。" } ] }