mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 19:57:04 +08:00
feat: 支持多个事件的返回值
This commit is contained in:
parent
df9e89deb7
commit
e582780195
|
@ -30,6 +30,9 @@ PersonNormalMessageReceived = "person_normal_message_received"
|
|||
launcher_id: int 发起对象ID(群号/QQ号)
|
||||
sender_id: int 发送者ID(QQ号)
|
||||
text_message: str 消息文本
|
||||
|
||||
returns (optional):
|
||||
alter: str 修改后的消息文本
|
||||
"""
|
||||
|
||||
PersonCommandSent = "person_command_sent"
|
||||
|
@ -44,6 +47,7 @@ PersonCommandSent = "person_command_sent"
|
|||
is_admin: bool 是否为管理员
|
||||
|
||||
returns (optional):
|
||||
alter: str 修改后的完整指令文本
|
||||
reply: list 回复消息组件列表
|
||||
"""
|
||||
|
||||
|
@ -54,6 +58,9 @@ GroupNormalMessageReceived = "group_normal_message_received"
|
|||
launcher_id: int 发起对象ID(群号/QQ号)
|
||||
sender_id: int 发送者ID(QQ号)
|
||||
text_message: str 消息文本
|
||||
|
||||
returns (optional):
|
||||
alter: str 修改后的消息文本
|
||||
"""
|
||||
|
||||
GroupCommandSent = "group_command_sent"
|
||||
|
@ -66,6 +73,10 @@ GroupCommandSent = "group_command_sent"
|
|||
params: list[str] 参数列表
|
||||
text_message: str 完整指令文本
|
||||
is_admin: bool 是否为管理员
|
||||
|
||||
returns (optional):
|
||||
alter: str 修改后的完整指令文本
|
||||
reply: list 回复消息组件列表
|
||||
"""
|
||||
|
||||
NormalMessageResponded = "normal_message_responded"
|
||||
|
@ -79,6 +90,7 @@ NormalMessageResponded = "normal_message_responded"
|
|||
response_text: str 响应文本
|
||||
|
||||
returns (optional):
|
||||
prefix: str 修改后的回复文字消息的前缀
|
||||
reply: list 替换回复消息组件列表
|
||||
"""
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@ def process_normal_message(text_message: str, mgr, config, launcher_type: str,
|
|||
}
|
||||
|
||||
event = pkg.plugin.host.emit(plugin_models.NormalMessageResponded, **args)
|
||||
|
||||
if event.get_return_value("prefix") is not None:
|
||||
prefix = event.get_return_value("prefix")
|
||||
|
||||
if event.get_return_value("reply") is not None:
|
||||
reply = event.get_return("reply")
|
||||
|
||||
|
|
|
@ -81,6 +81,9 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
|
|||
if launcher_type == 'person'
|
||||
else plugin_models.GroupCommandSent, **args)
|
||||
|
||||
if event.get_return_value("alter") is not None:
|
||||
text_message = event.get_return_value("alter")
|
||||
|
||||
# 取出插件提交的返回值赋值给reply
|
||||
if event.get_return_value("reply") is not None:
|
||||
reply.append(event.get_return("reply"))
|
||||
|
@ -101,6 +104,9 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
|
|||
if launcher_type == 'person'
|
||||
else plugin_models.GroupNormalMessageReceived, **args)
|
||||
|
||||
if event.get_return_value("alter") is not None:
|
||||
text_message = event.get_return_value("alter")
|
||||
|
||||
if not event.is_prevented_default():
|
||||
reply = pkg.qqbot.message.process_normal_message(text_message,
|
||||
mgr, config, launcher_type, launcher_id, sender_id)
|
||||
|
|
Loading…
Reference in New Issue
Block a user