refactor(core): 统一代码风格并移除未使用的导入

本次提交主要进行代码风格的统一和现代化改造,具体包括:
- 使用 `|` 联合类型替代 `typing.Optional`,以符合 PEP 604 的现代语法。
- 移除多个文件中未被使用的导入语句,清理代码。
- 调整了部分日志输出的级别,使其更符合调试场景。
- 统一了部分文件的导入顺序和格式。
This commit is contained in:
minecraft1024a
2025-10-07 20:16:47 +08:00
parent b3d1c93b87
commit 4f9b31d188
14 changed files with 55 additions and 67 deletions

View File

@@ -72,15 +72,15 @@ class ChatMood:
self.log_prefix = f"[{self.chat_stream.group_info.group_name if self.chat_stream.group_info else self.chat_stream.user_info.user_nickname}]"
# 初始化回归计数
if not hasattr(self, 'regression_count'):
if not hasattr(self, "regression_count"):
self.regression_count = 0
# 初始化情绪模型
if not hasattr(self, 'mood_model'):
if not hasattr(self, "mood_model"):
self.mood_model = LLMRequest(model_set=model_config.model_task_config.emotion, request_type="mood")
# 初始化最后变化时间
if not hasattr(self, 'last_change_time'):
if not hasattr(self, "last_change_time"):
self.last_change_time = 0
self._initialized = True
@@ -91,11 +91,11 @@ class ChatMood:
# 设置基础初始化状态,避免重复尝试
self.log_prefix = f"[{self.chat_id}]"
self._initialized = True
if not hasattr(self, 'regression_count'):
if not hasattr(self, "regression_count"):
self.regression_count = 0
if not hasattr(self, 'mood_model'):
if not hasattr(self, "mood_model"):
self.mood_model = LLMRequest(model_set=model_config.model_task_config.emotion, request_type="mood")
if not hasattr(self, 'last_change_time'):
if not hasattr(self, "last_change_time"):
self.last_change_time = 0
async def update_mood_by_message(self, message: MessageRecv | DatabaseMessages, interested_rate: float):