diff --git a/plugins/take_picture_plugin/_manifest.json b/plugins/take_picture_plugin/_manifest.json index ac7113148..0488d1de1 100644 --- a/plugins/take_picture_plugin/_manifest.json +++ b/plugins/take_picture_plugin/_manifest.json @@ -10,8 +10,7 @@ "license": "GPL-v3.0-or-later", "host_application": { - "min_version": "0.8.0", - "max_version": "0.8.0" + "min_version": "0.9.0" }, "homepage_url": "https://github.com/MaiM-with-u/maibot", "repository_url": "https://github.com/MaiM-with-u/maibot", diff --git a/src/chat/message_receive/bot.py b/src/chat/message_receive/bot.py index 316213f63..0f626b6c8 100644 --- a/src/chat/message_receive/bot.py +++ b/src/chat/message_receive/bot.py @@ -98,6 +98,7 @@ class ChatBot: # 使用新的组件注册中心查找命令 command_result = component_registry.find_command_by_text(text) if command_result: + message.is_command = True command_class, matched_groups, intercept_message, plugin_name = command_result # 获取插件配置 diff --git a/src/chat/message_receive/message.py b/src/chat/message_receive/message.py index ddb564a6f..e6b6741f0 100644 --- a/src/chat/message_receive/message.py +++ b/src/chat/message_receive/message.py @@ -107,6 +107,9 @@ class MessageRecv(Message): self.is_picid = False self.has_picid = False self.is_mentioned = None + + self.is_command = False + self.priority_mode = "interest" self.priority_info = None self.interest_value: float = None # type: ignore diff --git a/src/chat/message_receive/storage.py b/src/chat/message_receive/storage.py index 820b534c3..41b236ef0 100644 --- a/src/chat/message_receive/storage.py +++ b/src/chat/message_receive/storage.py @@ -43,6 +43,7 @@ class MessageStorage: priority_info = {} is_emoji = False is_picid = False + is_command = False else: filtered_display_message = "" interest_value = message.interest_value @@ -52,6 +53,7 @@ class MessageStorage: priority_info = message.priority_info is_emoji = message.is_emoji is_picid = message.is_picid + is_command = message.is_command chat_info_dict = chat_stream.to_dict() user_info_dict = message.message_info.user_info.to_dict() # type: ignore @@ -96,6 +98,7 @@ class MessageStorage: priority_info=priority_info, is_emoji=is_emoji, is_picid=is_picid, + is_command=is_command, ) except Exception: logger.exception("存储消息失败") diff --git a/src/chat/utils/chat_message_builder.py b/src/chat/utils/chat_message_builder.py index aaa59c8ec..4f24eef88 100644 --- a/src/chat/utils/chat_message_builder.py +++ b/src/chat/utils/chat_message_builder.py @@ -36,6 +36,7 @@ def get_raw_msg_by_timestamp_with_chat( limit: int = 0, limit_mode: str = "latest", filter_bot=False, + filter_command=False, ) -> List[Dict[str, Any]]: """获取在特定聊天从指定时间戳到指定时间戳的消息,按时间升序排序,返回消息列表 limit: 限制返回的消息数量,0为不限制 @@ -46,7 +47,12 @@ def get_raw_msg_by_timestamp_with_chat( sort_order = [("time", 1)] if limit == 0 else None # 直接将 limit_mode 传递给 find_messages return find_messages( - message_filter=filter_query, sort=sort_order, limit=limit, limit_mode=limit_mode, filter_bot=filter_bot + message_filter=filter_query, + sort=sort_order, + limit=limit, + limit_mode=limit_mode, + filter_bot=filter_bot, + filter_command=filter_command, ) diff --git a/src/common/database/database_model.py b/src/common/database/database_model.py index 1b364e909..140bb305c 100644 --- a/src/common/database/database_model.py +++ b/src/common/database/database_model.py @@ -161,7 +161,7 @@ class Messages(BaseModel): additional_config = TextField(null=True) is_emoji = BooleanField(default=False) is_picid = BooleanField(default=False) - + is_command = BooleanField(default=False) class Meta: # database = db # 继承自 BaseModel table_name = "messages" diff --git a/src/common/message_repository.py b/src/common/message_repository.py index edb12763b..7a5fd0fa9 100644 --- a/src/common/message_repository.py +++ b/src/common/message_repository.py @@ -23,6 +23,7 @@ def find_messages( limit: int = 0, limit_mode: str = "latest", filter_bot=False, + filter_command=False, ) -> List[dict[str, Any]]: """ 根据提供的过滤器、排序和限制条件查找消息。 @@ -75,6 +76,9 @@ def find_messages( if filter_bot: query = query.where(Messages.user_id != global_config.bot.qq_account) + if filter_command: + query = query.where(Messages.is_command == False) + if limit > 0: if limit_mode == "earliest": # 获取时间最早的 limit 条记录,已经是正序 diff --git a/src/plugin_system/apis/message_api.py b/src/plugin_system/apis/message_api.py index b720bb23c..7794ee819 100644 --- a/src/plugin_system/apis/message_api.py +++ b/src/plugin_system/apis/message_api.py @@ -69,6 +69,7 @@ def get_messages_by_time_in_chat( limit: int = 0, limit_mode: str = "latest", filter_mai: bool = False, + filter_command: bool = False, ) -> List[Dict[str, Any]]: """ 获取指定聊天中指定时间范围内的消息 @@ -80,7 +81,7 @@ def get_messages_by_time_in_chat( limit: 限制返回的消息数量,0为不限制 limit_mode: 当limit>0时生效,'earliest'表示获取最早的记录,'latest'表示获取最新的记录 filter_mai: 是否过滤麦麦自身的消息,默认为False - + filter_command: 是否过滤命令消息,默认为False Returns: List[Dict[str, Any]]: 消息列表 @@ -96,8 +97,8 @@ def get_messages_by_time_in_chat( if not isinstance(chat_id, str): raise ValueError("chat_id 必须是字符串类型") if filter_mai: - return filter_mai_messages(get_raw_msg_by_timestamp_with_chat(chat_id, start_time, end_time, limit, limit_mode)) - return get_raw_msg_by_timestamp_with_chat(chat_id, start_time, end_time, limit, limit_mode) + return filter_mai_messages(get_raw_msg_by_timestamp_with_chat(chat_id, start_time, end_time, limit, limit_mode, filter_command)) + return get_raw_msg_by_timestamp_with_chat(chat_id, start_time, end_time, limit, limit_mode, filter_command) def get_messages_by_time_in_chat_inclusive( @@ -107,6 +108,7 @@ def get_messages_by_time_in_chat_inclusive( limit: int = 0, limit_mode: str = "latest", filter_mai: bool = False, + filter_command: bool = False, ) -> List[Dict[str, Any]]: """ 获取指定聊天中指定时间范围内的消息(包含边界) @@ -135,9 +137,9 @@ def get_messages_by_time_in_chat_inclusive( raise ValueError("chat_id 必须是字符串类型") if filter_mai: return filter_mai_messages( - get_raw_msg_by_timestamp_with_chat_inclusive(chat_id, start_time, end_time, limit, limit_mode) + get_raw_msg_by_timestamp_with_chat_inclusive(chat_id, start_time, end_time, limit, limit_mode, filter_command) ) - return get_raw_msg_by_timestamp_with_chat_inclusive(chat_id, start_time, end_time, limit, limit_mode) + return get_raw_msg_by_timestamp_with_chat_inclusive(chat_id, start_time, end_time, limit, limit_mode, filter_command) def get_messages_by_time_in_chat_for_users( diff --git a/src/plugins/built_in/core_actions/no_reply.py b/src/plugins/built_in/core_actions/no_reply.py index 080c717f2..2880d1ec2 100644 --- a/src/plugins/built_in/core_actions/no_reply.py +++ b/src/plugins/built_in/core_actions/no_reply.py @@ -79,7 +79,11 @@ class NoReplyAction(BaseAction): # 1. 检查新消息 recent_messages_dict = message_api.get_messages_by_time_in_chat( - chat_id=self.chat_id, start_time=start_time, end_time=current_time + chat_id=self.chat_id, + start_time=start_time, + end_time=current_time, + filter_mai=True, + filter_command=True, ) new_message_count = len(recent_messages_dict) diff --git a/template/bot_config_template.toml b/template/bot_config_template.toml index e54c440b5..a139e3aa5 100644 --- a/template/bot_config_template.toml +++ b/template/bot_config_template.toml @@ -48,6 +48,7 @@ expression_groups = [ enable_relationship = true # 是否启用关系系统 relation_frequency = 1 # 关系频率,麦麦构建关系的频率 + [chat] #麦麦的聊天通用设置 focus_value = 1 # 麦麦的专注思考能力,越低越容易专注,消耗token也越多