指令都是空格之前内容,作为标准化处理
This commit is contained in:
@@ -38,7 +38,10 @@ def plugin_stats_decorator(plugin_name: str) -> Callable:
|
|||||||
sender = message.get("sender", "")
|
sender = message.get("sender", "")
|
||||||
roomid = message.get("roomid", "")
|
roomid = message.get("roomid", "")
|
||||||
|
|
||||||
logger.debug(f"[{plugin_name}] 消息内容: '{content}', 发送者: {sender}, 群ID: {roomid}")
|
# 提取指令部分(假设指令是第一个单词或空格前的部分)
|
||||||
|
command = content.strip().split(' ')[0] if content else ""
|
||||||
|
|
||||||
|
logger.debug(f"[{plugin_name}] 消息内容: '{content}', 指令: '{command}', 发送者: {sender}, 群ID: {roomid}")
|
||||||
|
|
||||||
# 记录开始时间
|
# 记录开始时间
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@@ -58,13 +61,13 @@ def plugin_stats_decorator(plugin_name: str) -> Callable:
|
|||||||
logger.debug(f"[{plugin_name}] 记录插件调用统计")
|
logger.debug(f"[{plugin_name}] 记录插件调用统计")
|
||||||
stats_db.record_plugin_call(
|
stats_db.record_plugin_call(
|
||||||
plugin_name=plugin_name,
|
plugin_name=plugin_name,
|
||||||
command=content,
|
command=command, # 使用提取的指令而不是完整内容
|
||||||
user_id=sender,
|
user_id=sender,
|
||||||
group_id=roomid,
|
group_id=roomid,
|
||||||
success=success,
|
success=success,
|
||||||
process_time_ms=process_time_ms
|
process_time_ms=process_time_ms
|
||||||
)
|
)
|
||||||
logger.info(f"[{plugin_name}] 成功记录插件调用: {content}, 耗时: {process_time_ms:.2f}ms")
|
logger.info(f"[{plugin_name}] 成功记录插件调用: {command}, 耗时: {process_time_ms:.2f}ms")
|
||||||
|
|
||||||
return success, response
|
return success, response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -83,7 +86,7 @@ def plugin_stats_decorator(plugin_name: str) -> Callable:
|
|||||||
logger.debug(f"[{plugin_name}] 记录插件调用失败统计")
|
logger.debug(f"[{plugin_name}] 记录插件调用失败统计")
|
||||||
stats_db.record_plugin_call(
|
stats_db.record_plugin_call(
|
||||||
plugin_name=plugin_name,
|
plugin_name=plugin_name,
|
||||||
command=content,
|
command=command, # 使用提取的指令而不是完整内容
|
||||||
user_id=sender,
|
user_id=sender,
|
||||||
group_id=roomid,
|
group_id=roomid,
|
||||||
success=False,
|
success=False,
|
||||||
@@ -94,13 +97,13 @@ def plugin_stats_decorator(plugin_name: str) -> Callable:
|
|||||||
logger.debug(f"[{plugin_name}] 记录错误详情")
|
logger.debug(f"[{plugin_name}] 记录错误详情")
|
||||||
stats_db.record_error(
|
stats_db.record_error(
|
||||||
plugin_name=plugin_name,
|
plugin_name=plugin_name,
|
||||||
command=content,
|
command=command, # 使用提取的指令而不是完整内容
|
||||||
user_id=sender,
|
user_id=sender,
|
||||||
group_id=roomid,
|
group_id=roomid,
|
||||||
error_message=error_message,
|
error_message=error_message,
|
||||||
stack_trace=stack_trace
|
stack_trace=stack_trace
|
||||||
)
|
)
|
||||||
logger.info(f"[{plugin_name}] 成功记录插件错误: {content}, 错误: {error_message}")
|
logger.info(f"[{plugin_name}] 成功记录插件错误: {command}, 错误: {error_message}")
|
||||||
except Exception as db_error:
|
except Exception as db_error:
|
||||||
logger.error(f"[{plugin_name}] 记录插件统计数据失败: {db_error}")
|
logger.error(f"[{plugin_name}] 记录插件统计数据失败: {db_error}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user