@@ -184,7 +184,9 @@ class HeartFChatting:
actual_version = performance_version or get_hfc_version ( )
self . performance_logger = HFCPerformanceLogger ( chat_id , actual_version )
logger . info ( f " { self . log_prefix } HeartFChatting 初始化完成,消息疲惫阈值: { self . _message_threshold } 条( 基于exit_focus_threshold= { global_config . chat . exit_focus_threshold } 计算, 仅在auto模式下生效) " )
logger . info (
f " { self . log_prefix } HeartFChatting 初始化完成,消息疲惫阈值: { self . _message_threshold } 条( 基于exit_focus_threshold= { global_config . chat . exit_focus_threshold } 计算, 仅在auto模式下生效) "
)
def _register_observations ( self ) :
""" 注册所有观察器 """
@@ -1180,19 +1182,26 @@ class HeartFChatting:
if action == " reply " and success :
self . _message_count + = 1
current_threshold = self . _get_current_fatigue_threshold ( )
logger . info ( f " { self . log_prefix } 已发送第 { self . _message_count } 条消息(动态阈值: { current_threshold } , exit_focus_threshold: { global_config . chat . exit_focus_threshold } ) " )
logger . info (
f " { self . log_prefix } 已发送第 { self . _message_count } 条消息(动态阈值: { current_threshold } , exit_focus_threshold: { global_config . chat . exit_focus_threshold } ) "
)
# 检查是否达到疲惫阈值( 只有在auto模式下才会自动退出)
if ( global_config . chat . chat_mode == " auto " and
self . _message_count > = current_threshold and
not self . _fatigue_triggered ) :
if (
global_config . chat . chat_mode == " auto "
and self . _message_count > = current_threshold
and not self . _fatigue_triggered
) :
self . _fatigue_triggered = True
logger . info ( f " { self . log_prefix } [auto模式] 已发送 { self . _message_count } 条消息,达到疲惫阈值 { current_threshold } ,麦麦感到疲惫了,准备退出专注聊天模式 " )
logger . info (
f " { self . log_prefix } [auto模式] 已发送 { self . _message_count } 条消息,达到疲惫阈值 { current_threshold } ,麦麦感到疲惫了,准备退出专注聊天模式 "
)
# 设置系统命令,在下次循环检查时触发退出
command = " stop_focus_chat "
elif ( self . _message_count > = current_threshold and
global_config . chat . chat_mode != " auto " ) :
logger . info ( f " { self . log_prefix } [非auto模式] 已发送 { self . _message_count } 条消息,达到疲惫阈值 { current_threshold } , 但非auto模式不会自动退出" )
elif self . _message_count > = current_threshold and global_config . chat . chat_mode != " auto " :
logger . info (
f " { self . log_prefix } [非auto模式] 已发送 { self . _message_count } 条消息,达到疲惫阈值 { current_threshold } , 但非auto模式不会自动退出"
)
logger . debug ( f " { self . log_prefix } 麦麦执行了 ' { action } ' , 返回结果 ' { success } ' , ' { reply_text } ' , ' { command } ' " )
@@ -1222,7 +1231,7 @@ class HeartFChatting:
" current_count " : self . _message_count ,
" threshold " : current_threshold ,
" fatigue_triggered " : self . _fatigue_triggered ,
" remaining " : max ( 0 , current_threshold - self . _message_count )
" remaining " : max ( 0 , current_threshold - self . _message_count ) ,
}
def reset_message_count ( self ) :