check-mode and channel-access should reference the computed target, not

"current channel"
This commit is contained in:
jesopo 2019-06-18 07:59:53 +01:00
parent a2a1a038b5
commit 88e796e334
2 changed files with 11 additions and 5 deletions

View file

@ -13,7 +13,7 @@ LOWHIGH = {
"help": "Set which channel mode is considered to be 'high' access", "help": "Set which channel mode is considered to be 'high' access",
"example": "o"}) "example": "o"})
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
def _check_command(self, event, require_mode): def _check_command(self, event, channel, require_mode):
if event["is_channel"] and require_mode: if event["is_channel"] and require_mode:
if require_mode.lower() in LOWHIGH: if require_mode.lower() in LOWHIGH:
require_mode = event["target"].get_setting( require_mode = event["target"].get_setting(
@ -30,8 +30,14 @@ class Module(ModuleManager.BaseModule):
def preprocess_command(self, event): def preprocess_command(self, event):
require_mode = event["hook"].get_kwarg("require_mode") require_mode = event["hook"].get_kwarg("require_mode")
if not require_mode == None: if not require_mode == None:
return self._check_command(event, require_mode) return self._check_command(event, event["target"], require_mode)
@utils.hook("check.command.channel-mode") @utils.hook("check.command.channel-mode")
def check_command(self, event): def check_command(self, event):
return self._check_command(event, event["request_args"][0]) target = event["target"]
mode = event["request_args"][0]
if len(event["request_args"]) > 1:
target = event["request_args"][0]
mode = event["request_args"][1]
return self._check_command(event, target, mode)

View file

@ -167,8 +167,8 @@ class Module(ModuleManager.BaseModule):
"Cannot change config for current channel when in " "Cannot change config for current channel when in "
"private message") "private message")
event["check_assert"](permission_check| event["check_assert"](permission_check|
utils.Check("channel-access", "set")| utils.Check("channel-access", target, "set")|
utils.Check("channel-mode", "o")) utils.Check("channel-mode", target, "o"))
elif context == "serverset" or context == "botset": elif context == "serverset" or context == "botset":
event["check_assert"](permission_check) event["check_assert"](permission_check)