make sure we always have a channel when require_mode/access is present
This commit is contained in:
parent
49f14caf42
commit
c9d07b6032
2 changed files with 6 additions and 2 deletions
|
@ -14,13 +14,15 @@ class Module(ModuleManager.BaseModule):
|
||||||
return (require_access in access or "*" in access) and identified
|
return (require_access in access or "*" in access) and identified
|
||||||
|
|
||||||
def _command_check(self, event, channel, require_access):
|
def _command_check(self, event, channel, require_access):
|
||||||
if channel and require_access:
|
if channel:
|
||||||
if self._has_channel_access(channel, event["user"],
|
if self._has_channel_access(channel, event["user"],
|
||||||
require_access):
|
require_access):
|
||||||
return utils.consts.PERMISSION_FORCE_SUCCESS, None
|
return utils.consts.PERMISSION_FORCE_SUCCESS, None
|
||||||
else:
|
else:
|
||||||
return (utils.consts.PERMISSION_ERROR,
|
return (utils.consts.PERMISSION_ERROR,
|
||||||
"You do not have permission to do this")
|
"You do not have permission to do this")
|
||||||
|
else:
|
||||||
|
raise ValueError("_command_check requires a channel")
|
||||||
|
|
||||||
@utils.hook("preprocess.command")
|
@utils.hook("preprocess.command")
|
||||||
def preprocess_command(self, event):
|
def preprocess_command(self, event):
|
||||||
|
|
|
@ -13,7 +13,7 @@ LOWHIGH = {
|
||||||
"Set which channel mode is considered to be 'high' access", example="o"))
|
"Set which channel mode is considered to be 'high' access", example="o"))
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def _check_command(self, event, channel, require_mode):
|
def _check_command(self, event, channel, require_mode):
|
||||||
if channel and require_mode:
|
if channel:
|
||||||
if require_mode in LOWHIGH:
|
if require_mode in LOWHIGH:
|
||||||
require_mode = channel.get_setting("mode-%s" % require_mode,
|
require_mode = channel.get_setting("mode-%s" % require_mode,
|
||||||
LOWHIGH[require_mode])
|
LOWHIGH[require_mode])
|
||||||
|
@ -31,6 +31,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
"You do not have permission to do this")
|
"You do not have permission to do this")
|
||||||
else:
|
else:
|
||||||
return utils.consts.PERMISSION_FORCE_SUCCESS, None
|
return utils.consts.PERMISSION_FORCE_SUCCESS, None
|
||||||
|
else:
|
||||||
|
raise ValueError("_command_check requires a channel")
|
||||||
|
|
||||||
@utils.hook("preprocess.command")
|
@utils.hook("preprocess.command")
|
||||||
def preprocess_command(self, event):
|
def preprocess_command(self, event):
|
||||||
|
|
Loading…
Reference in a new issue