refactor(replyer): 优化用户ID获取逻辑,简化自我回复判断
This commit is contained in:
@@ -1870,10 +1870,12 @@ class DefaultReplyer:
|
||||
|
||||
async def build_relation_info(self, sender: str, target: str):
|
||||
# 获取用户ID
|
||||
if sender == f"{global_config.bot.nickname}(你)":
|
||||
return f"你将要回复的是你自己发送的消息。"
|
||||
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_id = await person_info_manager.get_person_id_by_person_name(sender)
|
||||
if person_id == "SELF":
|
||||
return f"你将要回复的是你自己发送的消息。"
|
||||
|
||||
if not person_id:
|
||||
logger.warning(f"未找到用户 {sender} 的ID,跳过信息提取")
|
||||
return f"你完全不认识{sender},不理解ta的相关信息。"
|
||||
|
||||
@@ -132,8 +132,6 @@ class PersonInfoManager:
|
||||
若未命中则查询数据库并更新缓存。
|
||||
"""
|
||||
try:
|
||||
if person_name == f"{global_config.bot.nickname}(你)":
|
||||
return "SELF"
|
||||
# 优先使用内存缓存加速查找:self.person_name_list maps person_id -> person_name
|
||||
for pid, pname in self.person_name_list.items():
|
||||
if pname == person_name:
|
||||
|
||||
Reference in New Issue
Block a user