mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-24 15:59:21 +00:00
xtaodada
fb5a3f5baf
All checks were successful
Github commit to telegram / build (push) Successful in 13s
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
from pyrogram.raw.functions.messages import ReadMentions
|
|
|
|
from pagermaid.enums import Client, Message
|
|
from pagermaid.listener import listener
|
|
from pagermaid.utils import lang, Sub
|
|
|
|
from pyromod import require_mod_version
|
|
|
|
no_mentions_sub = Sub("no_mentions")
|
|
|
|
|
|
@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),
|
|
top_msg_id=message.message_thread_id if message.topic else None,
|
|
)
|
|
)
|