From c4a3baca7d1c38b54c394577045a9ef1a72a637b Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 28 Aug 2017 20:07:12 -0700 Subject: [PATCH] protocols: switch to self.is* --- protocols/clientbot.py | 6 +++--- protocols/inspircd.py | 6 +++--- protocols/ircs2s_common.py | 4 ++-- protocols/ngircd.py | 4 ++-- protocols/p10.py | 4 ++-- protocols/ts6.py | 2 +- protocols/ts6_common.py | 2 +- protocols/unreal.py | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/protocols/clientbot.py b/protocols/clientbot.py index b602f1c..00b1daf 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -218,7 +218,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): def mode(self, source, channel, modes, ts=None): """Sends channel MODE changes.""" - if utils.isChannel(channel): + if self.is_channel(channel): extmodes = [] # Re-parse all channel modes locally to eliminate anything invalid, such as unbanning # things that were never banned. This prevents the bot from getting caught in a loop @@ -910,7 +910,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): # <- :GL!~gl@127.0.0.1 MODE #dev +v ice # <- :ice MODE ice :+Zi target = args[0] - if utils.isChannel(target): + if self.is_channel(target): oldobj = self._channels[target].deepcopy() else: target = self.nick_to_uid(target) @@ -1021,7 +1021,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): log.warning('(%s) Received %s to %s being routed the wrong way!', self.name, command, target) return - if not utils.isChannel(target): + if not self.is_channel(target): target = self.nick_to_uid(target) if target: diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 7eb2cb9..38fc127 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -199,7 +199,7 @@ class InspIRCdProtocol(TS6BaseProtocol): (not self.is_internal_server(numeric)): raise LookupError('No such PyLink client/server exists.') - if ('+o', None) in modes and not utils.isChannel(target): + if ('+o', None) in modes and not self.is_channel(target): # https://github.com/inspircd/inspircd/blob/master/src/modules/m_spanningtree/opertype.cpp#L26-L28 # Servers need a special command to set umode +o on people. self._oper_up(target) @@ -207,7 +207,7 @@ class InspIRCdProtocol(TS6BaseProtocol): self.apply_modes(target, modes) joinedmodes = self.join_modes(modes) - if utils.isChannel(target): + if self.is_channel(target): ts = ts or self._channels[target].ts self._send_with_prefix(numeric, 'FMODE %s %s %s' % (target, ts, joinedmodes)) else: @@ -353,7 +353,7 @@ class InspIRCdProtocol(TS6BaseProtocol): raise ValueError('A server named %r already exists!' % name) if not self.is_internal_server(uplink): raise ValueError('Server %r is not a PyLink server!' % uplink) - if not utils.isServerName(name): + if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) self._send_with_prefix(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc)) self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 20c3e38..810f9d0 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -630,7 +630,7 @@ class IRCS2SProtocol(IRCCommonProtocol): # <- ABAAA M #test +v ABAAB 1460747615 # <- ABAAA OM #test +h ABAAA target = self._get_UID(args[0]) - if utils.isChannel(target): + if self.is_channel(target): channeldata = self._channels[target].deepcopy() else: channeldata = None @@ -693,7 +693,7 @@ class IRCS2SProtocol(IRCCommonProtocol): # before checking whether it's actually a channel. split_channel = target.split('#', 1) - if len(split_channel) >= 2 and utils.isChannel('#' + split_channel[1]): + if len(split_channel) >= 2 and self.is_channel('#' + split_channel[1]): # Note: don't mess with the case of the channel prefix, or ~#channel # messages will break on RFC1459 casemapping networks (it becomes ^#channel # instead). diff --git a/protocols/ngircd.py b/protocols/ngircd.py index 3bcd5f3..8714683 100644 --- a/protocols/ngircd.py +++ b/protocols/ngircd.py @@ -122,7 +122,7 @@ class NgIRCdProtocol(IRCS2SProtocol): if not self.is_internal_server(uplink): raise ValueError('Server %r is not a PyLink server!' % uplink) - if not utils.isServerName(name): + if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) # https://tools.ietf.org/html/rfc2813#section-4.1.2 @@ -184,7 +184,7 @@ class NgIRCdProtocol(IRCS2SProtocol): self.apply_modes(target, modes) modes = list(modes) # Work around TypeError in the expand PUID section - if utils.isChannel(target): + if self.is_channel(target): msgprefix = ':%s MODE %s ' % (self._expandPUID(source), target) bufsize = self.S2S_BUFSIZE - len(msgprefix) diff --git a/protocols/p10.py b/protocols/p10.py index 0bf8af3..264a52c 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -406,7 +406,7 @@ class P10Protocol(IRCS2SProtocol): # https://github.com/evilnet/nefarious2/blob/4e2dcb1/doc/p10.txt#L146 # One line can have a max of 15 parameters. Excluding the target and the first part of the # modestring, this means we can send a max of 13 modes with arguments per line. - is_cmode = utils.isChannel(target) + is_cmode = self.is_channel(target) if is_cmode: # Channel mode changes have a trailing TS. User mode changes do not. cobj = self._channels[target] @@ -668,7 +668,7 @@ class P10Protocol(IRCS2SProtocol): if not self.is_internal_server(uplink): raise ValueError('Server %r is not a PyLink server!' % uplink) - if not utils.isServerName(name): + if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) self._send_with_prefix(uplink, 'SERVER %s 1 %s %s P10 %s]]] +h6 :%s' % \ diff --git a/protocols/ts6.py b/protocols/ts6.py index 75221d5..2c42bd4 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -182,7 +182,7 @@ class TS6Protocol(TS6BaseProtocol): self.apply_modes(target, modes) modes = list(modes) - if utils.isChannel(target): + if self.is_channel(target): ts = ts or self._channels[target].ts # TMODE: # parameters: channelTS, channel, cmode changes, opt. cmode parameters... diff --git a/protocols/ts6_common.py b/protocols/ts6_common.py index 12f3bbc..7fca9f6 100644 --- a/protocols/ts6_common.py +++ b/protocols/ts6_common.py @@ -179,7 +179,7 @@ class TS6BaseProtocol(IRCS2SProtocol): raise ValueError('A server named %r already exists!' % name) if not self.is_internal_server(uplink): raise ValueError('Server %r is not a PyLink server!' % uplink) - if not utils.isServerName(name): + if not self.is_server_name(name): raise ValueError('Invalid server name %r' % name) self._send_with_prefix(uplink, 'SID %s 1 %s :%s' % (name, sid, desc)) self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc) diff --git a/protocols/unreal.py b/protocols/unreal.py index aea6d7e..18444b9 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -204,7 +204,7 @@ class UnrealProtocol(TS6BaseProtocol): self.apply_modes(target, modes) - if utils.isChannel(target): + if self.is_channel(target): # Fix assignment TypeError in the expandPUID bit (sets can't be # assigned to by index). @@ -320,7 +320,7 @@ class UnrealProtocol(TS6BaseProtocol): # KNOCKs in UnrealIRCd are actually just specially formatted NOTICEs, # sent to all ops in a channel. # <- :unreal.midnight.vpn NOTICE @#test :[Knock] by GL|!gl@hidden-1C620195 (test) - assert utils.isChannel(target), "Can only knock on channels!" + assert self.is_channel(target), "Can only knock on channels!" sender = self.get_server(numeric) s = '[Knock] by %s (%s)' % (self.get_hostmask(numeric), text) self._send_with_prefix(sender, 'NOTICE @%s :%s' % (target, s)) @@ -675,7 +675,7 @@ class UnrealProtocol(TS6BaseProtocol): # send 0 as a TS argument (which should be ignored unless breaking the internal channel TS is desired). # Also, we need to get rid of that extra space following the +f argument. :| - if utils.isChannel(args[0]): + if self.is_channel(args[0]): channel = args[0] oldobj = self._channels[channel].deepcopy()