diff options
| author | 2020-02-03 23:01:36 +0000 | |
|---|---|---|
| committer | 2020-02-03 23:01:36 +0000 | |
| commit | 96a74747dc700d8932d6f19287a3ed2ad30db68c (patch) | |
| tree | fe31afd9fe810bdfa4c6a62dfe84a8e1e72e8b8b /src/core_modules/modules.py | |
| parent | store timestamp and current git commit when loading a module (diff) | |
| signature | ||
implement !modinfo
closes #234
Diffstat (limited to 'src/core_modules/modules.py')
| -rw-r--r-- | src/core_modules/modules.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core_modules/modules.py b/src/core_modules/modules.py index a93afaea..1259c520 100644 --- a/src/core_modules/modules.py +++ b/src/core_modules/modules.py @@ -18,6 +18,30 @@ class Module(ModuleManager.BaseModule): raise utils.EventError("Failed to reload module '%s': %s" % ( name, str(e))) + @utils.hook("received.command.modinfo") + @utils.spec("!<module>string") + def info(self, event): + name = event["spec"][0] + if not name in self.bot.modules.modules: + raise + module = self.bot.modules.modules[name] + + event_calls = 0 + for event_name, hooks in self.events.all_hooks().items(): + for hook in hooks: + if hook.context == module.context: + event_calls += hook.call_count + + event_str = "event" if event_calls == 1 else "events" + + loaded_at = utils.datetime.format.datetime_human(module.loaded_at) + if module.commit: + loaded_at = "%s (git @%s)" % (loaded_at, module.commit) + + event["stdout"].write("%s: '%s' was loaded at %s and has handled %d %s" + % (event["user"].nickname, module.name, loaded_at, event_calls, + event_str)) + @utils.hook("received.command.loadmodule", min_args=1) def load(self, event): """ |
