Revert "feat(chat): 实现发送错别字后自动撤回修正的功能"

This reverts commit fd5d951501.
This commit is contained in:
minecraft1024a
2025-09-06 20:56:13 +08:00
parent 9591df7b74
commit 2241db3ebf
6 changed files with 199 additions and 322 deletions

View File

@@ -84,7 +84,7 @@ async def generate_reply(
return_prompt: bool = False,
request_type: str = "generator_api",
from_plugin: bool = True,
) -> Tuple[bool, List[Dict[str, Any]], Optional[str]]:
) -> Tuple[bool, List[Tuple[str, Any]], Optional[str]]:
"""生成回复
Args:
@@ -170,7 +170,7 @@ async def rewrite_reply(
reply_to: str = "",
return_prompt: bool = False,
request_type: str = "generator_api",
) -> Tuple[bool, List[Dict[str, Any]], Optional[str]]:
) -> Tuple[bool, List[Tuple[str, Any]], Optional[str]]:
"""重写回复
Args:
@@ -229,9 +229,7 @@ async def rewrite_reply(
return False, [], None
def process_human_text(
content: str, enable_splitter: bool, enable_chinese_typo: bool
) -> List[Dict[str, Any]]:
def process_human_text(content: str, enable_splitter: bool, enable_chinese_typo: bool) -> List[Tuple[str, Any]]:
"""将文本处理为更拟人化的文本
Args:
@@ -248,11 +246,9 @@ def process_human_text(
processed_response = process_llm_response(content, enable_splitter, enable_chinese_typo)
reply_set = []
for item in processed_response:
if item["type"] == "typo":
reply_set.append(item)
else:
reply_set.append({"type": "text", "content": item["content"]})
for text in processed_response:
reply_seg = ("text", text)
reply_set.append(reply_seg)
return reply_set

View File

@@ -179,7 +179,7 @@ async def _send_to_target(
# 构建机器人用户信息
bot_user_info = UserInfo(
user_id=str(global_config.bot.qq_account),
user_id=global_config.bot.qq_account,
user_nickname=global_config.bot.nickname,
platform=target_stream.platform,
)
@@ -190,13 +190,10 @@ async def _send_to_target(
# 处理回复消息
if reply_to_message:
anchor_message = message_dict_to_message_recv(message_dict=reply_to_message)
if anchor_message and anchor_message.message_info and anchor_message.message_info.user_info:
anchor_message.update_chat_stream(target_stream)
reply_to_platform_id = (
f"{anchor_message.message_info.platform}:{anchor_message.message_info.user_info.user_id}"
)
else:
reply_to_platform_id = None
anchor_message.update_chat_stream(target_stream)
reply_to_platform_id = (
f"{anchor_message.message_info.platform}:{anchor_message.message_info.user_info.user_id}"
)
else:
anchor_message = None
reply_to_platform_id = None
@@ -426,10 +423,10 @@ async def adapter_command_to_stream(
# 创建临时的用户信息和聊天流
temp_user_info = UserInfo(user_id="system", user_nickname="System", platform=platform or "qq")
temp_user_info = UserInfo(user_id="system", user_nickname="System", platform=platform)
temp_chat_stream = ChatStream(
stream_id=stream_id, platform=platform or "qq", user_info=temp_user_info, group_info=None
stream_id=stream_id, platform=platform, user_info=temp_user_info, group_info=None
)
target_stream = temp_chat_stream
@@ -446,7 +443,7 @@ async def adapter_command_to_stream(
# 构建机器人用户信息
bot_user_info = UserInfo(
user_id=str(global_config.bot.qq_account),
user_id=global_config.bot.qq_account,
user_nickname=global_config.bot.nickname,
platform=target_stream.platform,
)
@@ -499,23 +496,3 @@ async def adapter_command_to_stream(
logger.error(f"[SendAPI] 发送适配器命令时出错: {e}")
traceback.print_exc()
return {"status": "error", "message": f"发送适配器命令时出错: {str(e)}"}
async def recall_message(message_id: str, stream_id: str) -> bool:
"""撤回消息
Args:
message_id: 消息ID
stream_id: 聊天流ID
Returns:
bool: 是否成功
"""
command_data = {"name": "delete_msg", "args": message_id}
success = await command_to_stream(
command=command_data,
stream_id=stream_id,
storage_message=True,
)
return success