'mode_prefixes' -> prefix_modes and prefix_symbols
This commit is contained in:
parent
6c1ac52fde
commit
98207be7b1
3 changed files with 18 additions and 17 deletions
|
@ -70,12 +70,13 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
match = re.search(RE_PREFIXES, isupport_line)
|
match = re.search(RE_PREFIXES, isupport_line)
|
||||||
if match:
|
if match:
|
||||||
event["server"].mode_prefixes.clear()
|
event["server"].prefix_symbols.clear()
|
||||||
|
event["server"].prefix_modes.clear()
|
||||||
modes = match.group(1)
|
modes = match.group(1)
|
||||||
prefixes = match.group(2)
|
symbols = match.group(2)
|
||||||
for i, prefix in enumerate(prefixes):
|
for symbol, mode in zip(symbols, modes):
|
||||||
if i < len(modes):
|
event["server"].prefix_symbols[symbol] = mode
|
||||||
event["server"].mode_prefixes[prefix] = modes[i]
|
event["server"].prefix_modes[mode] = symbol
|
||||||
match = re.search(RE_CHANMODES, isupport_line)
|
match = re.search(RE_CHANMODES, isupport_line)
|
||||||
if match:
|
if match:
|
||||||
event["server"].channel_modes = list(match.group(4))
|
event["server"].channel_modes = list(match.group(4))
|
||||||
|
@ -145,8 +146,8 @@ class Module(ModuleManager.BaseModule):
|
||||||
for nickname in nicknames:
|
for nickname in nicknames:
|
||||||
modes = set([])
|
modes = set([])
|
||||||
|
|
||||||
while nickname[0] in event["server"].mode_prefixes:
|
while nickname[0] in event["server"].prefix_symbols:
|
||||||
modes.add(event["server"].mode_prefixes[nickname[0]])
|
modes.add(event["server"].prefix_symbols[nickname[0]])
|
||||||
nickname = nickname[1:]
|
nickname = nickname[1:]
|
||||||
|
|
||||||
if "userhost-in-names" in event["server"].capabilities:
|
if "userhost-in-names" in event["server"].capabilities:
|
||||||
|
@ -336,8 +337,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
for mode in chunk[1:]:
|
for mode in chunk[1:]:
|
||||||
if mode in event["server"].channel_modes:
|
if mode in event["server"].channel_modes:
|
||||||
channel.change_mode(remove, mode)
|
channel.change_mode(remove, mode)
|
||||||
elif mode in event["server"].mode_prefixes.values(
|
elif mode in event["server"].prefix_modes and len(args):
|
||||||
) and len(args):
|
|
||||||
channel.change_mode(remove, mode, args.pop(0))
|
channel.change_mode(remove, mode, args.pop(0))
|
||||||
else:
|
else:
|
||||||
args.pop(0)
|
args.pop(0)
|
||||||
|
|
|
@ -36,8 +36,7 @@ class Channel(IRCObject.Object):
|
||||||
def remove_user(self, user):
|
def remove_user(self, user):
|
||||||
self.users.remove(user)
|
self.users.remove(user)
|
||||||
for mode in list(self.modes.keys()):
|
for mode in list(self.modes.keys()):
|
||||||
if mode in self.server.mode_prefixes.values(
|
if mode in self.server.prefix_modes and user in self.modes[mode]:
|
||||||
) and user in self.modes[mode]:
|
|
||||||
self.modes[mode].discard(user)
|
self.modes[mode].discard(user)
|
||||||
if not len(self.modes[mode]):
|
if not len(self.modes[mode]):
|
||||||
del self.modes[mode]
|
del self.modes[mode]
|
||||||
|
@ -48,7 +47,7 @@ class Channel(IRCObject.Object):
|
||||||
if not mode in self.modes:
|
if not mode in self.modes:
|
||||||
self.modes[mode] = set([])
|
self.modes[mode] = set([])
|
||||||
if arg:
|
if arg:
|
||||||
if mode in self.server.mode_prefixes.values():
|
if mode in self.server.prefix_modes:
|
||||||
user = self.server.get_user(arg)
|
user = self.server.get_user(arg)
|
||||||
if user:
|
if user:
|
||||||
self.modes[mode].add(user)
|
self.modes[mode].add(user)
|
||||||
|
@ -58,7 +57,7 @@ class Channel(IRCObject.Object):
|
||||||
if not arg:
|
if not arg:
|
||||||
del self.modes[mode]
|
del self.modes[mode]
|
||||||
else:
|
else:
|
||||||
if mode in self.server.mode_prefixes.values():
|
if mode in self.server.prefix_modes:
|
||||||
user = self.server.get_user(arg)
|
user = self.server.get_user(arg)
|
||||||
if user:
|
if user:
|
||||||
self.modes[mode].discard(user)
|
self.modes[mode].discard(user)
|
||||||
|
@ -123,7 +122,7 @@ class Channel(IRCObject.Object):
|
||||||
self.server.send_part(self.name, reason)
|
self.server.send_part(self.name, reason)
|
||||||
|
|
||||||
def mode_or_above(self, user, mode):
|
def mode_or_above(self, user, mode):
|
||||||
mode_orders = list(self.server.mode_prefixes.values())
|
mode_orders = list(self.server.prefix_modes)
|
||||||
mode_index = mode_orders.index(mode)
|
mode_index = mode_orders.index(mode)
|
||||||
for mode in mode_orders[:mode_index+1]:
|
for mode in mode_orders[:mode_index+1]:
|
||||||
if user in self.modes.get(mode, []):
|
if user in self.modes.get(mode, []):
|
||||||
|
|
|
@ -40,8 +40,10 @@ class Server(IRCObject.Object):
|
||||||
self.channels = {}
|
self.channels = {}
|
||||||
|
|
||||||
self.own_modes = {}
|
self.own_modes = {}
|
||||||
self.mode_prefixes = collections.OrderedDict(
|
self.prefix_symbols = collections.OrderedDict(
|
||||||
{"@": "o", "+": "v"})
|
(("@", "o"), ("+", "v")))
|
||||||
|
self.prefix_modes = collections.OrderedDict(
|
||||||
|
(("o", "@"), ("v", "+")))
|
||||||
self.channel_modes = []
|
self.channel_modes = []
|
||||||
self.channel_types = ["#"]
|
self.channel_types = ["#"]
|
||||||
self.case_mapping = "rfc1459"
|
self.case_mapping = "rfc1459"
|
||||||
|
@ -260,8 +262,8 @@ class Server(IRCObject.Object):
|
||||||
if len(encoded) > 450:
|
if len(encoded) > 450:
|
||||||
encoded = encoded[:450]
|
encoded = encoded[:450]
|
||||||
self.buffered_lines.append(encoded + b"\r\n")
|
self.buffered_lines.append(encoded + b"\r\n")
|
||||||
|
|
||||||
self.bot.log.debug(">%s | %s", [str(self), encoded.decode("utf8")])
|
self.bot.log.debug(">%s | %s", [str(self), encoded.decode("utf8")])
|
||||||
|
|
||||||
def _send(self):
|
def _send(self):
|
||||||
if not len(self.write_buffer):
|
if not len(self.write_buffer):
|
||||||
self.write_buffer = self.buffered_lines.pop(0)
|
self.write_buffer = self.buffered_lines.pop(0)
|
||||||
|
|
Loading…
Reference in a new issue