refactor(mood): 移除与唤醒愤怒和失眠相关的状态管理

删除了 `ChatMood` 类中的 `is_angry_from_wakeup` 属性,并移除了 `MoodManager` 中所有与之相关的方法,包括:
- `reset_mood_by_chat_id`
- `set_angry_from_wakeup`
- `clear_angry_from_wakeup`
- `start_insomnia`
- `stop_insomnia`
- `get_angry_prompt_addition`

这些逻辑现在由更通用的状态机和动作系统处理,简化了情绪模块的职责,使其更专注于核心情绪值的管理。
This commit is contained in:
minecraft1024a
2025-10-31 21:13:54 +08:00
parent 26ba4c3643
commit 0ffcae4d44
2 changed files with 1 additions and 52 deletions

View File

@@ -1172,18 +1172,11 @@ class DefaultReplyer:
chat_id = chat_stream.stream_id chat_id = chat_stream.stream_id
person_info_manager = get_person_info_manager() person_info_manager = get_person_info_manager()
is_group_chat = bool(chat_stream.group_info) is_group_chat = bool(chat_stream.group_info)
mood_prompt = ""
if global_config.mood.enable_mood: if global_config.mood.enable_mood:
chat_mood = mood_manager.get_mood_by_chat_id(chat_id) chat_mood = mood_manager.get_mood_by_chat_id(chat_id)
mood_prompt = chat_mood.mood_state mood_prompt = chat_mood.mood_state
# 检查是否有愤怒状态的补充提示词
angry_prompt_addition = mood_manager.get_angry_prompt_addition(chat_id)
if angry_prompt_addition:
mood_prompt = f"{mood_prompt}{angry_prompt_addition}"
else:
mood_prompt = ""
if reply_to: if reply_to:
# 兼容旧的reply_to # 兼容旧的reply_to
sender, target = self._parse_reply_target(reply_to) sender, target = self._parse_reply_target(reply_to)

View File

@@ -52,7 +52,6 @@ class ChatMood:
self._initialized = False self._initialized = False
self.mood_state: str = "感觉很平静" self.mood_state: str = "感觉很平静"
self.is_angry_from_wakeup: bool = False # 是否因被吵醒而愤怒
async def _initialize(self): async def _initialize(self):
"""异步初始化方法""" """异步初始化方法"""
@@ -281,49 +280,6 @@ class MoodManager:
self.mood_list.append(new_mood) self.mood_list.append(new_mood)
return new_mood return new_mood
def reset_mood_by_chat_id(self, chat_id: str):
for mood in self.mood_list:
if mood.chat_id == chat_id:
mood.mood_state = "感觉很平静"
mood.regression_count = 0
mood.is_angry_from_wakeup = False
return
self.mood_list.append(ChatMood(chat_id))
def set_angry_from_wakeup(self, chat_id: str):
"""设置因被吵醒而愤怒的状态"""
mood = self.get_mood_by_chat_id(chat_id)
mood.is_angry_from_wakeup = True
mood.mood_state = "被人吵醒了非常生气"
mood.last_change_time = time.time()
logger.info(f"{mood.log_prefix} 因被吵醒设置为愤怒状态")
def clear_angry_from_wakeup(self, chat_id: str):
"""清除因被吵醒而愤怒的状态"""
mood = self.get_mood_by_chat_id(chat_id)
if mood.is_angry_from_wakeup:
mood.is_angry_from_wakeup = False
mood.mood_state = "感觉很平静"
logger.info(f"{mood.log_prefix} 清除被吵醒的愤怒状态")
def start_insomnia(self, chat_id: str):
"""开始一个聊天的失眠状态,锁定情绪更新"""
logger.info(f"Chat [{chat_id}]进入失眠状态,情绪已锁定。")
self.insomnia_chats.add(chat_id)
def stop_insomnia(self, chat_id: str):
"""停止一个聊天的失眠状态,解锁情绪更新"""
logger.info(f"Chat [{chat_id}]失眠状态结束,情绪已解锁。")
self.insomnia_chats.discard(chat_id)
def get_angry_prompt_addition(self, chat_id: str) -> str:
"""获取愤怒状态下的提示词补充"""
mood = self.get_mood_by_chat_id(chat_id)
if mood.is_angry_from_wakeup:
return "你被人吵醒了非常生气,说话带着怒气"
return ""
init_prompt() init_prompt()
mood_manager = MoodManager() mood_manager = MoodManager()