Dev (#76)
* fix(discord): 修复 WebSocket 连接检测并增强跨平台文件处理 修复 Discord WebSocket 连接检测逻辑,使用正确的属性检查连接状态 为跨平台消息处理添加文件类型支持,并增加详细的调试日志 优化附件处理逻辑,确保所有文件类型都能正确识别和转发 * feat(跨平台): 优化消息处理并添加纯文本提取功能 添加 extract_text_only 函数过滤非文本标记 修改翻译逻辑仅处理纯文本内容 完善附件处理和消息内容拼接 修复仅包含表情时的消息处理问题 * refactor(discord-cross): 使用模块专用日志记录器替换全局日志记录器 将各模块中的全局日志记录器替换为模块专用日志记录器,以提供更清晰的日志来源标识 同时在适配器中添加会话状态检查和重连机制,提升消息发送的可靠性 * feat(翻译): 改进翻译功能,同时显示原文和译文 修改翻译功能,不再替换原文而是同时显示原文和翻译内容,方便用户对照 更新 DeepSeek API 配置为官方地址和模型 优化 Discord 适配器的重连逻辑,直接关闭 WebSocket 触发重连 修复 Discord 频道 ID 转换逻辑,简化处理流程
This commit is contained in:
@@ -16,9 +16,9 @@ class CrossPlatformConfig:
|
||||
self.ENABLE_CROSS_PLATFORM = True
|
||||
|
||||
# DeepSeek API 配置
|
||||
self.DEEPSEEK_API_KEY = "sk-Cn4BeHyTHDPRKuDadLy6dUnjSSHxrz5wQa54ZFAdQovXguLD"
|
||||
self.DEEPSEEK_API_URL = "https://api.gptgod.online/v1/chat/completions"
|
||||
self.DEEPSEEK_MODEL = "gemini-3-flash-preview"
|
||||
self.DEEPSEEK_API_KEY = "sk-7b824b05e85445f8a9ceef6c849388a9"
|
||||
self.DEEPSEEK_API_URL = "https://api.deepseek.com/v1/chat/completions"
|
||||
self.DEEPSEEK_MODEL = "deepseek-chat"
|
||||
|
||||
# 是否启用翻译功能
|
||||
self.ENABLE_TRANSLATION = True
|
||||
@@ -48,12 +48,14 @@ class CrossPlatformConfig:
|
||||
for key, value in mappings.items():
|
||||
if isinstance(value, dict) and "qq_group_id" in value:
|
||||
try:
|
||||
discord_id = int(key) if str(key).isdigit() else int(str(key).split('.')[-1])
|
||||
# 直接将 key 转换为整数
|
||||
discord_id = int(str(key))
|
||||
self.CROSS_PLATFORM_MAP[discord_id] = {
|
||||
"qq_group_id": int(value.get("qq_group_id", 0)),
|
||||
"name": value.get("name", "")
|
||||
}
|
||||
except (ValueError, AttributeError):
|
||||
logger.warning(f"[CrossPlatform] 无效的 Discord 频道 ID: {key}")
|
||||
continue
|
||||
|
||||
logger.success(f"[CrossPlatform] 配置已重新加载: {len(self.CROSS_PLATFORM_MAP)} 个映射")
|
||||
|
||||
@@ -125,8 +125,8 @@ async def forward_discord_to_qq(
|
||||
if text_only:
|
||||
translated_content = await translate_with_deepseek(text_only, "zh-CN", channel_id, "en2zh")
|
||||
if translated_content != text_only:
|
||||
# 将翻译后的文本替换回原文本位置
|
||||
formatted_content = formatted_content.replace(text_only, translated_content)
|
||||
# 同时包含原文和翻译内容
|
||||
formatted_content = f"{formatted_content}\n\n[翻译]\n{translated_content}"
|
||||
|
||||
await send_to_qq(target_qq_group, formatted_content, image_list)
|
||||
logger.success(f"[CrossPlatform] Discord 频道 {channel_id} -> QQ 群 {target_qq_group}")
|
||||
@@ -166,7 +166,8 @@ async def forward_qq_to_discord(
|
||||
if text_only:
|
||||
translated_text = await translate_with_deepseek(text_only, "en", group_id, "zh2en")
|
||||
if translated_text != text_only:
|
||||
embed["description"] = embed["description"].replace(text_only, translated_text)
|
||||
# 同时包含原文和翻译内容
|
||||
embed["description"] = f"{original_text}\n\n[Translation]\n{translated_text}"
|
||||
|
||||
for channel_id in target_channels:
|
||||
await send_to_discord(channel_id, formatted_content, image_list, embed)
|
||||
|
||||
Reference in New Issue
Block a user