fix(chat): 修复睡眠模式下无法通过艾特唤醒的问题

在之前的实现中,当机器人处于睡眠模式时,获取消息的逻辑会过滤掉所有命令消息(`filter_command=True`),这其中也包括了艾特(@)机器人的消息。这导致了用户无法通过艾特来唤醒睡眠中的机器人。

本次修复通过引入一个 `filter_command_flag` 标志来解决此问题。当机器人处于睡眠状态时(`is_sleeping` 为 `True`),该标志会设置为 `False`,从而在获取消息时不过滤命令消息,确保艾特消息能够被正确接收和处理,进而触发唤醒逻辑。

此外,还对 `schedule_manager` 中的睡眠日志记录逻辑进行了优化,增加了时间间隔来避免在睡眠期间频繁打印日志,减少不必要的日志刷屏。
This commit is contained in:
tt-P607
2025-08-23 02:49:28 +08:00
parent 32cceb0167
commit ab48324c6f
2 changed files with 16 additions and 14 deletions

View File

@@ -122,6 +122,8 @@ class ScheduleManager:
self.llm = LLMRequest(model_set=model_config.model_task_config.schedule_generator, request_type="schedule")
self.max_retries = 3 # 最大重试次数
self.daily_task_started = False
self.last_sleep_log_time = 0
self.sleep_log_interval = 35 # 日志记录间隔,单位秒
async def start_daily_schedule_generation(self):
"""启动每日零点自动生成新日程的任务"""
@@ -376,7 +378,12 @@ class ScheduleManager:
logger.info(f"在休眠活动 '{activity}' 期间,但已被唤醒。")
return False
logger.info(f"当前处于休眠活动 '{activity}' 中。")
current_timestamp = datetime.now().timestamp()
if current_timestamp - self.last_sleep_log_time > self.sleep_log_interval:
logger.info(f"当前处于休眠活动 '{activity}' 中。")
self.last_sleep_log_time = current_timestamp
else:
logger.debug(f"当前处于休眠活动 '{activity}' 中。")
return True # 找到匹配的休眠活动直接返回True
except (ValueError, KeyError, AttributeError) as e: