fix:给示例插件改名
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -307,3 +307,8 @@ src/chat/focus_chat/working_memory/test/test4.txt
|
||||
run_maiserver.bat
|
||||
src/plugins/test_plugin_pic/actions/pic_action_config.toml
|
||||
run_pet.bat
|
||||
|
||||
# 忽略 /src/plugins 但保留特定目录
|
||||
/src/plugins/*
|
||||
!/src/plugins/doubao_pic/
|
||||
!/src/plugins/mute_action/
|
||||
|
||||
67
scripts/group_similarity_details.txt
Normal file
67
scripts/group_similarity_details.txt
Normal file
@@ -0,0 +1,67 @@
|
||||
群组相似度详情
|
||||
==================================================
|
||||
|
||||
群组1: qvn123
|
||||
群组2: 千石可乐
|
||||
场景相似度: 0.1478
|
||||
表达方式相似度: 0.0876
|
||||
组合相似度: 0.1153
|
||||
|
||||
共同表达方式:
|
||||
- 麦麦
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
群组1: 麦麦脑电图-2
|
||||
群组2: 麦麦大脑磁共振-1
|
||||
场景相似度: 0.0912
|
||||
表达方式相似度: 0.1589
|
||||
组合相似度: 0.1285
|
||||
|
||||
共同场景:
|
||||
- 想提及某人但不想太明显
|
||||
- 提及某人但不想太明显
|
||||
|
||||
共同表达方式:
|
||||
- 戳了戳xxx
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
群组1: 麦麦脑电图-2
|
||||
群组2: 麦麦大脑磁刺激-4
|
||||
场景相似度: 0.1599
|
||||
表达方式相似度: 0.2519
|
||||
组合相似度: 0.2112
|
||||
|
||||
共同场景:
|
||||
- 提出具体修改要求
|
||||
- 提及某人但不想太明显
|
||||
|
||||
共同表达方式:
|
||||
- 戳了戳xxx
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
群组1: desktop-pet-70eb3194
|
||||
群组2: 千石可乐
|
||||
场景相似度: 0.0000
|
||||
表达方式相似度: 0.1119
|
||||
组合相似度: 0.0622
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
群组1: 麦麦大脑磁共振-1
|
||||
群组2: 麦麦大脑磁刺激-4
|
||||
场景相似度: 0.0563
|
||||
表达方式相似度: 0.1267
|
||||
组合相似度: 0.0936
|
||||
|
||||
共同场景:
|
||||
- 提及某人但不想太明显
|
||||
|
||||
共同表达方式:
|
||||
- 666
|
||||
- 戳了戳xxx
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
19
src/plugins/doubao_pic/actions/pic_action_config.toml
Normal file
19
src/plugins/doubao_pic/actions/pic_action_config.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
# 火山方舟 API 的基础 URL
|
||||
base_url = "https://ark.cn-beijing.volces.com/api/v3"
|
||||
# 用于图片生成的API密钥
|
||||
volcano_generate_api_key = "YOUR_VOLCANO_GENERATE_API_KEY_HERE"
|
||||
# 默认图片生成模型
|
||||
default_model = "doubao-seedream-3-0-t2i-250415"
|
||||
# 默认图片尺寸
|
||||
default_size = "1024x1024"
|
||||
|
||||
|
||||
# 是否默认开启水印
|
||||
default_watermark = true
|
||||
# 默认引导强度
|
||||
default_guidance_scale = 2.5
|
||||
# 默认随机种子
|
||||
default_seed = 42
|
||||
|
||||
# 更多插件特定配置可以在此添加...
|
||||
# custom_parameter = "some_value"
|
||||
@@ -1,5 +0,0 @@
|
||||
"""测试插件包"""
|
||||
|
||||
"""
|
||||
这是一个测试插件
|
||||
"""
|
||||
@@ -1,7 +0,0 @@
|
||||
"""测试插件动作模块"""
|
||||
|
||||
# 导入所有动作模块以确保装饰器被执行
|
||||
from . import test_action # noqa
|
||||
|
||||
# from . import online_action # noqa
|
||||
from . import mute_action # noqa
|
||||
@@ -1,63 +0,0 @@
|
||||
from src.common.logger_manager import get_logger
|
||||
from src.chat.focus_chat.planners.actions.plugin_action import PluginAction, register_action
|
||||
from typing import Tuple
|
||||
|
||||
logger = get_logger("group_whole_ban_action")
|
||||
|
||||
|
||||
@register_action
|
||||
class GroupWholeBanAction(PluginAction):
|
||||
"""群聊全体禁言动作处理类"""
|
||||
|
||||
action_name = "group_whole_ban_action"
|
||||
action_description = "开启或关闭群聊全体禁言,当群聊过于混乱或需要安静时使用"
|
||||
action_parameters = {
|
||||
"enable": "是否开启全体禁言,输入True开启,False关闭,必填",
|
||||
}
|
||||
action_require = [
|
||||
"当群聊过于混乱需要安静时使用",
|
||||
"当需要临时暂停群聊讨论时使用",
|
||||
"当有人要求开启全体禁言时使用",
|
||||
"当管理员需要发布重要公告时使用",
|
||||
]
|
||||
default = False
|
||||
associated_types = ["command", "text"]
|
||||
|
||||
async def process(self) -> Tuple[bool, str]:
|
||||
"""处理群聊全体禁言动作"""
|
||||
logger.info(f"{self.log_prefix} 执行全体禁言动作: {self.reasoning}")
|
||||
|
||||
# 获取参数
|
||||
enable = self.action_data.get("enable")
|
||||
|
||||
if enable is None:
|
||||
error_msg = "全体禁言参数不完整,需要enable参数"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
return False, error_msg
|
||||
|
||||
# 确保enable是布尔类型
|
||||
if isinstance(enable, str):
|
||||
if enable.lower() in ["true", "1", "yes", "开启", "是"]:
|
||||
enable = True
|
||||
elif enable.lower() in ["false", "0", "no", "关闭", "否"]:
|
||||
enable = False
|
||||
else:
|
||||
error_msg = f"无效的enable参数: {enable},应该是True或False"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
return False, error_msg
|
||||
|
||||
# 发送表达情绪的消息
|
||||
action_text = "开启" if enable else "关闭"
|
||||
await self.send_message_by_expressor(f"我要{action_text}全体禁言")
|
||||
|
||||
try:
|
||||
# 发送群聊全体禁言命令,按照新格式
|
||||
await self.send_message(type="command", data={"name": "GROUP_WHOLE_BAN", "args": {"enable": enable}})
|
||||
|
||||
logger.info(f"{self.log_prefix} 成功{action_text}全体禁言")
|
||||
return True, f"成功{action_text}全体禁言"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 执行全体禁言动作时出错: {e}")
|
||||
await self.send_message_by_expressor(f"执行全体禁言动作时出错: {e}")
|
||||
return False, f"执行全体禁言动作时出错: {e}"
|
||||
@@ -1,76 +0,0 @@
|
||||
from src.common.logger_manager import get_logger
|
||||
from src.chat.focus_chat.planners.actions.plugin_action import PluginAction, register_action
|
||||
from typing import Tuple
|
||||
|
||||
logger = get_logger("mute_action")
|
||||
|
||||
|
||||
@register_action
|
||||
class MuteAction(PluginAction):
|
||||
"""群聊禁言动作处理类"""
|
||||
|
||||
action_name = "mute_action"
|
||||
action_description = "在特定情境下,对某人采取禁言,让他不能说话"
|
||||
action_parameters = {
|
||||
"target": "禁言对象,必填,输入你要禁言的对象的名字",
|
||||
"duration": "禁言时长,必填,输入你要禁言的时长(秒),单位为秒,必须为数字",
|
||||
"reason": "禁言理由,可选",
|
||||
}
|
||||
action_require = [
|
||||
"当有人违反了公序良俗的内容",
|
||||
"当有人刷屏时使用",
|
||||
"当有人发了擦边,或者色情内容时使用",
|
||||
"当有人要求禁言自己时使用",
|
||||
]
|
||||
default = False # 默认动作,是否手动添加到使用集
|
||||
associated_types = ["command", "text"]
|
||||
# associated_types = ["text"]
|
||||
|
||||
async def process(self) -> Tuple[bool, str]:
|
||||
"""处理群聊禁言动作"""
|
||||
logger.info(f"{self.log_prefix} 执行禁言动作: {self.reasoning}")
|
||||
|
||||
# 获取参数
|
||||
target = self.action_data.get("target")
|
||||
duration = self.action_data.get("duration")
|
||||
reason = self.action_data.get("reason", "违反群规")
|
||||
|
||||
if not target or not duration:
|
||||
error_msg = "禁言参数不完整,需要target和duration"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
return False, error_msg
|
||||
|
||||
# 获取用户ID
|
||||
platform, user_id = await self.get_user_id_by_person_name(target)
|
||||
|
||||
if not user_id:
|
||||
error_msg = f"未找到用户 {target} 的ID"
|
||||
await self.send_message_by_expressor(f"压根没 {target} 这个人")
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
return False, error_msg
|
||||
|
||||
# 发送表达情绪的消息
|
||||
await self.send_message_by_expressor(f"禁言{target} {duration}秒,因为{reason}")
|
||||
|
||||
try:
|
||||
# 确保duration是字符串类型
|
||||
if int(duration) < 60:
|
||||
duration = 60
|
||||
if int(duration) > 3600 * 24 * 30:
|
||||
duration = 3600 * 24 * 30
|
||||
duration_str = str(int(duration))
|
||||
|
||||
# 发送群聊禁言命令,按照新格式
|
||||
await self.send_message(
|
||||
type="command",
|
||||
data={"name": "GROUP_BAN", "args": {"qq_id": str(user_id), "duration": duration_str}},
|
||||
display_message=f"我 禁言了 {target} {duration_str}秒",
|
||||
)
|
||||
|
||||
logger.info(f"{self.log_prefix} 成功发送禁言命令,用户 {target}({user_id}),时长 {duration} 秒")
|
||||
return True, f"成功禁言 {target},时长 {duration} 秒"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 执行禁言动作时出错: {e}")
|
||||
await self.send_message_by_expressor(f"执行禁言动作时出错: {e}")
|
||||
return False, f"执行禁言动作时出错: {e}"
|
||||
@@ -1,37 +0,0 @@
|
||||
from src.common.logger_manager import get_logger
|
||||
from src.chat.focus_chat.planners.actions.plugin_action import PluginAction, register_action
|
||||
from typing import Tuple
|
||||
|
||||
logger = get_logger("test_action")
|
||||
|
||||
|
||||
@register_action
|
||||
class TestAction(PluginAction):
|
||||
"""测试动作处理类"""
|
||||
|
||||
action_name = "test_action"
|
||||
action_description = "这是一个测试动作,当有人要求你测试插件系统时使用"
|
||||
action_parameters = {"test_param": "测试参数(可选)"}
|
||||
action_require = [
|
||||
"测试情况下使用",
|
||||
"想测试插件动作加载时使用",
|
||||
]
|
||||
default = False # 不是默认动作,需要手动添加到使用集
|
||||
|
||||
async def process(self) -> Tuple[bool, str]:
|
||||
"""处理测试动作"""
|
||||
logger.info(f"{self.log_prefix} 执行测试动作: {self.reasoning}")
|
||||
|
||||
# 获取聊天类型
|
||||
chat_type = self.get_chat_type()
|
||||
logger.info(f"{self.log_prefix} 当前聊天类型: {chat_type}")
|
||||
|
||||
# 获取最近消息
|
||||
recent_messages = self.get_recent_messages(3)
|
||||
logger.info(f"{self.log_prefix} 最近3条消息: {recent_messages}")
|
||||
|
||||
# 发送测试消息
|
||||
test_param = self.action_data.get("test_param", "默认参数")
|
||||
await self.send_message_by_expressor(f"测试动作执行成功,参数: {test_param}")
|
||||
|
||||
return True, "测试动作执行成功"
|
||||
Reference in New Issue
Block a user