diff options
| author | 2019-01-30 19:20:11 +0000 | |
|---|---|---|
| committer | 2019-01-30 19:20:11 +0000 | |
| commit | 8ac989fa9676eac830b110e1af64197b83e84ad5 (patch) | |
| tree | 89180d2c567008953cffd8683cd3f72154aad5ba /modules | |
| parent | Break when we've found a suitable command hook (commands.py) (diff) | |
| signature | ||
check we have a `channel_arg` kwarg before parsing it as an int
(channel_access.py)
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/channel_access.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/modules/channel_access.py b/modules/channel_access.py index 555a2a3c..f90d067e 100644 --- a/modules/channel_access.py +++ b/modules/channel_access.py @@ -21,17 +21,18 @@ class Module(ModuleManager.BaseModule): else: return "You do not have permission to do this" else: - channel_arg_index = int(event["hook"].get_kwarg("channel_arg")) - channel_name = event["args_split"][channel_arg_index] - if channel_name in event["server"].channels: - channel = event["server"].channels.get(channel_name) - if self._has_channel_access(channel, event["user"], - require_access): - return utils.consts.PERMISSION_FORCE_SUCCESS + channel_arg_index = event["hook"].get_kwarg("channel_arg", None) + if not channel_arg_index == None: + channel_name = event["args_split"][int(channel_arg_index)] + if channel_name in event["server"].channels: + channel = event["server"].channels.get(channel_name) + if self._has_channel_access(channel, event["user"], + require_access): + return utils.consts.PERMISSION_FORCE_SUCCESS + else: + return "You do not have permission to do this" else: - return "You do not have permission to do this" - else: - return "I'm not in that channel" + return "I'm not in that channel" @utils.hook("get.haschannelaccess") def has_channel_access(self, event): |
