aboutsummaryrefslogtreecommitdiff
path: root/modules/check_mode.py
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-14 11:42:12 +0100
committerGravatar jesopo2019-06-14 11:42:12 +0100
commitd7fa2cfa24439e86483139f2823e819c67321aaf (patch)
tree0e100e5f6d26180da5f276a5c9c5ade0a90cfcc6 /modules/check_mode.py
parentUpdate CHANGELOG.md (diff)
signature
Catch `yield`s in command callbacks for e.g. permission checks
Diffstat (limited to 'modules/check_mode.py')
-rw-r--r--modules/check_mode.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/check_mode.py b/modules/check_mode.py
index d31f836e..add90cc8 100644
--- a/modules/check_mode.py
+++ b/modules/check_mode.py
@@ -13,9 +13,7 @@ LOWHIGH = {
"help": "Set which channel mode is considered to be 'high' access",
"example": "o"})
class Module(ModuleManager.BaseModule):
- @utils.hook("preprocess.command")
- def preprocess_command(self, event):
- require_mode = event["hook"].get_kwarg("require_mode")
+ def _check_command(self, event, require_mode):
if event["is_channel"] and require_mode:
if require_mode.lower() in LOWHIGH:
require_mode = event["target"].get_setting(
@@ -27,3 +25,13 @@ class Module(ModuleManager.BaseModule):
return "You do not have permission to do this"
else:
return utils.consts.PERMISSION_FORCE_SUCCESS
+
+ @utils.hook("preprocess.command")
+ def preprocess_command(self, event):
+ require_mode = event["hook"].get_kwarg("require_mode")
+ if not require_mode == None:
+ return self._check_command(event, require_mode)
+
+ @utils.hook("check.command.channel-mode")
+ def check_command(self, event):
+ return self._check_command(event, event["check_args"][0])