feat:将no_reply内置
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
from typing import Tuple, List
|
||||
from collections import deque
|
||||
|
||||
# 导入新插件系统
|
||||
from src.plugin_system import BaseAction, ActionActivationType, ChatMode
|
||||
|
||||
# 导入依赖的系统组件
|
||||
from src.common.logger import get_logger
|
||||
|
||||
|
||||
logger = get_logger("no_reply_action")
|
||||
|
||||
|
||||
class NoReplyAction(BaseAction):
|
||||
"""不回复动作,支持waiting和breaking两种形式.
|
||||
|
||||
waiting形式:
|
||||
- 只要有新消息就结束动作
|
||||
- 记录新消息的兴趣度到列表(最多保留最近三项)
|
||||
- 如果最近三次动作都是no_reply,且最近新消息列表兴趣度之和小于阈值,就进入breaking形式
|
||||
|
||||
breaking形式:
|
||||
- 和原有逻辑一致,需要消息满足一定数量或累计一定兴趣值才结束动作
|
||||
"""
|
||||
|
||||
focus_activation_type = ActionActivationType.NEVER
|
||||
normal_activation_type = ActionActivationType.NEVER
|
||||
mode_enable = ChatMode.FOCUS
|
||||
parallel_action = False
|
||||
|
||||
# 动作基本信息
|
||||
action_name = "no_reply"
|
||||
action_description = "暂时不回复消息"
|
||||
|
||||
|
||||
|
||||
# 兴趣值退出阈值
|
||||
_interest_exit_threshold = 3.0
|
||||
# 消息数量退出阈值
|
||||
_min_exit_message_count = 3
|
||||
_max_exit_message_count = 6
|
||||
|
||||
# 动作参数定义
|
||||
action_parameters = {}
|
||||
|
||||
# 动作使用场景
|
||||
action_require = [""]
|
||||
|
||||
# 关联类型
|
||||
associated_types = []
|
||||
|
||||
async def execute(self) -> Tuple[bool, str]:
|
||||
"""执行不回复动作"""
|
||||
|
||||
try:
|
||||
reason = self.action_data.get("reason", "")
|
||||
|
||||
logger.info(f"{self.log_prefix} 选择不回复,原因: {reason}")
|
||||
|
||||
await self.store_action_info(
|
||||
action_build_into_prompt=False,
|
||||
action_prompt_display=reason,
|
||||
action_done=True,
|
||||
)
|
||||
return True, reason
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 不回复动作执行失败: {e}")
|
||||
exit_reason = f"执行异常: {str(e)}"
|
||||
full_prompt = f"no_reply执行异常: {exit_reason},你思考是否要进行回复"
|
||||
await self.store_action_info(
|
||||
action_build_into_prompt=True,
|
||||
action_prompt_display=full_prompt,
|
||||
action_done=True,
|
||||
)
|
||||
return False, f"不回复动作执行失败: {e}"
|
||||
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "核心动作插件 (Core Actions)",
|
||||
"name": "Emoji插件 (Emoji Actions)",
|
||||
"version": "1.0.0",
|
||||
"description": "系统核心动作插件,提供基础聊天交互功能,包括回复、不回复、表情包发送和聊天模式切换等核心功能。",
|
||||
"description": "可以发送和管理Emoji",
|
||||
"author": {
|
||||
"name": "MaiBot团队",
|
||||
"name": "SengokuCola",
|
||||
"url": "https://github.com/MaiM-with-u"
|
||||
},
|
||||
"license": "GPL-v3.0-or-later",
|
||||
|
||||
"host_application": {
|
||||
"min_version": "0.8.0"
|
||||
"min_version": "0.10.0"
|
||||
},
|
||||
"homepage_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"repository_url": "https://github.com/MaiM-with-u/maibot",
|
||||
"keywords": ["core", "chat", "reply", "emoji", "action", "built-in"],
|
||||
"categories": ["Core System", "Chat Management"],
|
||||
"keywords": ["emoji", "action", "built-in"],
|
||||
"categories": ["Emoji"],
|
||||
|
||||
"default_locale": "zh-CN",
|
||||
"locales_path": "_locales",
|
||||
@@ -24,11 +24,6 @@
|
||||
"is_built_in": true,
|
||||
"plugin_type": "action_provider",
|
||||
"components": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "no_reply",
|
||||
"description": "暂时不回复消息,等待新消息或超时"
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"name": "emoji",
|
||||
@@ -9,8 +9,7 @@ from src.common.logger import get_logger
|
||||
|
||||
# 导入API模块 - 标准Python包方式
|
||||
from src.plugin_system.apis import emoji_api, llm_api, message_api
|
||||
# 注释:不再需要导入NoReplyAction,因为计数器管理已移至heartFC_chat.py
|
||||
# from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
||||
# NoReplyAction已集成到heartFC_chat.py中,不再需要导入
|
||||
from src.config.config import global_config
|
||||
|
||||
|
||||
@@ -149,8 +148,7 @@ class EmojiAction(BaseAction):
|
||||
logger.error(f"{self.log_prefix} 表情包发送失败")
|
||||
return False, "表情包发送失败"
|
||||
|
||||
# 注释:重置NoReplyAction的连续计数器现在由heartFC_chat.py统一管理
|
||||
# NoReplyAction.reset_consecutive_count()
|
||||
# no_reply计数器现在由heartFC_chat.py统一管理,无需在此重置
|
||||
|
||||
return True, f"发送表情包: {emoji_description}"
|
||||
|
||||
@@ -15,7 +15,7 @@ from src.plugin_system.base.config_types import ConfigField
|
||||
from src.common.logger import get_logger
|
||||
|
||||
# 导入API模块 - 标准Python包方式
|
||||
from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
||||
# NoReplyAction已集成到heartFC_chat.py中,不再需要导入
|
||||
from src.plugins.built_in.core_actions.emoji import EmojiAction
|
||||
|
||||
logger = get_logger("core_actions")
|
||||
@@ -50,10 +50,9 @@ class CoreActionsPlugin(BasePlugin):
|
||||
config_schema: dict = {
|
||||
"plugin": {
|
||||
"enabled": ConfigField(type=bool, default=True, description="是否启用插件"),
|
||||
"config_version": ConfigField(type=str, default="0.5.0", description="配置文件版本"),
|
||||
"config_version": ConfigField(type=str, default="0.6.0", description="配置文件版本"),
|
||||
},
|
||||
"components": {
|
||||
"enable_no_reply": ConfigField(type=bool, default=True, description="是否启用不回复动作"),
|
||||
"enable_emoji": ConfigField(type=bool, default=True, description="是否启用发送表情/图片动作"),
|
||||
},
|
||||
}
|
||||
@@ -63,8 +62,6 @@ class CoreActionsPlugin(BasePlugin):
|
||||
|
||||
# --- 根据配置注册组件 ---
|
||||
components = []
|
||||
if self.get_config("components.enable_no_reply", True):
|
||||
components.append((NoReplyAction.get_action_info(), NoReplyAction))
|
||||
if self.get_config("components.enable_emoji", True):
|
||||
components.append((EmojiAction.get_action_info(), EmojiAction))
|
||||
|
||||
Reference in New Issue
Block a user