aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.conf.example6
-rw-r--r--src/IRCBot.py14
2 files changed, 18 insertions, 2 deletions
diff --git a/bot.conf.example b/bot.conf.example
index 69e2af81..9ce0cbbb 100644
--- a/bot.conf.example
+++ b/bot.conf.example
@@ -14,6 +14,12 @@ api-port =
# the default channel BitBot automatically joins
bot-channel =
+# module blacklist and whitelist. comma-separated. leave both empty to load all
+# modules, leave whitelist empty to load all but blacklisted modules, populate
+# whitelist to not load all modules by default.
+module-blacklist =
+module-whitelist =
+
# https://openweathermap.org/api
openweathermap-api-key =
diff --git a/src/IRCBot.py b/src/IRCBot.py
index 859b052d..37559d95 100644
--- a/src/IRCBot.py
+++ b/src/IRCBot.py
@@ -62,8 +62,18 @@ class Bot(object):
def load_modules(self, safe: bool=False
) -> typing.Tuple[typing.List[str], typing.List[str]]:
- whitelist = self.get_setting("module-whitelist", [])
- blacklist = self.get_setting("module-blacklist", [])
+ db_blacklist = set(self.get_setting("module-blacklist", []))
+ db_whitelist = set(self.get_setting("module-whitelist", []))
+
+ conf_blacklist = self.config.get("module-blacklist", "").split(",")
+ conf_whitelist = self.config.get("module-whitelist", "").split(",")
+
+ conf_blacklist = set(filter(None, conf_blacklist))
+ conf_whitelist = set(filter(None, conf_whitelist))
+
+ blacklist = db_blacklist|conf_blacklist
+ whitelist = db_whitelist|conf_whitelist
+
return self.modules.load_modules(self, whitelist=whitelist,
blacklist=blacklist, safe=safe)