chore: perform widespread code cleanup and formatting

Perform a comprehensive code cleanup across multiple modules to improve code quality, consistency, and maintainability.

Key changes include:
- Removing numerous unused imports.
- Standardizing import order.
- Eliminating trailing whitespace and inconsistent newlines.
- Updating legacy type hints to modern syntax (e.g., `List` -> `list`).
- Making minor improvements for code robustness and style.
This commit is contained in:
minecraft1024a
2025-11-15 17:12:46 +08:00
parent bd45899dce
commit 6f62073630
26 changed files with 109 additions and 117 deletions

View File

@@ -9,6 +9,7 @@ from datetime import datetime
from typing import Any
import orjson
from json_repair import repair_json
from src.chat.utils.chat_message_builder import (
build_readable_messages_with_id,
@@ -19,7 +20,6 @@ from src.common.logger import get_logger
from src.config.config import global_config, model_config
from src.llm_models.utils_model import LLMRequest
from src.mood.mood_manager import mood_manager
from json_repair import repair_json
from src.plugin_system.base.component_types import ActionInfo, ChatType
from src.schedule.schedule_manager import schedule_manager
@@ -144,7 +144,7 @@ class ChatterPlanFilter:
plan.decided_actions = [
ActionPlannerInfo(action_type="no_action", reasoning=f"筛选时出错: {e}")
]
# 在返回最终计划前,打印将要执行的动作
if plan.decided_actions:
action_types = [action.action_type for action in plan.decided_actions]
@@ -631,7 +631,6 @@ class ChatterPlanFilter:
candidate_ids.add(normalized_id[1:])
# 处理包含在文本中的ID格式 (如 "消息m123" -> 提取 m123)
import re
# 尝试提取各种格式的ID
id_patterns = [

View File

@@ -10,7 +10,6 @@ from src.common.data_models.database_data_model import DatabaseMessages
from src.common.data_models.info_data_model import Plan, TargetPersonInfo
from src.config.config import global_config
from src.plugin_system.base.component_types import ActionInfo, ChatMode, ChatType
from src.plugin_system.core.component_registry import component_registry
class ChatterPlanGenerator:

View File

@@ -201,7 +201,7 @@ class ChatterActionPlanner:
available_actions = list(initial_plan.available_actions.keys())
plan_filter = ChatterPlanFilter(self.chat_id, available_actions)
filtered_plan = await plan_filter.filter(initial_plan)
# 检查reply动作是否可用
has_reply_action = "reply" in available_actions or "respond" in available_actions
if filtered_plan.decided_actions and has_reply_action and reply_not_available:

View File

@@ -320,7 +320,7 @@ class QZoneService:
return
# 1. 将评论分为用户评论和自己的回复
user_comments = [c for c in comments if str(c.get("qq_account")) != str(qq_account)]
user_comments = [c for c in comments if str(c.get("qq_account")) != str(qq_account)]
if not user_comments:
return

View File

@@ -295,7 +295,7 @@ class SystemCommand(PlusCommand):
if injections:
response_parts.append(f"🎯 **{target}** (注入源):")
for inj in injections:
source_tag = f"({inj['source']})" if inj['source'] != 'static_default' else ''
source_tag = f"({inj['source']})" if inj["source"] != "static_default" else ""
response_parts.append(f" ⎿ `{inj['name']}` (优先级: {inj['priority']}) {source_tag}")
else:
response_parts.append(f"🎯 **{target}** (无注入)")