mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
protocols: switch to self.is*
This commit is contained in:
parent
e39b4e9c69
commit
c4a3baca7d
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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).
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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' % \
|
||||
|
@ -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...
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user