fix:修复表达器炸裂

This commit is contained in:
SengokuCola
2025-06-21 20:07:09 +08:00
parent b9ba0d37a9
commit c0652abbdb

View File

@@ -83,8 +83,13 @@ class ExpressionLearner:
# 获取当前chat_id的类型 # 获取当前chat_id的类型
chat_stream = get_chat_manager().get_stream(chat_id) chat_stream = get_chat_manager().get_stream(chat_id)
if chat_stream is None:
# 如果聊天流不在内存中跳过互通组查找直接使用当前chat_id
logger.warning(f"聊天流 {chat_id} 不在内存中,跳过互通组查找")
chat_ids_to_load = [chat_id]
else:
platform = chat_stream.platform platform = chat_stream.platform
if chat_stream and chat_stream.group_info: if chat_stream.group_info:
current_chat_type = "group" current_chat_type = "group"
typed_chat_id = f"{platform}:{chat_stream.group_info.group_id}:{current_chat_type}" typed_chat_id = f"{platform}:{chat_stream.group_info.group_id}:{current_chat_type}"
else: else:
@@ -266,7 +271,10 @@ class ExpressionLearner:
learnt_expressions, chat_id = res learnt_expressions, chat_id = res
chat_stream = get_chat_manager().get_stream(chat_id) chat_stream = get_chat_manager().get_stream(chat_id)
if chat_stream.group_info: if chat_stream is None:
# 如果聊天流不在内存中使用chat_id作为默认名称
group_name = f"聊天流 {chat_id}"
elif chat_stream.group_info:
group_name = chat_stream.group_info.group_name group_name = chat_stream.group_info.group_name
else: else:
group_name = f"{chat_stream.user_info.user_nickname}的私聊" group_name = f"{chat_stream.user_info.user_nickname}的私聊"