allow for plugins ot clean up after themselves

master
BuildTools 3 years ago
parent 24db5c9a45
commit 77464883b1
  1. 1
      client.py
  2. 4
      plugin_manager.py

@ -11,6 +11,7 @@ class client():
self.last_sequence = None self.last_sequence = None
self.session_id = None self.session_id = None
self.user = None self.user = None
self.logger.write(f"loading config from {config_path}")
with open(config_path, "r") as conf_fd: with open(config_path, "r") as conf_fd:
self.config = json.loads(conf_fd.read()) self.config = json.loads(conf_fd.read())
self.plugman = plugin_manager(self.logger, plugin_path = self.config["plugin_path"]) self.plugman = plugin_manager(self.logger, plugin_path = self.config["plugin_path"])

@ -29,3 +29,7 @@ class plugin_manager():
getattr(plugin, "run")(event, ctx, bot) getattr(plugin, "run")(event, ctx, bot)
except Exception as e: except Exception as e:
bot.logger.write(e) bot.logger.write(e)
def __del__(self):
for plugin in self.plugins_loaded:
if hasattr(plugin, "clean"):
getattr(plugin, "clean")()
Loading…
Cancel
Save