fix:修复路径遗留问题
This commit is contained in:
@@ -378,7 +378,7 @@ class PingCommand(BaseCommand):
|
||||
message = self.matched_groups.get("message", "")
|
||||
reply_text = f"🏓 Pong! {message}" if message else "🏓 Pong!"
|
||||
|
||||
await self.send_reply(reply_text)
|
||||
await self.send_text(reply_text)
|
||||
return True, f"发送ping响应: {reply_text}"
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -105,14 +105,14 @@ class DoubaoImageGenerationAction(BaseAction):
|
||||
|
||||
if not (http_base_url and http_api_key):
|
||||
error_msg = "抱歉,图片生成功能所需的HTTP配置(如API地址或密钥)不完整,无法提供服务。"
|
||||
await self.send_reply(error_msg)
|
||||
await self.send_text(error_msg)
|
||||
logger.error(f"{self.log_prefix} HTTP调用配置缺失: base_url 或 volcano_generate_api_key.")
|
||||
return False, "HTTP配置不完整"
|
||||
|
||||
# API密钥验证
|
||||
if http_api_key == "YOUR_DOUBAO_API_KEY_HERE":
|
||||
error_msg = "图片生成功能尚未配置,请设置正确的API密钥。"
|
||||
await self.send_reply(error_msg)
|
||||
await self.send_text(error_msg)
|
||||
logger.error(f"{self.log_prefix} API密钥未配置")
|
||||
return False, "API密钥未配置"
|
||||
|
||||
@@ -120,7 +120,7 @@ class DoubaoImageGenerationAction(BaseAction):
|
||||
description = self.action_data.get("description")
|
||||
if not description or not description.strip():
|
||||
logger.warning(f"{self.log_prefix} 图片描述为空,无法生成图片。")
|
||||
await self.send_reply("你需要告诉我想要画什么样的图片哦~ 比如说'画一只可爱的小猫'")
|
||||
await self.send_text("你需要告诉我想要画什么样的图片哦~ 比如说'画一只可爱的小猫'")
|
||||
return False, "图片描述为空"
|
||||
|
||||
# 清理和验证描述
|
||||
@@ -143,12 +143,12 @@ class DoubaoImageGenerationAction(BaseAction):
|
||||
if cache_key in self._request_cache:
|
||||
cached_result = self._request_cache[cache_key]
|
||||
logger.info(f"{self.log_prefix} 使用缓存的图片结果")
|
||||
await self.send_reply("我之前画过类似的图片,用之前的结果~")
|
||||
await self.send_text("我之前画过类似的图片,用之前的结果~")
|
||||
|
||||
# 直接发送缓存的结果
|
||||
send_success = await self._send_image(cached_result)
|
||||
if send_success:
|
||||
await self.send_reply("图片已发送!")
|
||||
await self.send_text("图片已发送!")
|
||||
return True, "图片已发送(缓存)"
|
||||
else:
|
||||
# 缓存失败,清除这个缓存项并继续正常流程
|
||||
@@ -159,7 +159,7 @@ class DoubaoImageGenerationAction(BaseAction):
|
||||
seed_val = self._get_seed()
|
||||
watermark_val = self._get_watermark()
|
||||
|
||||
await self.send_reply(
|
||||
await self.send_text(
|
||||
f"收到!正在为您生成关于 '{description}' 的图片,请稍候...(模型: {default_model}, 尺寸: {image_size})"
|
||||
)
|
||||
|
||||
|
||||
@@ -97,13 +97,13 @@ class MuteAction(BaseAction):
|
||||
if not target:
|
||||
error_msg = "禁言目标不能为空"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("没有指定禁言对象呢~")
|
||||
await self.send_text("没有指定禁言对象呢~")
|
||||
return False, error_msg
|
||||
|
||||
if not duration:
|
||||
error_msg = "禁言时长不能为空"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("没有指定禁言时长呢~")
|
||||
await self.send_text("没有指定禁言时长呢~")
|
||||
return False, error_msg
|
||||
|
||||
# 获取时长限制配置
|
||||
@@ -116,7 +116,7 @@ class MuteAction(BaseAction):
|
||||
if duration_int <= 0:
|
||||
error_msg = "禁言时长必须大于0"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("禁言时长必须是正数哦~")
|
||||
await self.send_text("禁言时长必须是正数哦~")
|
||||
return False, error_msg
|
||||
|
||||
# 限制禁言时长范围
|
||||
@@ -130,7 +130,7 @@ class MuteAction(BaseAction):
|
||||
except (ValueError, TypeError):
|
||||
error_msg = f"禁言时长格式无效: {duration}"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("禁言时长必须是数字哦~")
|
||||
await self.send_text("禁言时长必须是数字哦~")
|
||||
return False, error_msg
|
||||
|
||||
# 获取用户ID
|
||||
@@ -139,12 +139,12 @@ class MuteAction(BaseAction):
|
||||
except Exception as e:
|
||||
error_msg = f"查找用户ID时出错: {e}"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("查找用户信息时出现问题~")
|
||||
await self.send_text("查找用户信息时出现问题~")
|
||||
return False, error_msg
|
||||
|
||||
if not user_id:
|
||||
error_msg = f"未找到用户 {target} 的ID"
|
||||
await self.send_reply(f"找不到 {target} 这个人呢~")
|
||||
await self.send_text(f"找不到 {target} 这个人呢~")
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
return False, error_msg
|
||||
|
||||
@@ -154,7 +154,7 @@ class MuteAction(BaseAction):
|
||||
|
||||
# 获取模板化消息
|
||||
message = self._get_template_message(target, time_str, reason)
|
||||
# await self.send_reply(message)
|
||||
# await self.send_text(message)
|
||||
await self.send_message_by_expressor(message)
|
||||
|
||||
# 发送群聊禁言命令
|
||||
@@ -170,7 +170,7 @@ class MuteAction(BaseAction):
|
||||
else:
|
||||
error_msg = "发送禁言命令失败"
|
||||
logger.error(f"{self.log_prefix} {error_msg}")
|
||||
await self.send_reply("执行禁言动作失败")
|
||||
await self.send_text("执行禁言动作失败")
|
||||
return False, error_msg
|
||||
|
||||
def _get_template_message(self, target: str, duration_str: str, reason: str) -> str:
|
||||
@@ -237,7 +237,7 @@ class MuteCommand(BaseCommand):
|
||||
reason = self.matched_groups.get("reason", "管理员操作")
|
||||
|
||||
if not all([target, duration]):
|
||||
await self.send_reply("❌ 命令参数不完整,请检查格式")
|
||||
await self.send_text("❌ 命令参数不完整,请检查格式")
|
||||
return False, "参数不完整"
|
||||
|
||||
# 获取时长限制配置
|
||||
@@ -248,19 +248,19 @@ class MuteCommand(BaseCommand):
|
||||
try:
|
||||
duration_int = int(duration)
|
||||
if duration_int <= 0:
|
||||
await self.send_reply("❌ 禁言时长必须大于0")
|
||||
await self.send_text("❌ 禁言时长必须大于0")
|
||||
return False, "时长无效"
|
||||
|
||||
# 限制禁言时长范围
|
||||
if duration_int < min_duration:
|
||||
duration_int = min_duration
|
||||
await self.send_reply(f"⚠️ 禁言时长过短,调整为{min_duration}秒")
|
||||
await self.send_text(f"⚠️ 禁言时长过短,调整为{min_duration}秒")
|
||||
elif duration_int > max_duration:
|
||||
duration_int = max_duration
|
||||
await self.send_reply(f"⚠️ 禁言时长过长,调整为{max_duration}秒")
|
||||
await self.send_text(f"⚠️ 禁言时长过长,调整为{max_duration}秒")
|
||||
|
||||
except ValueError:
|
||||
await self.send_reply("❌ 禁言时长必须是数字")
|
||||
await self.send_text("❌ 禁言时长必须是数字")
|
||||
return False, "时长格式错误"
|
||||
|
||||
# 获取用户ID
|
||||
@@ -268,11 +268,11 @@ class MuteCommand(BaseCommand):
|
||||
platform, user_id = await self.api.get_user_id_by_person_name(target)
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 查找用户ID时出错: {e}")
|
||||
await self.send_reply("❌ 查找用户信息时出现问题")
|
||||
await self.send_text("❌ 查找用户信息时出现问题")
|
||||
return False, str(e)
|
||||
|
||||
if not user_id:
|
||||
await self.send_reply(f"❌ 找不到用户: {target}")
|
||||
await self.send_text(f"❌ 找不到用户: {target}")
|
||||
return False, "用户不存在"
|
||||
|
||||
# 格式化时长显示
|
||||
@@ -291,17 +291,17 @@ class MuteCommand(BaseCommand):
|
||||
if success:
|
||||
# 获取并发送模板化消息
|
||||
message = self._get_template_message(target, time_str, reason)
|
||||
await self.send_reply(message)
|
||||
await self.send_text(message)
|
||||
|
||||
logger.info(f"{self.log_prefix} 成功禁言 {target}({user_id}),时长 {duration_int} 秒")
|
||||
return True, f"成功禁言 {target},时长 {time_str}"
|
||||
else:
|
||||
await self.send_reply("❌ 发送禁言命令失败")
|
||||
await self.send_text("❌ 发送禁言命令失败")
|
||||
return False, "发送禁言命令失败"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"{self.log_prefix} 禁言命令执行失败: {e}")
|
||||
await self.send_reply(f"❌ 禁言命令错误: {str(e)}")
|
||||
await self.send_text(f"❌ 禁言命令错误: {str(e)}")
|
||||
return False, str(e)
|
||||
|
||||
def _get_template_message(self, target: str, duration_str: str, reason: str) -> str:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from src.common.logger import get_logger
|
||||
from src.chat.actions.base_action import ActionActivationType
|
||||
from src.chat.actions.plugin_action import PluginAction, register_action
|
||||
from src.plugin_system.base.base_action import ActionActivationType
|
||||
from src.plugin_system.base.base_action import BaseAction as PluginAction, register_action
|
||||
from typing import Tuple
|
||||
|
||||
logger = get_logger("tts_action")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from src.common.logger import get_logger
|
||||
from src.chat.actions.plugin_action import PluginAction, register_action, ActionActivationType
|
||||
from src.plugin_system.base.base_action import BaseAction as PluginAction, ActionActivationType
|
||||
from src.plugin_system.base.base_action import register_action
|
||||
from typing import Tuple
|
||||
|
||||
logger = get_logger("vtb_action")
|
||||
|
||||
Reference in New Issue
Block a user