2019-05-25 20:40:06 +00:00
|
|
|
#--depends-on commands
|
|
|
|
|
2018-10-03 12:22:37 +00:00
|
|
|
from src import ModuleManager, utils
|
2016-04-18 15:50:19 +00:00
|
|
|
|
2018-11-10 22:32:44 +00:00
|
|
|
LOWHIGH = {
|
|
|
|
"low": "v",
|
|
|
|
"high": "o"
|
|
|
|
}
|
|
|
|
@utils.export("channelset", {"setting": "mode-low",
|
2019-05-23 09:28:14 +00:00
|
|
|
"help": "Set which channel mode is considered to be 'low' access",
|
|
|
|
"example": "v"})
|
2018-11-10 22:32:44 +00:00
|
|
|
@utils.export("channelset", {"setting": "mode-high",
|
2019-05-23 09:28:14 +00:00
|
|
|
"help": "Set which channel mode is considered to be 'high' access",
|
|
|
|
"example": "o"})
|
2018-09-26 17:27:17 +00:00
|
|
|
class Module(ModuleManager.BaseModule):
|
2019-06-18 06:59:53 +00:00
|
|
|
def _check_command(self, event, channel, require_mode):
|
2018-09-30 16:29:09 +00:00
|
|
|
if event["is_channel"] and require_mode:
|
2018-11-10 22:32:44 +00:00
|
|
|
if require_mode.lower() in LOWHIGH:
|
|
|
|
require_mode = event["target"].get_setting(
|
|
|
|
"mode-%s" % require_mode.lower(),
|
|
|
|
LOWHIGH[require_mode.lower()])
|
|
|
|
|
2018-07-02 15:15:26 +00:00
|
|
|
if not event["target"].mode_or_above(event["user"],
|
2018-09-30 19:53:36 +00:00
|
|
|
require_mode):
|
2016-04-18 15:50:19 +00:00
|
|
|
return "You do not have permission to do this"
|
2019-01-28 23:29:52 +00:00
|
|
|
else:
|
|
|
|
return utils.consts.PERMISSION_FORCE_SUCCESS
|
2019-06-14 10:42:12 +00:00
|
|
|
|
|
|
|
@utils.hook("preprocess.command")
|
|
|
|
def preprocess_command(self, event):
|
|
|
|
require_mode = event["hook"].get_kwarg("require_mode")
|
|
|
|
if not require_mode == None:
|
2019-06-18 06:59:53 +00:00
|
|
|
return self._check_command(event, event["target"], require_mode)
|
2019-06-14 10:42:12 +00:00
|
|
|
|
|
|
|
@utils.hook("check.command.channel-mode")
|
|
|
|
def check_command(self, event):
|
2019-06-18 06:59:53 +00:00
|
|
|
target = event["target"]
|
|
|
|
mode = event["request_args"][0]
|
|
|
|
if len(event["request_args"]) > 1:
|
|
|
|
target = event["request_args"][0]
|
|
|
|
mode = event["request_args"][1]
|
|
|
|
|
|
|
|
return self._check_command(event, target, mode)
|