From 77464883b1dcd00b01421363798ab174e50f1c96 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 30 Jan 2022 03:23:30 -0500 Subject: [PATCH] allow for plugins ot clean up after themselves --- client.py | 1 + plugin_manager.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client.py b/client.py index 81f0ae9..4164a65 100644 --- a/client.py +++ b/client.py @@ -11,6 +11,7 @@ class client(): self.last_sequence = None self.session_id = None self.user = None + self.logger.write(f"loading config from {config_path}") with open(config_path, "r") as conf_fd: self.config = json.loads(conf_fd.read()) self.plugman = plugin_manager(self.logger, plugin_path = self.config["plugin_path"]) diff --git a/plugin_manager.py b/plugin_manager.py index 0fd2163..8f1b945 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -28,4 +28,8 @@ class plugin_manager(): try: getattr(plugin, "run")(event, ctx, bot) except Exception as e: - bot.logger.write(e) \ No newline at end of file + bot.logger.write(e) + def __del__(self): + for plugin in self.plugins_loaded: + if hasattr(plugin, "clean"): + getattr(plugin, "clean")() \ No newline at end of file