feat(翻译): 改进翻译功能,同时显示原文和译文

修改翻译功能,不再替换原文而是同时显示原文和翻译内容,方便用户对照
更新 DeepSeek API 配置为官方地址和模型
优化 Discord 适配器的重连逻辑,直接关闭 WebSocket 触发重连
修复 Discord 频道 ID 转换逻辑,简化处理流程
This commit is contained in:
2026-03-22 15:07:18 +08:00
parent e34221939e
commit 313c4c651b
3 changed files with 20 additions and 11 deletions

View File

@@ -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)