style: 统一代码风格并进行现代化改进
对整个代码库进行了一次全面的风格统一和现代化改进。主要变更包括:
- 将 `hasattr` 等内置函数中的字符串参数从单引号 `'` 统一为双引号 `"`。
- 采用现代类型注解,例如将 `Optional[T]` 替换为 `T | None`,`List[T]` 替换为 `list[T]` 等。
- 移除不再需要的 Python 2 兼容性声明 `# -*- coding: utf-8 -*-`。
- 清理了多余的空行、注释和未使用的导入。
- 统一了文件末尾的换行符。
- 优化了部分日志输出和字符串格式化 (`f"{e!s}"`)。
这些改动旨在提升代码的可读性、一致性和可维护性,使其更符合现代 Python 编码规范。
This commit is contained in:
@@ -14,4 +14,4 @@ __plugin_meta__ = PluginMetadata(
|
||||
"is_built_in": True,
|
||||
"plugin_type": "functional"
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -65,10 +65,10 @@ class ColdStartTask(AsyncTask):
|
||||
nickname = await person_api.get_person_value(person_id, "nickname")
|
||||
user_nickname = nickname or f"用户{user_id}"
|
||||
user_info = UserInfo(platform=platform, user_id=str(user_id), user_nickname=user_nickname)
|
||||
|
||||
|
||||
# 使用 get_or_create_stream 来安全地获取或创建流
|
||||
stream = await self.chat_manager.get_or_create_stream(platform, user_info)
|
||||
|
||||
|
||||
formatted_stream_id = f"{stream.user_info.platform}:{stream.user_info.user_id}:private"
|
||||
await self.executor.execute(stream_id=formatted_stream_id, start_mode="cold_start")
|
||||
logger.info(f"【冷启动】已为用户 {chat_id} (昵称: {user_nickname}) 发送唤醒/问候消息。")
|
||||
|
||||
Reference in New Issue
Block a user