Skip to content

Commit

Permalink
add 'module-blacklist/whitelist' to bot.conf - use that as well as DB…
Browse files Browse the repository at this point in the history
… setting
  • Loading branch information
jesopo committed Jun 1, 2019
1 parent 5077bad commit e5c11f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions bot.conf.example
Expand Up @@ -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 =

Expand Down
14 changes: 12 additions & 2 deletions src/IRCBot.py
Expand Up @@ -62,8 +62,18 @@ def trigger(self,

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)

Expand Down

0 comments on commit e5c11f4

Please sign in to comment.