'commit'
This commit is contained in:
@@ -63,6 +63,7 @@ class ChatMonitorBot:
|
||||
self.input_pos = None
|
||||
self.last_screen_hash = None
|
||||
self.last_processed_msg_hash = None
|
||||
self.first_run = True # 标记是否为首次运行
|
||||
self.check_interval = 3 # 检查频率 (秒)
|
||||
|
||||
self.persona = (
|
||||
@@ -312,7 +313,12 @@ class ChatMonitorBot:
|
||||
# E. 判断是否需要回复 (对方发送且非重复消息)
|
||||
sender = last_msg.get('sender', '')
|
||||
if sender != "我":
|
||||
if current_msg_hash != self.last_processed_msg_hash:
|
||||
if self.first_run:
|
||||
# 首次运行时,记录最后一条消息的哈希但不回复,防止重启后重复回复历史消息
|
||||
logger.info(f"🚦 [启动] 首次扫描,忽略已存在的最后一条消息: {last_msg}")
|
||||
self.last_processed_msg_hash = current_msg_hash
|
||||
self.first_run = False
|
||||
elif current_msg_hash != self.last_processed_msg_hash:
|
||||
event_shot = WxUtil.get_next_debug_path("event_new_msg")
|
||||
self.device.screenshot(event_shot)
|
||||
logger.info(f"💡 [监控] 发现新消息: {last_msg},保存现场截图: {event_shot}")
|
||||
@@ -345,7 +351,11 @@ class ChatMonitorBot:
|
||||
pass
|
||||
else:
|
||||
# 最后一条是我发送的
|
||||
if current_msg_hash != self.last_processed_msg_hash:
|
||||
if self.first_run:
|
||||
logger.info(f"🚦 [启动] 首次扫描,最后一条是自己发的,标记为已处理: {last_msg}")
|
||||
self.last_processed_msg_hash = current_msg_hash
|
||||
self.first_run = False
|
||||
elif current_msg_hash != self.last_processed_msg_hash:
|
||||
logger.info(f"⚪ [监控] 最后一条消息是自己发的,跳过回复: {last_msg}")
|
||||
self.last_processed_msg_hash = current_msg_hash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user