Treat "low"/"high" as synonymous with "v"/"o" but with a settable override in
modules/check_mode.py
This commit is contained in:
parent
07c813cc1f
commit
dbe0d6cdab
2 changed files with 15 additions and 3 deletions
|
@ -1,11 +1,23 @@
|
||||||
|
|
||||||
from src import ModuleManager, utils
|
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):
|
class Module(ModuleManager.BaseModule):
|
||||||
@utils.hook("preprocess.command")
|
@utils.hook("preprocess.command")
|
||||||
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 event["is_channel"] and 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"],
|
if not event["target"].mode_or_above(event["user"],
|
||||||
require_mode):
|
require_mode):
|
||||||
return "You do not have permission to do this"
|
return "You do not have permission to do this"
|
||||||
|
|
|
@ -51,11 +51,11 @@ class Module(ModuleManager.BaseModule):
|
||||||
self._set("set", event, event["user"], event["command"]=="setadd")
|
self._set("set", event, event["user"], event["command"]=="setadd")
|
||||||
|
|
||||||
@utils.hook("received.command.channelset", channel_only=True,
|
@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,
|
@utils.hook("received.command.channelsetoverride", channel_only=True,
|
||||||
permission="channelsetoverride", help=CHANNELSET_HELP)
|
permission="channelsetoverride", help=CHANNELSET_HELP)
|
||||||
@utils.hook("received.command.channelsetadd", channel_only=True,
|
@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,
|
@utils.hook("received.command.channelsetaddoverride", channel_only=True,
|
||||||
permission="channelsetoverride", help=CHANNELSETADD_HELP)
|
permission="channelsetoverride", help=CHANNELSETADD_HELP)
|
||||||
def channel_set(self, event):
|
def channel_set(self, event):
|
||||||
|
|
Loading…
Reference in a new issue