check we have a channel_arg kwarg before parsing it as an int

(channel_access.py)
This commit is contained in:
jesopo 2019-01-30 19:20:11 +00:00
parent 0e66921d34
commit 8ac989fa96

View file

@ -21,17 +21,18 @@ class Module(ModuleManager.BaseModule):
else: else:
return "You do not have permission to do this" return "You do not have permission to do this"
else: else:
channel_arg_index = int(event["hook"].get_kwarg("channel_arg")) channel_arg_index = event["hook"].get_kwarg("channel_arg", None)
channel_name = event["args_split"][channel_arg_index] if not channel_arg_index == None:
if channel_name in event["server"].channels: channel_name = event["args_split"][int(channel_arg_index)]
channel = event["server"].channels.get(channel_name) if channel_name in event["server"].channels:
if self._has_channel_access(channel, event["user"], channel = event["server"].channels.get(channel_name)
require_access): if self._has_channel_access(channel, event["user"],
return utils.consts.PERMISSION_FORCE_SUCCESS require_access):
return utils.consts.PERMISSION_FORCE_SUCCESS
else:
return "You do not have permission to do this"
else: else:
return "You do not have permission to do this" return "I'm not in that channel"
else:
return "I'm not in that channel"
@utils.hook("get.haschannelaccess") @utils.hook("get.haschannelaccess")
def has_channel_access(self, event): def has_channel_access(self, event):