fix:修改插件基类,现在支持任意类型发送
This commit is contained in:
@@ -78,7 +78,7 @@ class ExitFocusChatAction(BaseAction):
|
||||
if self.sub_heartflow:
|
||||
try:
|
||||
# 转换为normal_chat状态
|
||||
await self.sub_heartflow.change_chat_state(ChatState.NORMAL_CHAT)
|
||||
await self.sub_heartflow.change_chat_state(ChatState.CHAT)
|
||||
status_message = "已成功切换到普通聊天模式"
|
||||
logger.info(f"{self.log_prefix} {status_message}")
|
||||
except Exception as e:
|
||||
|
||||
@@ -41,7 +41,7 @@ class PluginAction(BaseAction):
|
||||
return platform, user_id
|
||||
|
||||
# 提供简化的API方法
|
||||
async def send_message(self, text: str, target: Optional[str] = None) -> bool:
|
||||
async def send_message(self, type: str, data: str, target: Optional[str] = "") -> bool:
|
||||
"""发送消息的简化方法
|
||||
|
||||
Args:
|
||||
@@ -60,7 +60,7 @@ class PluginAction(BaseAction):
|
||||
return False
|
||||
|
||||
# 构造简化的动作数据
|
||||
reply_data = {"text": text, "target": target or "", "emojis": []}
|
||||
# reply_data = {"text": text, "target": target or "", "emojis": []}
|
||||
|
||||
# 获取锚定消息(如果有)
|
||||
observations = self._services.get("observations", [])
|
||||
@@ -68,7 +68,8 @@ class PluginAction(BaseAction):
|
||||
chatting_observation: ChattingObservation = next(
|
||||
obs for obs in observations if isinstance(obs, ChattingObservation)
|
||||
)
|
||||
anchor_message = chatting_observation.search_message_by_text(reply_data["target"])
|
||||
|
||||
anchor_message = chatting_observation.search_message_by_text(target)
|
||||
|
||||
# 如果没有找到锚点消息,创建一个占位符
|
||||
if not anchor_message:
|
||||
@@ -80,7 +81,7 @@ class PluginAction(BaseAction):
|
||||
anchor_message.update_chat_stream(chat_stream)
|
||||
|
||||
response_set = [
|
||||
("text", text),
|
||||
(type, data),
|
||||
]
|
||||
|
||||
# 调用内部方法发送消息
|
||||
|
||||
Reference in New Issue
Block a user