diff --git a/robot.py b/robot.py index 881edbf..af77ed9 100644 --- a/robot.py +++ b/robot.py @@ -569,6 +569,7 @@ class Robot: self.LOG.info(f"夜间休眠时间(00:30-05:00),忽略消息: {msg}") return False message_plugins = self.plugin_registry.get_plugins_by_type(MessagePluginInterface) + message_plugins = self._sort_message_plugins(message_plugins) if not message_plugins: return False @@ -608,6 +609,26 @@ class Robot: return False + @staticmethod + def _sort_message_plugins(message_plugins): + """将兜底型插件放到最后执行,避免影响其他插件命中。""" + if not message_plugins: + return [] + + def is_fallback_plugin(plugin): + feature_key = str(getattr(plugin, "feature_key", "") or "").strip().upper() + module_name = str(getattr(plugin.__class__, "__module__", "") or "").lower() + plugin_name = str(getattr(plugin, "name", "") or "").strip().lower() + return ( + feature_key == "AI_AUTO_RESPONSE" + or "plugins.ai_auto_response" in module_name + or plugin_name in {"小牛群聊bot", "ai_auto_response"} + ) + + normal_plugins = [plugin for plugin in message_plugins if not is_fallback_plugin(plugin)] + fallback_plugins = [plugin for plugin in message_plugins if is_fallback_plugin(plugin)] + return normal_plugins + fallback_plugins + def get_all_contacts(self) -> dict: """获取所有联系人信息并返回字典格式 {wxid: nickname}""" try: