refactor(person_info): 引入同步方法 get_value 并替换旧的 get_value_sync(因为根本就没有这个方法)
为了解决在不同异步上下文中同步调用数据库可能引发的运行时错误,实现了一个新的、更健壮的同步方法 `PersonInfoManager.get_value`。 - 新方法能够正确处理已在运行的 asyncio 事件循环,提高了在混合代码环境中调用的稳定性。 - 全面替换了原有的 `get_value_sync` 方法调用,统一了同步获取用户信息的接口。
This commit is contained in:
committed by
Windpicker-owo
parent
02067b6eeb
commit
79baac2797
@@ -43,9 +43,9 @@ def replace_user_references_sync(
|
||||
# 检查是否是机器人自己
|
||||
if replace_bot_name and user_id == global_config.bot.qq_account:
|
||||
return f"{global_config.bot.nickname}(你)"
|
||||
person = Person(platform=platform, user_id=user_id)
|
||||
return person.person_name or user_id # type: ignore
|
||||
|
||||
person_id = PersonInfoManager.get_person_id(platform, user_id)
|
||||
return person_info_manager.get_value(person_id, "person_name") or user_id # type: ignore
|
||||
|
||||
name_resolver = default_resolver
|
||||
|
||||
# 处理回复<aaa:bbb>格式
|
||||
|
||||
Reference in New Issue
Block a user