mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-11 20:52:42 +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):
|
def mode(self, source, channel, modes, ts=None):
|
||||||
"""Sends channel MODE changes."""
|
"""Sends channel MODE changes."""
|
||||||
if utils.isChannel(channel):
|
if self.is_channel(channel):
|
||||||
extmodes = []
|
extmodes = []
|
||||||
# Re-parse all channel modes locally to eliminate anything invalid, such as unbanning
|
# 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
|
# 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
|
# <- :GL!~gl@127.0.0.1 MODE #dev +v ice
|
||||||
# <- :ice MODE ice :+Zi
|
# <- :ice MODE ice :+Zi
|
||||||
target = args[0]
|
target = args[0]
|
||||||
if utils.isChannel(target):
|
if self.is_channel(target):
|
||||||
oldobj = self._channels[target].deepcopy()
|
oldobj = self._channels[target].deepcopy()
|
||||||
else:
|
else:
|
||||||
target = self.nick_to_uid(target)
|
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)
|
log.warning('(%s) Received %s to %s being routed the wrong way!', self.name, command, target)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not utils.isChannel(target):
|
if not self.is_channel(target):
|
||||||
target = self.nick_to_uid(target)
|
target = self.nick_to_uid(target)
|
||||||
|
|
||||||
if target:
|
if target:
|
||||||
|
@ -199,7 +199,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
(not self.is_internal_server(numeric)):
|
(not self.is_internal_server(numeric)):
|
||||||
raise LookupError('No such PyLink client/server exists.')
|
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
|
# 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.
|
# Servers need a special command to set umode +o on people.
|
||||||
self._oper_up(target)
|
self._oper_up(target)
|
||||||
@ -207,7 +207,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
self.apply_modes(target, modes)
|
self.apply_modes(target, modes)
|
||||||
joinedmodes = self.join_modes(modes)
|
joinedmodes = self.join_modes(modes)
|
||||||
|
|
||||||
if utils.isChannel(target):
|
if self.is_channel(target):
|
||||||
ts = ts or self._channels[target].ts
|
ts = ts or self._channels[target].ts
|
||||||
self._send_with_prefix(numeric, 'FMODE %s %s %s' % (target, ts, joinedmodes))
|
self._send_with_prefix(numeric, 'FMODE %s %s %s' % (target, ts, joinedmodes))
|
||||||
else:
|
else:
|
||||||
@ -353,7 +353,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
raise ValueError('A server named %r already exists!' % name)
|
raise ValueError('A server named %r already exists!' % name)
|
||||||
if not self.is_internal_server(uplink):
|
if not self.is_internal_server(uplink):
|
||||||
raise ValueError('Server %r is not a PyLink 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)
|
raise ValueError('Invalid server name %r' % name)
|
||||||
self._send_with_prefix(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc))
|
self._send_with_prefix(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc))
|
||||||
self.servers[sid] = Server(self, uplink, name, internal=True, desc=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 M #test +v ABAAB 1460747615
|
||||||
# <- ABAAA OM #test +h ABAAA
|
# <- ABAAA OM #test +h ABAAA
|
||||||
target = self._get_UID(args[0])
|
target = self._get_UID(args[0])
|
||||||
if utils.isChannel(target):
|
if self.is_channel(target):
|
||||||
channeldata = self._channels[target].deepcopy()
|
channeldata = self._channels[target].deepcopy()
|
||||||
else:
|
else:
|
||||||
channeldata = None
|
channeldata = None
|
||||||
@ -693,7 +693,7 @@ class IRCS2SProtocol(IRCCommonProtocol):
|
|||||||
# before checking whether it's actually a channel.
|
# before checking whether it's actually a channel.
|
||||||
|
|
||||||
split_channel = target.split('#', 1)
|
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
|
# Note: don't mess with the case of the channel prefix, or ~#channel
|
||||||
# messages will break on RFC1459 casemapping networks (it becomes ^#channel
|
# messages will break on RFC1459 casemapping networks (it becomes ^#channel
|
||||||
# instead).
|
# instead).
|
||||||
|
@ -122,7 +122,7 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
if not self.is_internal_server(uplink):
|
if not self.is_internal_server(uplink):
|
||||||
raise ValueError('Server %r is not a PyLink 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)
|
raise ValueError('Invalid server name %r' % name)
|
||||||
|
|
||||||
# https://tools.ietf.org/html/rfc2813#section-4.1.2
|
# https://tools.ietf.org/html/rfc2813#section-4.1.2
|
||||||
@ -184,7 +184,7 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
self.apply_modes(target, modes)
|
self.apply_modes(target, modes)
|
||||||
modes = list(modes) # Work around TypeError in the expand PUID section
|
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)
|
msgprefix = ':%s MODE %s ' % (self._expandPUID(source), target)
|
||||||
bufsize = self.S2S_BUFSIZE - len(msgprefix)
|
bufsize = self.S2S_BUFSIZE - len(msgprefix)
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
# https://github.com/evilnet/nefarious2/blob/4e2dcb1/doc/p10.txt#L146
|
# 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
|
# 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.
|
# 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:
|
if is_cmode:
|
||||||
# Channel mode changes have a trailing TS. User mode changes do not.
|
# Channel mode changes have a trailing TS. User mode changes do not.
|
||||||
cobj = self._channels[target]
|
cobj = self._channels[target]
|
||||||
@ -668,7 +668,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
|
|
||||||
if not self.is_internal_server(uplink):
|
if not self.is_internal_server(uplink):
|
||||||
raise ValueError('Server %r is not a PyLink 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)
|
raise ValueError('Invalid server name %r' % name)
|
||||||
|
|
||||||
self._send_with_prefix(uplink, 'SERVER %s 1 %s %s P10 %s]]] +h6 :%s' % \
|
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)
|
self.apply_modes(target, modes)
|
||||||
modes = list(modes)
|
modes = list(modes)
|
||||||
|
|
||||||
if utils.isChannel(target):
|
if self.is_channel(target):
|
||||||
ts = ts or self._channels[target].ts
|
ts = ts or self._channels[target].ts
|
||||||
# TMODE:
|
# TMODE:
|
||||||
# parameters: channelTS, channel, cmode changes, opt. cmode parameters...
|
# parameters: channelTS, channel, cmode changes, opt. cmode parameters...
|
||||||
|
@ -179,7 +179,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
|||||||
raise ValueError('A server named %r already exists!' % name)
|
raise ValueError('A server named %r already exists!' % name)
|
||||||
if not self.is_internal_server(uplink):
|
if not self.is_internal_server(uplink):
|
||||||
raise ValueError('Server %r is not a PyLink 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)
|
raise ValueError('Invalid server name %r' % name)
|
||||||
self._send_with_prefix(uplink, 'SID %s 1 %s :%s' % (name, sid, desc))
|
self._send_with_prefix(uplink, 'SID %s 1 %s :%s' % (name, sid, desc))
|
||||||
self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc)
|
self.servers[sid] = Server(self, uplink, name, internal=True, desc=desc)
|
||||||
|
@ -204,7 +204,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
self.apply_modes(target, modes)
|
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
|
# Fix assignment TypeError in the expandPUID bit (sets can't be
|
||||||
# assigned to by index).
|
# assigned to by index).
|
||||||
@ -320,7 +320,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
# KNOCKs in UnrealIRCd are actually just specially formatted NOTICEs,
|
# KNOCKs in UnrealIRCd are actually just specially formatted NOTICEs,
|
||||||
# sent to all ops in a channel.
|
# sent to all ops in a channel.
|
||||||
# <- :unreal.midnight.vpn NOTICE @#test :[Knock] by GL|!gl@hidden-1C620195 (test)
|
# <- :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)
|
sender = self.get_server(numeric)
|
||||||
s = '[Knock] by %s (%s)' % (self.get_hostmask(numeric), text)
|
s = '[Knock] by %s (%s)' % (self.get_hostmask(numeric), text)
|
||||||
self._send_with_prefix(sender, 'NOTICE @%s :%s' % (target, s))
|
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).
|
# 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. :|
|
# 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]
|
channel = args[0]
|
||||||
oldobj = self._channels[channel].deepcopy()
|
oldobj = self._channels[channel].deepcopy()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user