aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2018-12-05 12:13:29 +0000
committerGravatar jesopo2018-12-05 12:13:29 +0000
commit764e1e3245fc6d1deac9042fad128362be59d042 (patch)
tree182409e19093aa1e79368ef604a8f2a2fcf11afb /modules
parentDon't try to call .isdigit() on an int object in coin.py.lottery_buy (diff)
signature
Prevent setting values to array settings and prevent adding to non-array
settings
Diffstat (limited to 'modules')
-rw-r--r--modules/github.py2
-rw-r--r--modules/set.py15
2 files changed, 12 insertions, 5 deletions
diff --git a/modules/github.py b/modules/github.py
index ed27e1a9..c147ae42 100644
--- a/modules/github.py
+++ b/modules/github.py
@@ -28,7 +28,7 @@ COMMENT_ACTIONS = {
@utils.export("channelset", {"setting": "github-hook",
"help": ("Disable/Enable showing BitBot's github commits in the "
- "current channel")})
+ "current channel"), "array": True})
@utils.export("channelset", {"setting": "github-hide-prefix",
"help": "Hide/show command-like prefix on Github hook outputs",
"validate": utils.bool_or_none})
diff --git a/modules/set.py b/modules/set.py
index 24a234e6..d7310cc3 100644
--- a/modules/set.py
+++ b/modules/set.py
@@ -7,15 +7,22 @@ CHANNELSETADD_HELP = ("Add to a specified channel setting for the "
class Module(ModuleManager.BaseModule):
def _set(self, category, event, target, array):
settings = self.exports.get_all(category)
- settings_dict = dict([(setting["setting"], setting
- ) for setting in settings])
+ settings_dict = {setting["setting"]: setting for setting in settings}
if len(event["args_split"]) > 1:
setting = event["args_split"][0].lower()
if setting in settings_dict:
+ setting_options = settings_dict[setting]
+ if not setting_options.get("array", False) == array:
+ if array:
+ raise utils.EventError(
+ "Can't add to a non-array setting")
+ else:
+ raise utils.EventError(
+ "You can only 'add' to an array setting")
+
value = " ".join(event["args_split"][1:])
- value = settings_dict[setting].get("validate",
- lambda x: x)(value)
+ value = setting_options.get("validate", lambda x: x)(value)
if not value == None:
if array: