feat:新增纯表情发送action

This commit is contained in:
SengokuCola
2025-06-02 19:11:58 +08:00
parent b068b6a31e
commit 6fd0121f87
3 changed files with 14 additions and 8 deletions

View File

@@ -20,13 +20,14 @@ class EmojiAction(BaseAction):
""" """
action_name: str = "emoji" action_name: str = "emoji"
action_description: str = "当你想发送一个表情" action_description: str = "当你想发送一个表情辅助你的回复表达"
action_parameters: dict[str:str] = { action_parameters: dict[str:str] = {
"description": "描述你想要发送的表情", "description": "文字描述你想要发送的表情",
} }
action_require: list[str] = [ action_require: list[str] = [
"你想要发送一个表情", "你想要发送一个表情",
"表达情绪时可以选择使用", "表达情绪时可以选择使用",
"一般在你回复之后可以选择性使用"
] ]
associated_types: list[str] = ["emoji"] associated_types: list[str] = ["emoji"]
@@ -90,8 +91,7 @@ class EmojiAction(BaseAction):
"description": "描述你想要发送的表情" "description": "描述你想要发送的表情"
} }
""" """
logger.info(f"{self.log_prefix} 决定发送表情: {self.reasoning}") logger.info(f"{self.log_prefix} 决定发送表情")
# 从聊天观察获取锚定消息 # 从聊天观察获取锚定消息
# chatting_observation: ChattingObservation = next( # chatting_observation: ChattingObservation = next(
# obs for obs in self.observations if isinstance(obs, ChattingObservation) # obs for obs in self.observations if isinstance(obs, ChattingObservation)

View File

@@ -193,12 +193,17 @@ class DefaultReplyer:
try: try:
has_sent_something = False
sent_msg_list = []
reply = [] reply = []
with Timer("选择表情", cycle_timers): with Timer("选择表情", cycle_timers):
emoji_keyword = action_data.get("description", []) emoji_keyword = action_data.get("description", [])
emoji_base64 = await self._choose_emoji(emoji_keyword) emoji_base64, description = await self._choose_emoji(emoji_keyword)
if emoji_base64: if emoji_base64:
logger.info(f"选择表情: {description}")
reply.append(("emoji", emoji_base64)) reply.append(("emoji", emoji_base64))
else:
logger.warning(f"{self.log_prefix} 没有找到合适表情")
if reply: if reply:
@@ -559,11 +564,12 @@ class DefaultReplyer:
选择表情根据send_emoji文本选择表情返回表情base64 选择表情根据send_emoji文本选择表情返回表情base64
""" """
emoji_base64 = "" emoji_base64 = ""
description = ""
emoji_raw = await emoji_manager.get_emoji_for_text(send_emoji) emoji_raw = await emoji_manager.get_emoji_for_text(send_emoji)
if emoji_raw: if emoji_raw:
emoji_path, _description = emoji_raw emoji_path, description = emoji_raw
emoji_base64 = image_path_to_base64(emoji_path) emoji_base64 = image_path_to_base64(emoji_path)
return emoji_base64 return emoji_base64, description
async def _build_single_sending_message( async def _build_single_sending_message(
self, self,

View File

@@ -22,7 +22,7 @@ class MuteAction(PluginAction):
"当有人发了擦边,或者色情内容时使用", "当有人发了擦边,或者色情内容时使用",
"当有人要求禁言自己时使用", "当有人要求禁言自己时使用",
] ]
default = True # 默认动作,是否手动添加到使用集 default = False # 默认动作,是否手动添加到使用集
associated_types = ["command", "text"] associated_types = ["command", "text"]
# associated_types = ["text"] # associated_types = ["text"]