don't just remove the first key in a JOIN when there's a blacklisted channel
This commit is contained in:
parent
6e4ec91003
commit
1e16cf601e
1 changed files with 16 additions and 11 deletions
|
@ -10,21 +10,26 @@ class Module(ModuleManager.BaseModule):
|
||||||
channels = event["line"].args[0].split(",")
|
channels = event["line"].args[0].split(",")
|
||||||
keys = event["line"].args[1:]
|
keys = event["line"].args[1:]
|
||||||
|
|
||||||
remove = []
|
changed = False
|
||||||
|
channels_out = []
|
||||||
for channel_name in channels:
|
for channel_name in channels:
|
||||||
id = event["server"].channels.get_id(channel_name, create=False)
|
id = event["server"].channels.get_id(channel_name, create=False)
|
||||||
if not id == None:
|
if not id == None and self.bot.database.channel_settings.get(
|
||||||
if self.bot.database.channel_settings.get(id, "blacklist",
|
id, "blacklist", False):
|
||||||
False):
|
changed = True
|
||||||
remove.append(channel_name)
|
|
||||||
if keys:
|
if keys:
|
||||||
keys.pop(0)
|
keys.pop(0)
|
||||||
for channel_name in remove:
|
else:
|
||||||
channels.remove(channel_name)
|
key = None
|
||||||
|
if keys:
|
||||||
|
key = keys.pop(0)
|
||||||
|
channels_out.append([channel_name, key])
|
||||||
|
|
||||||
if remove:
|
if changed:
|
||||||
if not channels:
|
if not channels_out:
|
||||||
event["line"].invalidate()
|
event["line"].invalidate()
|
||||||
else:
|
else:
|
||||||
|
channels = [c[0] for c in channels_out]
|
||||||
|
keys = [c[1] for c in channels_out if c[1]]
|
||||||
event["line"].args[0] = ",".join(channels)
|
event["line"].args[0] = ",".join(channels)
|
||||||
event["line"].args[1:] = keys
|
event["line"].args[1:] = keys
|
||||||
|
|
Loading…
Reference in a new issue