diff --git a/bot.py b/bot.py index 770f5365b..9a4a50002 100644 --- a/bot.py +++ b/bot.py @@ -130,9 +130,7 @@ def check_eula(): privacy_file = Path("PRIVACY.md") eula_updated = True - eula_new_hash = None privacy_updated = True - privacy_new_hash = None eula_confirmed = False privacy_confirmed = False diff --git a/scripts/info_extraction.py b/scripts/info_extraction.py index fdb445285..65c4082b6 100644 --- a/scripts/info_extraction.py +++ b/scripts/info_extraction.py @@ -76,7 +76,7 @@ def process_single_text(pg_hash, raw_data, llm_client_list): return doc_item, None -def signal_handler(signum, frame): +def signal_handler(_signum, _frame): """处理Ctrl+C信号""" logger.info("\n接收到中断信号,正在优雅地关闭程序...") shutdown_event.set() diff --git a/src/common/message_repository.py b/src/common/message_repository.py index 9f246077f..03f192cea 100644 --- a/src/common/message_repository.py +++ b/src/common/message_repository.py @@ -26,7 +26,6 @@ def find_messages( """ try: query = db.messages.find(message_filter) - results: List[dict[str, Any]] = [] if limit > 0: if limit_mode == "earliest": diff --git a/src/individuality/individuality.py b/src/individuality/individuality.py index 86e5b63ed..9ffdfdaab 100644 --- a/src/individuality/individuality.py +++ b/src/individuality/individuality.py @@ -113,7 +113,6 @@ class Individuality: p_pronoun = "我" prompt_personality = f"{p_pronoun}{self.personality.personality_core}" else: # x_person == 0 - p_pronoun = "" # 无人称 # 对于无人称,直接描述核心特征 prompt_personality = f"{self.personality.personality_core}" diff --git a/src/plugins/PFC/action_planner.py b/src/plugins/PFC/action_planner.py index 23de9f0d3..4770c6ce5 100644 --- a/src/plugins/PFC/action_planner.py +++ b/src/plugins/PFC/action_planner.py @@ -262,7 +262,6 @@ class ActionPlanner: # --- 知识信息字符串构建结束 --- # 获取聊天历史记录 (chat_history_text) - chat_history_text = "" try: if hasattr(observation_info, "chat_history") and observation_info.chat_history: chat_history_text = observation_info.chat_history_str diff --git a/src/plugins/PFC/chat_observer.py b/src/plugins/PFC/chat_observer.py index e99ed8005..3576397d5 100644 --- a/src/plugins/PFC/chat_observer.py +++ b/src/plugins/PFC/chat_observer.py @@ -123,11 +123,7 @@ class ChatObserver: self.last_cold_chat_check = current_time # 判断是否冷场 - is_cold = False - if self.last_message_time is None: - is_cold = True - else: - is_cold = (current_time - self.last_message_time) > self.cold_chat_threshold + is_cold = True if self.last_message_time is None else (current_time - self.last_message_time) > self.cold_chat_threshold # 如果冷场状态发生变化,发送通知 if is_cold != self.is_cold_chat_state: diff --git a/src/plugins/chat/utils.py b/src/plugins/chat/utils.py index a74086812..cdaa21942 100644 --- a/src/plugins/chat/utils.py +++ b/src/plugins/chat/utils.py @@ -156,7 +156,7 @@ async def get_recent_group_messages(chat_id: str, limit: int = 12) -> list: return message_objects -def get_recent_group_detailed_plain_text(chat_stream_id: int, limit: int = 12, combine=False): +def get_recent_group_detailed_plain_text(chat_stream_id: str, limit: int = 12, combine=False): recent_messages = list( db.messages.find( {"chat_id": chat_stream_id}, diff --git a/src/plugins/emoji_system/emoji_manager.py b/src/plugins/emoji_system/emoji_manager.py index a75a4f904..f789f906b 100644 --- a/src/plugins/emoji_system/emoji_manager.py +++ b/src/plugins/emoji_system/emoji_manager.py @@ -50,8 +50,6 @@ class MaiEmoji: async def initialize_hash_format(self): """从文件创建表情包实例, 计算哈希值和格式""" - image_base64 = None - image_bytes = None try: # 使用 full_path 检查文件是否存在 if not os.path.exists(self.full_path): diff --git a/src/plugins/heartFC_chat/heartFC_chat.py b/src/plugins/heartFC_chat/heartFC_chat.py index 47d420dd7..71b8d81c2 100644 --- a/src/plugins/heartFC_chat/heartFC_chat.py +++ b/src/plugins/heartFC_chat/heartFC_chat.py @@ -174,7 +174,7 @@ class HeartFChatting: self, chat_id: str, sub_mind: SubMind, - observations: Observation, + observations: list[Observation], on_consecutive_no_reply_callback: Callable[[], Coroutine[None, None, None]], ): """ @@ -631,19 +631,18 @@ class HeartFChatting: observation = self.observations[0] if self.observations else None try: - dang_qian_deng_dai = 0.0 # 初始化本次等待时间 with Timer("等待新消息", cycle_timers): # 等待新消息、超时或关闭信号,并获取结果 await self._wait_for_new_message(observation, planner_start_db_time, self.log_prefix) # 从计时器获取实际等待时间 - dang_qian_deng_dai = cycle_timers.get("等待新消息", 0.0) + current_waiting = cycle_timers.get("等待新消息", 0.0) if not self._shutting_down: self._lian_xu_bu_hui_fu_ci_shu += 1 - self._lian_xu_deng_dai_shi_jian += dang_qian_deng_dai # 累加等待时间 + self._lian_xu_deng_dai_shi_jian += current_waiting # 累加等待时间 logger.debug( f"{self.log_prefix} 连续不回复计数增加: {self._lian_xu_bu_hui_fu_ci_shu}/{CONSECUTIVE_NO_REPLY_THRESHOLD}, " - f"本次等待: {dang_qian_deng_dai:.2f}秒, 累计等待: {self._lian_xu_deng_dai_shi_jian:.2f}秒" + f"本次等待: {current_waiting:.2f}秒, 累计等待: {self._lian_xu_deng_dai_shi_jian:.2f}秒" ) # 检查是否同时达到次数和时间阈值 diff --git a/src/plugins/memory_system/Hippocampus.py b/src/plugins/memory_system/Hippocampus.py index ff34541e0..ccc4d4fa4 100644 --- a/src/plugins/memory_system/Hippocampus.py +++ b/src/plugins/memory_system/Hippocampus.py @@ -364,7 +364,6 @@ class Hippocampus: logger.debug(f"有效的关键词: {', '.join(valid_keywords)}") # 从每个关键词获取记忆 - all_memories = [] activate_map = {} # 存储每个词的累计激活值 # 对每个关键词进行扩散式检索 @@ -536,7 +535,6 @@ class Hippocampus: logger.debug(f"有效的关键词: {', '.join(valid_keywords)}") # 从每个关键词获取记忆 - all_memories = [] activate_map = {} # 存储每个词的累计激活值 # 对每个关键词进行扩散式检索 diff --git a/src/plugins/person_info/person_info.py b/src/plugins/person_info/person_info.py index 8bafe5ebf..a71f95f8f 100644 --- a/src/plugins/person_info/person_info.py +++ b/src/plugins/person_info/person_info.py @@ -137,7 +137,6 @@ class PersonInfoManager: @staticmethod def _extract_json_from_text(text: str) -> dict: """从文本中提取JSON数据的高容错方法""" - parsed_json = None try: # 尝试直接解析 parsed_json = json.loads(text) diff --git a/src/plugins/willing/mode_dynamic.py b/src/plugins/willing/mode_dynamic.py index ab1389ea7..029da4e0f 100644 --- a/src/plugins/willing/mode_dynamic.py +++ b/src/plugins/willing/mode_dynamic.py @@ -50,7 +50,6 @@ class DynamicWillingManager(BaseWillingManager): is_high_mode = self.chat_high_willing_mode.get(chat_id, False) # 获取当前模式的持续时间 - duration = 0 if is_high_mode: duration = self.chat_high_willing_duration.get(chat_id, 180) # 默认3分钟 else: @@ -154,8 +153,6 @@ class DynamicWillingManager(BaseWillingManager): ) # 根据当前模式计算回复概率 - base_probability = 0.0 - if in_conversation_context: # 在对话上下文中,降低基础回复概率 base_probability = 0.5 if is_high_mode else 0.25 diff --git a/src/plugins/willing/mode_llmcheck.py b/src/plugins/willing/mode_llmcheck.py index ec1cde295..697621b11 100644 --- a/src/plugins/willing/mode_llmcheck.py +++ b/src/plugins/willing/mode_llmcheck.py @@ -76,10 +76,8 @@ class LlmcheckWillingManager(MxpWillingManager): current_date = time.strftime("%Y-%m-%d", time.localtime()) current_time = time.strftime("%H:%M:%S", time.localtime()) - chat_talking_prompt = "" - if chat_id: - chat_talking_prompt = get_recent_group_detailed_plain_text(chat_id, limit=length, combine=True) - else: + chat_talking_prompt = get_recent_group_detailed_plain_text(chat_id, limit=length, combine=True) + if not chat_id: return 0 # if is_mentioned_bot: