mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
fix(json_utils): 解决 “fixed_json_text”可能未绑定 的问题
This commit is contained in:
@@ -94,6 +94,7 @@ def parse_json_response(
|
|||||||
Returns:
|
Returns:
|
||||||
(成功标志, 解析后的数据列表, 错误消息)
|
(成功标志, 解析后的数据列表, 错误消息)
|
||||||
"""
|
"""
|
||||||
|
fixed_json_text = None
|
||||||
try:
|
try:
|
||||||
# 1. 提取JSON部分
|
# 1. 提取JSON部分
|
||||||
json_match = re.search(r"\[.*?\]", result_text, re.DOTALL)
|
json_match = re.search(r"\[.*?\]", result_text, re.DOTALL)
|
||||||
@@ -125,9 +126,7 @@ def parse_json_response(
|
|||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as e:
|
||||||
error_msg = f"{data_type}JSON解析失败: {e}"
|
error_msg = f"{data_type}JSON解析失败: {e}"
|
||||||
logger.warning(error_msg)
|
logger.warning(error_msg)
|
||||||
logger.debug(
|
logger.debug(f"修复后的JSON: {fixed_json_text or 'N/A'}")
|
||||||
f"修复后的JSON: {fixed_json_text if 'fixed_json_text' in locals() else 'N/A'}"
|
|
||||||
)
|
|
||||||
return False, None, error_msg
|
return False, None, error_msg
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = f"{data_type}解析异常: {e}"
|
error_msg = f"{data_type}解析异常: {e}"
|
||||||
|
|||||||
Reference in New Issue
Block a user