Merge branch 'afc' of https://github.com/MoFox-Studio/MoFox_Bot into afc
This commit is contained in:
@@ -151,12 +151,31 @@ class ChatterPlanFilter:
|
||||
identity_block = f"你的名字是{bot_name}{bot_nickname},你{bot_core_personality}:"
|
||||
|
||||
schedule_block = ""
|
||||
if global_config.planning_system.schedule_enable:
|
||||
# 优先检查是否被吵醒
|
||||
from src.chat.message_manager.message_manager import message_manager
|
||||
angry_prompt_addition = ""
|
||||
wakeup_mgr = message_manager.wakeup_manager
|
||||
|
||||
# 双重检查确保愤怒状态不会丢失
|
||||
# 检查1: 直接从 wakeup_manager 获取
|
||||
if wakeup_mgr.is_in_angry_state():
|
||||
angry_prompt_addition = wakeup_mgr.get_angry_prompt_addition()
|
||||
|
||||
# 检查2: 如果上面没获取到,再从 mood_manager 确认
|
||||
if not angry_prompt_addition:
|
||||
chat_mood_for_check = mood_manager.get_mood_by_chat_id(plan.chat_id)
|
||||
if chat_mood_for_check.is_angry_from_wakeup:
|
||||
angry_prompt_addition = global_config.sleep_system.angry_prompt
|
||||
|
||||
if angry_prompt_addition:
|
||||
schedule_block = angry_prompt_addition
|
||||
elif global_config.planning_system.schedule_enable:
|
||||
if current_activity := schedule_manager.get_current_activity():
|
||||
schedule_block = f"你当前正在:{current_activity},但注意它与群聊的聊天无关。"
|
||||
|
||||
mood_block = ""
|
||||
if global_config.mood.enable_mood:
|
||||
# 如果被吵醒,则心情也是愤怒的,不需要另外的情绪模块
|
||||
if not angry_prompt_addition and global_config.mood.enable_mood:
|
||||
chat_mood = mood_manager.get_mood_by_chat_id(plan.chat_id)
|
||||
mood_block = f"你现在的心情是:{chat_mood.mood_state}"
|
||||
|
||||
|
||||
@@ -654,20 +654,30 @@ class QZoneService:
|
||||
end_idx = resp_text.rfind("}") + 1
|
||||
if start_idx != -1 and end_idx != -1:
|
||||
json_str = resp_text[start_idx:end_idx]
|
||||
upload_result = eval(json_str) # 与原版保持一致使用eval
|
||||
try:
|
||||
upload_result = orjson.loads(json_str)
|
||||
except orjson.JSONDecodeError:
|
||||
logger.error(f"图片上传响应JSON解析失败,原始响应: {resp_text}")
|
||||
return None
|
||||
|
||||
logger.info(f"图片上传解析结果: {upload_result}")
|
||||
logger.debug(f"图片上传解析结果: {upload_result}")
|
||||
|
||||
if upload_result.get("ret") == 0:
|
||||
# 使用原版的参数提取逻辑
|
||||
picbo, richval = _get_picbo_and_richval(upload_result)
|
||||
logger.info(f"图片 {index + 1} 上传成功: picbo={picbo}")
|
||||
return {"pic_bo": picbo, "richval": richval}
|
||||
try:
|
||||
# 使用原版的参数提取逻辑
|
||||
picbo, richval = _get_picbo_and_richval(upload_result)
|
||||
logger.info(f"图片 {index + 1} 上传成功: picbo={picbo}")
|
||||
return {"pic_bo": picbo, "richval": richval}
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"从上传结果中提取图片参数失败: {e}, 上传结果: {upload_result}", exc_info=True
|
||||
)
|
||||
return None
|
||||
else:
|
||||
logger.error(f"图片 {index + 1} 上传失败: {upload_result}")
|
||||
return None
|
||||
else:
|
||||
logger.error("无法解析上传响应")
|
||||
logger.error(f"无法从响应中提取JSON内容: {resp_text}")
|
||||
return None
|
||||
else:
|
||||
error_text = await response.text()
|
||||
|
||||
Reference in New Issue
Block a user