Allow channel-access and channel-mode check for channels people are not in
This commit is contained in:
parent
73aa55b866
commit
ced59a0f74
2 changed files with 10 additions and 4 deletions
|
@ -39,6 +39,10 @@ class ConfigChannelTarget(object):
|
||||||
channel_id = self._get_id()
|
channel_id = self._get_id()
|
||||||
self._bot.database.channel_settings.delete(channel_id, setting)
|
self._bot.database.channel_settings.delete(channel_id, setting)
|
||||||
|
|
||||||
|
def get_user_setting(self, user_id, setting, default=None):
|
||||||
|
return self.bot.database.user_channel_settings.get(user_id,
|
||||||
|
self._get_id(), setting, default)
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def _to_context(self, server, channel, user, context_desc):
|
def _to_context(self, server, channel, user, context_desc):
|
||||||
context_desc_lower = context_desc.lower()
|
context_desc_lower = context_desc.lower()
|
||||||
|
@ -144,22 +148,22 @@ class Module(ModuleManager.BaseModule):
|
||||||
target = event["user"]
|
target = event["user"]
|
||||||
elif context == "channelset":
|
elif context == "channelset":
|
||||||
if name:
|
if name:
|
||||||
event["check_assert"](permission_check)
|
|
||||||
|
|
||||||
if name in event["server"].channels:
|
if name in event["server"].channels:
|
||||||
target = event["server"].channels.get(name)
|
target = event["server"].channels.get(name)
|
||||||
else:
|
else:
|
||||||
|
event["check_assert"]
|
||||||
target = ConfigChannelTarget(self.bot, event["server"],
|
target = ConfigChannelTarget(self.bot, event["server"],
|
||||||
name)
|
name)
|
||||||
else:
|
else:
|
||||||
if event["is_channel"]:
|
if event["is_channel"]:
|
||||||
event["check_assert"](
|
|
||||||
utils.Check("channel-mode", "o")|permission_check)
|
|
||||||
target = event["target"]
|
target = event["target"]
|
||||||
else:
|
else:
|
||||||
raise utils.EventError(
|
raise utils.EventError(
|
||||||
"Cannot change config for current channel when in "
|
"Cannot change config for current channel when in "
|
||||||
"private message")
|
"private message")
|
||||||
|
event["check_assert"](permission_check|
|
||||||
|
utils.Check("channel-access", "set")|
|
||||||
|
utils.Check("channel-mode", "o"))
|
||||||
elif context == "serverset" or context == "botset":
|
elif context == "serverset" or context == "botset":
|
||||||
event["check_assert"](permission_check)
|
event["check_assert"](permission_check)
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,8 @@ class MultiCheck(object):
|
||||||
return self
|
return self
|
||||||
def requests(self):
|
def requests(self):
|
||||||
return self._requests[:]
|
return self._requests[:]
|
||||||
|
def __or__(self, other: "Check"):
|
||||||
|
return MultiCheck(self._requests+[(other.request, other.args)])
|
||||||
class Check(object):
|
class Check(object):
|
||||||
def __init__(self, request: str, *args: str):
|
def __init__(self, request: str, *args: str):
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
Loading…
Reference in a new issue