diff options
| author | 2018-11-10 22:32:44 +0000 | |
|---|---|---|
| committer | 2018-11-10 22:32:44 +0000 | |
| commit | dbe0d6cdab2e801d60d952a77be4183e29fd03c0 (patch) | |
| tree | 5b20ba109cf930f29f16bc7693ad45922389ab8c /modules | |
| parent | Add basic access controls to modules/rest_api.py (diff) | |
| signature | ||
Treat "low"/"high" as synonymous with "v"/"o" but with a settable override in
modules/check_mode.py
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/check_mode.py | 14 | ||||
| -rw-r--r-- | modules/set.py | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/modules/check_mode.py b/modules/check_mode.py index f4922549..cdc1dc12 100644 --- a/modules/check_mode.py +++ b/modules/check_mode.py @@ -1,11 +1,23 @@ - from src import ModuleManager, utils +LOWHIGH = { + "low": "v", + "high": "o" +} +@utils.export("channelset", {"setting": "mode-low", + "help": "Set which channel mode is considered to be 'low' access") +@utils.export("channelset", {"setting": "mode-high", + "help": "Set which channel mode is considered to be 'high' access") class Module(ModuleManager.BaseModule): @utils.hook("preprocess.command") def preprocess_command(self, event): require_mode = event["hook"].get_kwarg("require_mode") if event["is_channel"] and require_mode: + if require_mode.lower() in LOWHIGH: + require_mode = event["target"].get_setting( + "mode-%s" % require_mode.lower(), + LOWHIGH[require_mode.lower()]) + if not event["target"].mode_or_above(event["user"], require_mode): return "You do not have permission to do this" diff --git a/modules/set.py b/modules/set.py index ceef713a..8516e443 100644 --- a/modules/set.py +++ b/modules/set.py @@ -51,11 +51,11 @@ class Module(ModuleManager.BaseModule): self._set("set", event, event["user"], event["command"]=="setadd") @utils.hook("received.command.channelset", channel_only=True, - require_mode="o", help=CHANNELSET_HELP) + require_mode="high", help=CHANNELSET_HELP) @utils.hook("received.command.channelsetoverride", channel_only=True, permission="channelsetoverride", help=CHANNELSET_HELP) @utils.hook("received.command.channelsetadd", channel_only=True, - require_mode="o", help=CHANNELSETADD_HELP) + require_mode="high", help=CHANNELSETADD_HELP) @utils.hook("received.command.channelsetaddoverride", channel_only=True, permission="channelsetoverride", help=CHANNELSETADD_HELP) def channel_set(self, event): |
