From 585f9e5952d754c20aaf70fbe4f4a8709d9d5ed8 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Thu, 26 May 2022 19:47:30 -0700 Subject: [PATCH] Add "enabled" config option If a plugin has enabled = false, it will not load. Signed-off-by: Alek Ratzloff --- omnibot/bot.py | 1 + omnibot/plugin.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/omnibot/bot.py b/omnibot/bot.py index 1d0a3bd..a5f241a 100644 --- a/omnibot/bot.py +++ b/omnibot/bot.py @@ -19,6 +19,7 @@ class Bot: self.__plugins = [ plugin.load_plugin(server_config, config) for config in server_config.plugins + if config.get("enabled", True) ] # TODO - this may not be needed self.__channels: Set[str] = set() diff --git a/omnibot/plugin.py b/omnibot/plugin.py index 48ee2a0..630b918 100644 --- a/omnibot/plugin.py +++ b/omnibot/plugin.py @@ -23,6 +23,10 @@ class Plugin: else: return self.server_config.channels + @property + def enabled(self) -> bool: + return self.plugin_config.get("enabled", True) + @property def plugin_config(self) -> PluginConfig: return self.__plugin_config