From 6f6c3af302719256899fa15ca60e16a043f63cf6 Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Thu, 21 Dec 2023 18:04:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/plugin/host.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/plugin/host.py b/pkg/plugin/host.py index 889e57f6..d65a0916 100644 --- a/pkg/plugin/host.py +++ b/pkg/plugin/host.py @@ -443,6 +443,8 @@ class PluginHost: event_context = EventContext(event_name) logging.debug("触发事件: {} ({})".format(event_name, event_context.eid)) + + emitted_plugins = [] for plugin in iter_plugins(): if not plugin['enabled']: @@ -460,6 +462,8 @@ class PluginHost: if 'hooks' not in plugin or event_name not in plugin['hooks']: continue + emitted_plugins.append(plugin) + hooks = [] if event_name in plugin["hooks"]: hooks = plugin["hooks"][event_name] @@ -487,6 +491,31 @@ class PluginHost: logging.debug("事件 {} ({}) 处理完毕,返回值: {}".format(event_name, event_context.eid, event_context.__return_value__)) + if len(emitted_plugins) > 0: + + plugins_info = [] + + for plugin in emitted_plugins: + name = plugin['name'] + meta = metadata.get_plugin_metadata(get_plugin_path_name_by_plugin_name(name)) + remote = meta['source'] if meta != {} else "" + author = plugin['author'] + version = plugin['version'] + + plugins_info.append( + { + "name": name, + "remote": remote, + "author": author, + "version": version, + } + ) + + context.get_center_v2_api().usage.post_event_record( + plugins=plugins_info, + event_name=event_name, + ) + return event_context if __name__ == "__main__":