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()
|
||||
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):
|
||||
def _to_context(self, server, channel, user, context_desc):
|
||||
context_desc_lower = context_desc.lower()
|
||||
|
@ -144,22 +148,22 @@ class Module(ModuleManager.BaseModule):
|
|||
target = event["user"]
|
||||
elif context == "channelset":
|
||||
if name:
|
||||
event["check_assert"](permission_check)
|
||||
|
||||
if name in event["server"].channels:
|
||||
target = event["server"].channels.get(name)
|
||||
else:
|
||||
event["check_assert"]
|
||||
target = ConfigChannelTarget(self.bot, event["server"],
|
||||
name)
|
||||
else:
|
||||
if event["is_channel"]:
|
||||
event["check_assert"](
|
||||
utils.Check("channel-mode", "o")|permission_check)
|
||||
target = event["target"]
|
||||
else:
|
||||
raise utils.EventError(
|
||||
"Cannot change config for current channel when in "
|
||||
"private message")
|
||||
event["check_assert"](permission_check|
|
||||
utils.Check("channel-access", "set")|
|
||||
utils.Check("channel-mode", "o"))
|
||||
elif context == "serverset" or context == "botset":
|
||||
event["check_assert"](permission_check)
|
||||
|
||||
|
|
|
@ -193,6 +193,8 @@ class MultiCheck(object):
|
|||
return self
|
||||
def requests(self):
|
||||
return self._requests[:]
|
||||
def __or__(self, other: "Check"):
|
||||
return MultiCheck(self._requests+[(other.request, other.args)])
|
||||
class Check(object):
|
||||
def __init__(self, request: str, *args: str):
|
||||
self.request = request
|
||||
|
|
Loading…
Reference in a new issue