PagerMaid_Plugins_Pyro/no_mentions/main.py

56 lines
2.0 KiB
Python
Raw Normal View History

from pyrogram.raw.functions.messages import ReadMentions
from pagermaid.enums import Client, Message
from pagermaid.listener import listener
2024-09-28 14:35:08 +00:00
from pagermaid.utils import lang, Sub
from pyromod import require_mod_version
no_mentions_sub = Sub("no_mentions")
2023-07-01 12:18:58 +00:00
@listener(
command="no_mentions",
description="自动消除某个对话的 @ 提醒",
parameters="[true|false|status]",
)
async def no_mentions(_: Client, message: Message):
if len(message.parameter) != 1:
await message.edit(f"[no_mentions] {lang('error_prefix')}{lang('arg_error')}")
return
status = message.parameter[0].lower()
if status == "true":
if no_mentions_sub.add_id(message.chat.id):
return await message.edit("[no_mentions] 成功在这个对话开启")
else:
return await message.edit("[no_mentions] 这个对话已经开启了")
elif status == "false":
if no_mentions_sub.del_id(message.chat.id):
return await message.edit("[no_mentions] 成功在这个对话关闭")
else:
return await message.edit("[no_mentions] 这个对话未开启")
elif message.parameter[0] == "status":
if no_mentions_sub.check_id(message.chat.id):
await message.edit("[no_mentions] 这个对话已经开启了")
else:
await message.edit("[no_mentions] 这个对话未开启")
else:
await message.edit(f"[no_mentions] {lang('error_prefix')}{lang('arg_error')}")
@listener(incoming=True, outgoing=False, ignore_edited=True)
@require_mod_version(2)
async def set_read_mentions(client: Client, message: Message):
if not no_mentions_sub.check_id(message.chat.id):
return
if not message.reply_to_message:
return
if not message.reply_to_message.outgoing:
return
await client.invoke(
ReadMentions(
peer=await client.resolve_peer(message.chat.id),
2024-02-04 07:56:06 +00:00
top_msg_id=message.message_thread_id if message.topic else None,
)
)