events系统大体完成

This commit is contained in:
UnCLAS-Prommer
2025-09-17 16:17:35 +08:00
parent 1260a11b78
commit 88eb5cd40d
3 changed files with 57 additions and 2 deletions

View File

@@ -151,7 +151,7 @@ class PrintMessage(BaseEventHandler):
class ForwardMessages(BaseEventHandler):
"""
把接收到的消息转发到指定聊天ID
此组件是HYBRID消息和FORWARD消息的使用示例。
每收到10条消息就会以1%的概率使用HYBRID消息转发否则使用FORWARD消息转发。
"""
@@ -177,11 +177,23 @@ class ForwardMessages(BaseEventHandler):
if random.random() < 0.01:
success = await self.send_hybrid(stream_id, [(ReplyContentType.TEXT, msg) for msg in self.messages])
else:
success = await self.send_forward(stream_id, [(str(global_config.bot.qq_account), str(global_config.bot.nickname), [(ReplyContentType.TEXT, msg)]) for msg in self.messages])
success = await self.send_forward(
stream_id,
[
(
str(global_config.bot.qq_account),
str(global_config.bot.nickname),
[(ReplyContentType.TEXT, msg)],
)
for msg in self.messages
],
)
if not success:
raise ValueError("转发消息失败")
self.messages = []
return True, True, None, None, None
class RandomEmojis(BaseCommand):
command_name = "random_emojis"
command_description = "发送多张随机表情包"
@@ -203,6 +215,7 @@ class RandomEmojis(BaseCommand):
success = await self.send_forward([("0", "神秘用户", [(ReplyContentType.IMAGE, img)]) for img in images])
return (True, "已发送随机表情包", True) if success else (False, "发送随机表情包失败", False)
# ===== 插件注册 =====