feat(set_emoji_like): 添加群聊检查,确保表情回应动作仅在群聊中有效

This commit is contained in:
Windpicker-owo
2025-12-03 13:55:37 +08:00
parent 6233e27d46
commit a36e2fdf92
2 changed files with 9 additions and 0 deletions

View File

@@ -176,6 +176,7 @@ class NapcatAdapter(BaseAdapter):
# 消息事件
if post_type == "message":
return await self.message_handler.handle_raw_message(raw) # type: ignore[return-value]
# 通知事件
elif post_type == "notice":
return await self.notice_handler.handle_notice(raw) # type: ignore[return-value]

View File

@@ -244,6 +244,14 @@ class SetEmojiLikeAction(BaseAction):
async def execute(self) -> tuple[bool, str]:
"""执行设置表情回应的动作"""
# 检查是否在群聊中,该动作仅在群聊中有效
if not self.is_group:
logger.warning("set_emoji_like 动作仅在群聊中有效,当前为私聊场景")
await self.store_action_info(
action_prompt_display="贴表情失败: 该功能仅在群聊中可用", action_done=False
)
return False, "该功能仅在群聊中可用"
message_id = None
set_like = self.action_data.get("set", True)