aboutsummaryrefslogtreecommitdiff
path: root/modules/set.py
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/set.py
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/set.py')
-rw-r--r--modules/set.py15
1 files changed, 11 insertions, 4 deletions
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: