mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 07:47:39 +00:00
repeat 自动复读(无引用)一个人的消息。
This commit is contained in:
parent
2525ac4481
commit
38a7e041dd
10
list.json
10
list.json
@ -629,6 +629,16 @@
|
||||
"supported": true,
|
||||
"des-short": "强制加入频道讨论群。",
|
||||
"des": "自动删除未加入频道讨论群用户的发言。命令:forcegroup 。"
|
||||
},
|
||||
{
|
||||
"name": "repeat",
|
||||
"version": "1.0",
|
||||
"section": "chat",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "1.8 kb",
|
||||
"supported": true,
|
||||
"des-short": "自动复读(无引用)一个人的消息。",
|
||||
"des": "自动复读(无引用)一个人的消息。命令:repeat 。"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
45
repeat.py
Normal file
45
repeat.py
Normal file
@ -0,0 +1,45 @@
|
||||
from pagermaid import redis, redis_status, log
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command=alias_command("repeat"),
|
||||
description='自动复读(无引用)一个人的消息。',
|
||||
parameters="<[reply]|status>")
|
||||
async def repeat(context):
|
||||
if not context.is_group:
|
||||
await context.edit('请在群组中运行。')
|
||||
return
|
||||
if not redis_status():
|
||||
await context.edit('出错了呜呜呜 ~ Redis 数据库离线。')
|
||||
return
|
||||
reply = await context.get_reply_message()
|
||||
if not reply or not reply.sender:
|
||||
await context.edit('请回复一个用户。')
|
||||
return
|
||||
uid = reply.sender_id
|
||||
if len(context.parameter) == 1:
|
||||
if redis.get(f'repeat_{context.chat_id}_{uid}'):
|
||||
await context.edit('此用户存在于自动复读列表。')
|
||||
else:
|
||||
await context.edit('此用户不存在于自动复读列表。')
|
||||
return
|
||||
if redis.get(f'repeat_{context.chat_id}_{uid}'):
|
||||
redis.delete(f'repeat_{context.chat_id}_{uid}')
|
||||
await context.edit('从自动复读列表移除成功。')
|
||||
else:
|
||||
redis.set(f'repeat_{context.chat_id}_{uid}', 'true')
|
||||
await context.edit('添加到自动复读列表成功。')
|
||||
|
||||
|
||||
@listener(is_plugin=True, incoming=True, ignore_edited=True)
|
||||
async def repeat_msg(context):
|
||||
""" Event handler. """
|
||||
if not redis_status():
|
||||
return
|
||||
if redis.get(f'repeat_{context.chat_id}_{context.sender_id}'):
|
||||
try:
|
||||
msg = await context.client.get_messages(context.chat_id, ids=context.id)
|
||||
return await context.client.send_message(context.chat_id, msg)
|
||||
except Exception as e:
|
||||
await log(f'Repeat Error:\n{e}')
|
Loading…
Reference in New Issue
Block a user