mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
protocols: rename _send to _send_with_prefix to avoid clashing with process_queue
This commit is contained in:
parent
df18e318a8
commit
8acf39cad6
@ -109,7 +109,7 @@ class HybridProtocol(TS6Protocol):
|
||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||
self.irc.applyModes(uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
self._send(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||
self._send_with_prefix(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||
"* :{realname}".format(ts=ts, host=host,
|
||||
nick=nick, ident=ident, uid=uid,
|
||||
modes=raw_modes, ip=ip, realname=realname))
|
||||
@ -131,7 +131,7 @@ class HybridProtocol(TS6Protocol):
|
||||
self.irc.users[target].host = text
|
||||
# On Hybrid, it appears that host changing is actually just forcing umode
|
||||
# "+x <hostname>" on the target. -GLolol
|
||||
self._send(self.irc.sid, 'SVSMODE %s %s +x %s' % (target, ts, text))
|
||||
self._send_with_prefix(self.irc.sid, 'SVSMODE %s %s +x %s' % (target, ts, text))
|
||||
else:
|
||||
raise NotImplementedError("Changing field %r of a client is unsupported by this protocol." % field)
|
||||
|
||||
@ -144,7 +144,7 @@ class HybridProtocol(TS6Protocol):
|
||||
ts = self.irc.channels[target].ts
|
||||
servername = self.irc.servers[numeric].name
|
||||
|
||||
self._send(numeric, 'TBURST %s %s %s %s :%s' % (ts, target, int(time.time()), servername, text))
|
||||
self._send_with_prefix(numeric, 'TBURST %s %s %s %s :%s' % (ts, target, int(time.time()), servername, text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
|
||||
|
@ -59,7 +59,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
self.irc.applyModes(uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
|
||||
self._send(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
||||
self._send_with_prefix(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
||||
" {ts} {modes} + :{realname}".format(ts=ts, host=host,
|
||||
nick=nick, ident=ident, uid=uid,
|
||||
modes=raw_modes, ip=ip, realname=realname,
|
||||
@ -82,7 +82,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
|
||||
# Strip out list-modes, they shouldn't be ever sent in FJOIN.
|
||||
modes = [m for m in self.irc.channels[channel].modes if m[0] not in self.irc.cmodes['*A']]
|
||||
self._send(server, "FJOIN {channel} {ts} {modes} :,{uid}".format(
|
||||
self._send_with_prefix(server, "FJOIN {channel} {ts} {modes} :,{uid}".format(
|
||||
ts=self.irc.channels[channel].ts, uid=client, channel=channel,
|
||||
modes=self.irc.joinModes(modes)))
|
||||
self.irc.channels[channel].users.add(client)
|
||||
@ -142,7 +142,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
log.debug("(%s) sjoin: KeyError trying to add %r to %r's channel list?", self.irc.name, channel, user)
|
||||
|
||||
namelist = ' '.join(namelist)
|
||||
self._send(server, "FJOIN {channel} {ts} {modes} :{users}".format(
|
||||
self._send_with_prefix(server, "FJOIN {channel} {ts} {modes} :{users}".format(
|
||||
ts=ts, users=namelist, channel=channel,
|
||||
modes=self.irc.joinModes(modes)))
|
||||
self.irc.channels[channel].users.update(uids)
|
||||
@ -150,7 +150,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
if banmodes:
|
||||
# Burst ban modes if there are any.
|
||||
# <- :1ML FMODE #test 1461201525 +bb *!*@bad.user *!*@rly.bad.user
|
||||
self._send(server, "FMODE {channel} {ts} {modes} ".format(
|
||||
self._send_with_prefix(server, "FMODE {channel} {ts} {modes} ".format(
|
||||
ts=ts, channel=channel, modes=self.irc.joinModes(banmodes)))
|
||||
|
||||
self.updateTS(server, channel, ts, changedmodes)
|
||||
@ -187,7 +187,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
else:
|
||||
otype = ':' + otype
|
||||
|
||||
self._send(target, 'OPERTYPE %s' % otype)
|
||||
self._send_with_prefix(target, 'OPERTYPE %s' % otype)
|
||||
|
||||
def mode(self, numeric, target, modes, ts=None):
|
||||
"""Sends mode changes from a PyLink client/server."""
|
||||
@ -198,7 +198,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
(not self.irc.isInternalServer(numeric)):
|
||||
raise LookupError('No such PyLink client/server exists.')
|
||||
|
||||
log.debug('(%s) inspircd._sendModes: received %r for mode list', self.irc.name, modes)
|
||||
log.debug('(%s) inspircd._send_with_prefixModes: received %r for mode list', self.irc.name, modes)
|
||||
if ('+o', None) in modes and not utils.isChannel(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.
|
||||
@ -207,9 +207,9 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
joinedmodes = self.irc.joinModes(modes)
|
||||
if utils.isChannel(target):
|
||||
ts = ts or self.irc.channels[self.irc.toLower(target)].ts
|
||||
self._send(numeric, 'FMODE %s %s %s' % (target, ts, joinedmodes))
|
||||
self._send_with_prefix(numeric, 'FMODE %s %s %s' % (target, ts, joinedmodes))
|
||||
else:
|
||||
self._send(numeric, 'MODE %s %s' % (target, joinedmodes))
|
||||
self._send_with_prefix(numeric, 'MODE %s %s' % (target, joinedmodes))
|
||||
|
||||
def kill(self, numeric, target, reason):
|
||||
"""Sends a kill from a PyLink client/server."""
|
||||
@ -225,7 +225,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
else:
|
||||
sourcenick = self.irc.users[numeric].nick
|
||||
|
||||
self._send(numeric, 'KILL %s :Killed (%s (%s))' % (target, sourcenick, reason))
|
||||
self._send_with_prefix(numeric, 'KILL %s :Killed (%s (%s))' % (target, sourcenick, reason))
|
||||
|
||||
# We only need to call removeClient here if the target is one of our
|
||||
# clients, since any remote servers will send a QUIT from
|
||||
@ -239,7 +239,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
raise LookupError('No such PyLink server exists.')
|
||||
ts = int(time.time())
|
||||
servername = self.irc.servers[numeric].name
|
||||
self._send(numeric, 'FTOPIC %s %s %s :%s' % (target, ts, servername, text))
|
||||
self._send_with_prefix(numeric, 'FTOPIC %s %s %s :%s' % (target, ts, servername, text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
|
||||
@ -247,13 +247,13 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
"""Sends an INVITE from a PyLink client.."""
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(numeric, 'INVITE %s %s' % (target, channel))
|
||||
self._send_with_prefix(numeric, 'INVITE %s %s' % (target, channel))
|
||||
|
||||
def knock(self, numeric, target, text):
|
||||
"""Sends a KNOCK from a PyLink client."""
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(numeric, 'ENCAP * KNOCK %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'ENCAP * KNOCK %s :%s' % (target, text))
|
||||
|
||||
def updateClient(self, target, field, text):
|
||||
"""Updates the ident, host, or realname of any connected client."""
|
||||
@ -267,13 +267,13 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# It is one of our clients, use FIDENT/HOST/NAME.
|
||||
if field == 'IDENT':
|
||||
self.irc.users[target].ident = text
|
||||
self._send(target, 'FIDENT %s' % text)
|
||||
self._send_with_prefix(target, 'FIDENT %s' % text)
|
||||
elif field == 'HOST':
|
||||
self.irc.users[target].host = text
|
||||
self._send(target, 'FHOST %s' % text)
|
||||
self._send_with_prefix(target, 'FHOST %s' % text)
|
||||
elif field in ('REALNAME', 'GECOS'):
|
||||
self.irc.users[target].realname = text
|
||||
self._send(target, 'FNAME :%s' % text)
|
||||
self._send_with_prefix(target, 'FNAME :%s' % text)
|
||||
else:
|
||||
# It is a client on another server, use CHGIDENT/HOST/NAME.
|
||||
if field == 'IDENT':
|
||||
@ -282,7 +282,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
return
|
||||
|
||||
self.irc.users[target].ident = text
|
||||
self._send(self.irc.sid, 'CHGIDENT %s %s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGIDENT %s %s' % (target, text))
|
||||
|
||||
# Send hook payloads for other plugins to listen to.
|
||||
self.irc.callHooks([self.irc.sid, 'CHGIDENT',
|
||||
@ -293,7 +293,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
return
|
||||
|
||||
self.irc.users[target].host = text
|
||||
self._send(self.irc.sid, 'CHGHOST %s %s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGHOST %s %s' % (target, text))
|
||||
|
||||
self.irc.callHooks([self.irc.sid, 'CHGHOST',
|
||||
{'target': target, 'newhost': text}])
|
||||
@ -303,7 +303,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
log.warning('(%s) Failed to change real name of %s to %r: load m_chgname.so!', self.irc.name, target, text)
|
||||
return
|
||||
self.irc.users[target].realname = text
|
||||
self._send(self.irc.sid, 'CHGNAME %s :%s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGNAME %s :%s' % (target, text))
|
||||
|
||||
self.irc.callHooks([self.irc.sid, 'CHGNAME',
|
||||
{'target': target, 'newgecos': text}])
|
||||
@ -314,7 +314,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
source = source or self.irc.sid
|
||||
target = target or self.irc.uplink
|
||||
if not (target is None or source is None):
|
||||
self._send(source, 'PING %s %s' % (source, target))
|
||||
self._send_with_prefix(source, 'PING %s %s' % (source, target))
|
||||
|
||||
def numeric(self, source, numeric, target, text):
|
||||
"""Sends raw numerics from a server to a remote client."""
|
||||
@ -327,15 +327,15 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# :<sid> NUM <numeric source sid> <target uuid> <3 digit number> <params>
|
||||
# Take this into consideration if we ever target InspIRCd 2.2, even though m_spanningtree
|
||||
# does provide backwards compatibility for commands like this. -GLolol
|
||||
self._send(self.irc.sid, 'PUSH %s ::%s %s %s %s' % (target, source, numeric, target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'PUSH %s ::%s %s %s %s' % (target, source, numeric, target, text))
|
||||
|
||||
def away(self, source, text):
|
||||
"""Sends an AWAY message from a PyLink client. <text> can be an empty string
|
||||
to unset AWAY status."""
|
||||
if text:
|
||||
self._send(source, 'AWAY %s :%s' % (int(time.time()), text))
|
||||
self._send_with_prefix(source, 'AWAY %s :%s' % (int(time.time()), text))
|
||||
else:
|
||||
self._send(source, 'AWAY')
|
||||
self._send_with_prefix(source, 'AWAY')
|
||||
self.irc.users[source].away = text
|
||||
|
||||
def spawnServer(self, name, sid=None, uplink=None, desc=None, endburst_delay=0):
|
||||
@ -367,7 +367,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
raise ValueError('Server %r is not a PyLink server!' % uplink)
|
||||
if not utils.isServerName(name):
|
||||
raise ValueError('Invalid server name %r' % name)
|
||||
self._send(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc))
|
||||
self._send_with_prefix(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc))
|
||||
self.irc.servers[sid] = IrcServer(uplink, name, internal=True, desc=desc)
|
||||
|
||||
def endburstf():
|
||||
@ -376,18 +376,18 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# We managed to catch the abort flag before sending ENDBURST, so break
|
||||
log.debug('(%s) stopping endburstf() for %s as aborted was set', self.irc.name, sid)
|
||||
return
|
||||
self._send(sid, 'ENDBURST')
|
||||
self._send_with_prefix(sid, 'ENDBURST')
|
||||
|
||||
if endburst_delay:
|
||||
threading.Thread(target=endburstf).start()
|
||||
else: # Else, send burst immediately
|
||||
self._send(sid, 'ENDBURST')
|
||||
self._send_with_prefix(sid, 'ENDBURST')
|
||||
return sid
|
||||
|
||||
def squit(self, source, target, text='No reason given'):
|
||||
"""SQUITs a PyLink server."""
|
||||
# -> :9PY SQUIT 9PZ :blah, blah
|
||||
self._send(source, 'SQUIT %s :%s' % (target, text))
|
||||
self._send_with_prefix(source, 'SQUIT %s :%s' % (target, text))
|
||||
self.handle_squit(source, 'SQUIT', [target, text])
|
||||
|
||||
### Core / command handlers
|
||||
@ -409,10 +409,10 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
Pass=self.irc.serverdata["sendpass"], sid=self.irc.sid,
|
||||
sdesc=self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']))
|
||||
|
||||
self._send(self.irc.sid, 'BURST %s' % ts)
|
||||
self._send_with_prefix(self.irc.sid, 'BURST %s' % ts)
|
||||
# InspIRCd sends VERSION data on link, instead of whenever requested by a client.
|
||||
self._send(self.irc.sid, 'VERSION :%s' % self.irc.version())
|
||||
self._send(self.irc.sid, 'ENDBURST')
|
||||
self._send_with_prefix(self.irc.sid, 'VERSION :%s' % self.irc.version())
|
||||
self._send_with_prefix(self.irc.sid, 'ENDBURST')
|
||||
|
||||
def handle_capab(self, source, command, args):
|
||||
"""
|
||||
@ -524,7 +524,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# <- :70M PING 70M 0AL
|
||||
# -> :0AL PONG 0AL 70M
|
||||
if self.irc.isInternalServer(args[1]):
|
||||
self._send(args[1], 'PONG %s %s' % (args[1], source), queue=False)
|
||||
self._send_with_prefix(args[1], 'PONG %s %s' % (args[1], source), queue=False)
|
||||
|
||||
def handle_fjoin(self, servernumeric, command, args):
|
||||
"""Handles incoming FJOIN commands (InspIRCd equivalent of JOIN/SJOIN)."""
|
||||
@ -764,7 +764,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
# The target has to be one of our servers in order to work...
|
||||
uplink = self.irc.servers[target].uplink
|
||||
reason = 'Requested by %s' % self.irc.getHostmask(numeric)
|
||||
self._send(uplink, 'SQUIT %s :%s' % (target, reason))
|
||||
self._send_with_prefix(uplink, 'SQUIT %s :%s' % (target, reason))
|
||||
return self.handle_squit(numeric, 'SQUIT', [target, reason])
|
||||
else:
|
||||
log.debug("(%s) Got RSQUIT for '%s', which is either invalid or not "
|
||||
@ -833,6 +833,6 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
|
||||
# XXX: We override notice() here because that abstraction doesn't allow messages from servers.
|
||||
timestring = '%s (%s)' % (time.strftime('%Y-%m-%d %H:%M:%S'), int(time.time()))
|
||||
self._send(self.irc.sid, 'NOTICE %s :System time is %s on %s' % (source, timestring, self.irc.hostname()))
|
||||
self._send_with_prefix(self.irc.sid, 'NOTICE %s :System time is %s on %s' % (source, timestring, self.irc.hostname()))
|
||||
|
||||
Class = InspIRCdProtocol
|
||||
|
@ -164,7 +164,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
self.protocol_caps |= {'slash-in-hosts', 'underscore-in-hosts'}
|
||||
|
||||
def _send(self, source, text, **kwargs):
|
||||
def _send_with_prefix(self, source, text, **kwargs):
|
||||
self.irc.send("%s %s" % (source, text), **kwargs)
|
||||
|
||||
@staticmethod
|
||||
@ -292,7 +292,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
else: # TODO: propagate IPv6 address, but only if uplink supports it
|
||||
b64ip = 'AAAAAA'
|
||||
|
||||
self._send(server, "N {nick} 1 {ts} {ident} {host} {modes} {ip} {uid} "
|
||||
self._send_with_prefix(server, "N {nick} 1 {ts} {ident} {host} {modes} {ip} {uid} "
|
||||
":{realname}".format(ts=ts, host=host, nick=nick, ident=ident, uid=uid,
|
||||
modes=raw_modes, ip=b64ip, realname=realname,
|
||||
realhost=realhost))
|
||||
@ -305,9 +305,9 @@ class P10Protocol(IRCS2SProtocol):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
|
||||
if text:
|
||||
self._send(source, 'A :%s' % text)
|
||||
self._send_with_prefix(source, 'A :%s' % text)
|
||||
else:
|
||||
self._send(source, 'A')
|
||||
self._send_with_prefix(source, 'A')
|
||||
self.irc.users[source].away = text
|
||||
|
||||
def invite(self, numeric, target, channel):
|
||||
@ -320,7 +320,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
nick = self.irc.users[target].nick
|
||||
|
||||
self._send(numeric, 'I %s %s %s' % (nick, channel, self.irc.channels[channel].ts))
|
||||
self._send_with_prefix(numeric, 'I %s %s %s' % (nick, channel, self.irc.channels[channel].ts))
|
||||
|
||||
def join(self, client, channel):
|
||||
"""Joins a PyLink client to a channel."""
|
||||
@ -333,9 +333,9 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
if not self.irc.channels[channel].users:
|
||||
# Empty channels should be created with the CREATE command.
|
||||
self._send(client, "C {channel} {ts}".format(ts=ts, channel=channel))
|
||||
self._send_with_prefix(client, "C {channel} {ts}".format(ts=ts, channel=channel))
|
||||
else:
|
||||
self._send(client, "J {channel} {ts}".format(ts=ts, channel=channel))
|
||||
self._send_with_prefix(client, "J {channel} {ts}".format(ts=ts, channel=channel))
|
||||
|
||||
self.irc.channels[channel].users.add(client)
|
||||
self.irc.users[client].channels.add(channel)
|
||||
@ -358,7 +358,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
reason = '(%s) %s' % (self.irc.getFriendlyName(numeric), reason)
|
||||
numeric = self.irc.getServer(numeric)
|
||||
|
||||
self._send(numeric, 'K %s %s :%s' % (channel, target, reason))
|
||||
self._send_with_prefix(numeric, 'K %s %s :%s' % (channel, target, reason))
|
||||
|
||||
# We can pretend the target left by its own will; all we really care about
|
||||
# is that the target gets removed from the channel userlist, and calling
|
||||
@ -373,7 +373,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
(not self.irc.isInternalServer(numeric)):
|
||||
raise LookupError('No such PyLink client/server exists.')
|
||||
|
||||
self._send(numeric, 'D %s :Killed (%s)' % (target, reason))
|
||||
self._send_with_prefix(numeric, 'D %s :Killed (%s)' % (target, reason))
|
||||
self.removeClient(target)
|
||||
|
||||
def knock(self, numeric, target, text):
|
||||
@ -384,7 +384,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
|
||||
self._send(numeric, 'P %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'P %s :%s' % (target, text))
|
||||
|
||||
def mode(self, numeric, target, modes, ts=None):
|
||||
"""Sends mode changes from a PyLink client/server."""
|
||||
@ -428,9 +428,9 @@ class P10Protocol(IRCS2SProtocol):
|
||||
joinedmodes = self.irc.joinModes([m for m in modes[:12]])
|
||||
if is_cmode:
|
||||
for wrapped_modes in self.irc.wrapModes(modes[:12], bufsize):
|
||||
self._send(numeric, 'M %s %s %s' % (real_target, wrapped_modes, ts))
|
||||
self._send_with_prefix(numeric, 'M %s %s %s' % (real_target, wrapped_modes, ts))
|
||||
else:
|
||||
self._send(numeric, 'M %s %s' % (real_target, joinedmodes))
|
||||
self._send_with_prefix(numeric, 'M %s %s' % (real_target, joinedmodes))
|
||||
modes = modes[12:]
|
||||
|
||||
def nick(self, numeric, newnick):
|
||||
@ -439,7 +439,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
|
||||
self._send(numeric, 'N %s %s' % (newnick, int(time.time())))
|
||||
self._send_with_prefix(numeric, 'N %s %s' % (newnick, int(time.time())))
|
||||
self.irc.users[numeric].nick = newnick
|
||||
|
||||
# Update the NICK TS.
|
||||
@ -449,7 +449,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
"""Sends raw numerics from a server to a remote client. This is used for WHOIS
|
||||
replies."""
|
||||
# <- AB 311 AyAAA GL ~gl nefarious.midnight.vpn * :realname
|
||||
self._send(source, '%s %s %s' % (numeric, target, text))
|
||||
self._send_with_prefix(source, '%s %s %s' % (numeric, target, text))
|
||||
|
||||
def notice(self, numeric, target, text):
|
||||
"""Sends a NOTICE from a PyLink client or server."""
|
||||
@ -457,7 +457,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
(not self.irc.isInternalServer(numeric)):
|
||||
raise LookupError('No such PyLink client/server exists.')
|
||||
|
||||
self._send(numeric, 'O %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'O %s :%s' % (target, text))
|
||||
|
||||
def part(self, client, channel, reason=None):
|
||||
"""Sends a part from a PyLink client."""
|
||||
@ -469,7 +469,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
msg = "L %s" % channel
|
||||
if reason:
|
||||
msg += " :%s" % reason
|
||||
self._send(client, msg)
|
||||
self._send_with_prefix(client, msg)
|
||||
self.handle_part(client, 'PART', [channel])
|
||||
|
||||
def ping(self, source=None, target=None):
|
||||
@ -479,14 +479,14 @@ class P10Protocol(IRCS2SProtocol):
|
||||
if source is None:
|
||||
return
|
||||
if target is not None:
|
||||
self._send(source, 'G %s %s' % (source, target))
|
||||
self._send_with_prefix(source, 'G %s %s' % (source, target))
|
||||
else:
|
||||
self._send(source, 'G %s' % source)
|
||||
self._send_with_prefix(source, 'G %s' % source)
|
||||
|
||||
def quit(self, numeric, reason):
|
||||
"""Quits a PyLink client."""
|
||||
if self.irc.isInternalClient(numeric):
|
||||
self._send(numeric, "Q :%s" % reason)
|
||||
self._send_with_prefix(numeric, "Q :%s" % reason)
|
||||
self.removeClient(numeric)
|
||||
else:
|
||||
raise LookupError("No such PyLink client exists.")
|
||||
@ -657,7 +657,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
if not utils.isServerName(name):
|
||||
raise ValueError('Invalid server name %r' % name)
|
||||
|
||||
self._send(uplink, 'SERVER %s 1 %s %s P10 %s]]] +h6 :%s' % \
|
||||
self._send_with_prefix(uplink, 'SERVER %s 1 %s %s P10 %s]]] +h6 :%s' % \
|
||||
(name, self.irc.start_ts, int(time.time()), sid, desc))
|
||||
|
||||
self.irc.servers[sid] = IrcServer(uplink, name, internal=True, desc=desc)
|
||||
@ -669,7 +669,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
targetname = self.irc.servers[target].name
|
||||
|
||||
self._send(source, 'SQ %s 0 :%s' % (targetname, text))
|
||||
self._send_with_prefix(source, 'SQ %s 0 :%s' % (targetname, text))
|
||||
self.handle_squit(source, 'SQUIT', [target, text])
|
||||
|
||||
def topic(self, numeric, target, text):
|
||||
@ -684,7 +684,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
creationts = self.irc.channels[target].ts
|
||||
|
||||
self._send(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts,
|
||||
self._send_with_prefix(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts,
|
||||
int(time.time()), text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
@ -700,7 +700,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
creationts = self.irc.channels[target].ts
|
||||
|
||||
self._send(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts,
|
||||
self._send_with_prefix(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts,
|
||||
int(time.time()), text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
@ -737,7 +737,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
"only available on nefarious, and we're using p10_ircd=%r" % ircd)
|
||||
|
||||
# Use FAKE (FA) for external clients.
|
||||
self._send(self.irc.sid, 'FA %s %s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'FA %s %s' % (target, text))
|
||||
|
||||
# Save the host change as a user mode (this is what P10 does on bursts),
|
||||
# so further host checks work.
|
||||
@ -821,7 +821,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
self.irc.cmodes.update(cmodes)
|
||||
|
||||
self.irc.send('SERVER %s 1 %s %s J10 %s]]] +s6 :%s' % (name, ts, ts, sid, desc))
|
||||
self._send(sid, "EB")
|
||||
self._send_with_prefix(sid, "EB")
|
||||
self.irc.connected.set()
|
||||
|
||||
def handle_server(self, source, command, args):
|
||||
@ -975,7 +975,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
if self.irc.isInternalServer(sid):
|
||||
# Only respond if the target server is ours. No forwarding is needed because
|
||||
# no IRCds can ever connect behind us...
|
||||
self._send(self.irc.sid, 'Z %s %s %s %s' % (target, orig_pingtime, timediff, currtime), queue=False)
|
||||
self._send_with_prefix(self.irc.sid, 'Z %s %s %s %s' % (target, orig_pingtime, timediff, currtime), queue=False)
|
||||
|
||||
def handle_pass(self, source, command, args):
|
||||
"""Handles authentication with our uplink."""
|
||||
@ -1116,7 +1116,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
# Send EOB acknowledgement; this is required by the P10 specification,
|
||||
# and needed if we want to be able to receive channel messages, etc.
|
||||
if source == self.irc.uplink:
|
||||
self._send(self.irc.sid, 'EA')
|
||||
self._send_with_prefix(self.irc.sid, 'EA')
|
||||
return {}
|
||||
|
||||
def handle_mode(self, source, command, args):
|
||||
@ -1180,7 +1180,7 @@ class P10Protocol(IRCS2SProtocol):
|
||||
|
||||
# Send PART in response to acknowledge the KICK, per
|
||||
# https://github.com/evilnet/nefarious2/blob/ed12d64/doc/p10.txt#L611-L616
|
||||
self._send(kicked, 'L %s :%s' % (channel, args[2]))
|
||||
self._send_with_prefix(kicked, 'L %s :%s' % (channel, args[2]))
|
||||
|
||||
return {'channel': channel, 'target': kicked, 'text': args[2]}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
self.irc.applyModes(uid, modes)
|
||||
self.irc.servers[server].users.add(uid)
|
||||
|
||||
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||
self._send_with_prefix(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||
"{realhost} * :{realname}".format(ts=ts, host=host,
|
||||
nick=nick, ident=ident, uid=uid,
|
||||
modes=raw_modes, ip=ip, realname=realname,
|
||||
@ -72,7 +72,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
if not self.irc.isInternalClient(client):
|
||||
log.error('(%s) Error trying to join %r to %r (no such client exists)', self.irc.name, client, channel)
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(client, "JOIN {ts} {channel} +".format(ts=self.irc.channels[channel].ts, channel=channel))
|
||||
self._send_with_prefix(client, "JOIN {ts} {channel} +".format(ts=self.irc.channels[channel].ts, channel=channel))
|
||||
self.irc.channels[channel].users.add(client)
|
||||
self.irc.users[client].channels.add(channel)
|
||||
|
||||
@ -147,7 +147,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
log.debug("(%s) sjoin: KeyError trying to add %r to %r's channel list?", self.irc.name, channel, user)
|
||||
users = users[12:]
|
||||
namelist = ' '.join(namelist)
|
||||
self._send(server, "SJOIN {ts} {channel} {modes} :{users}".format(
|
||||
self._send_with_prefix(server, "SJOIN {ts} {channel} {modes} :{users}".format(
|
||||
ts=ts, users=namelist, channel=channel,
|
||||
modes=self.irc.joinModes(regularmodes)))
|
||||
self.irc.channels[channel].users.update(uids)
|
||||
@ -193,7 +193,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
self.irc.send(msgprefix + modestr)
|
||||
else:
|
||||
joinedmodes = self.irc.joinModes(modes)
|
||||
self._send(numeric, 'MODE %s %s' % (target, joinedmodes))
|
||||
self._send_with_prefix(numeric, 'MODE %s %s' % (target, joinedmodes))
|
||||
|
||||
def topicBurst(self, numeric, target, text):
|
||||
"""Sends a topic change from a PyLink server. This is usually used on burst."""
|
||||
@ -206,7 +206,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
# parameters: channel, topicTS, opt. topic setter, topic
|
||||
ts = self.irc.channels[target].ts
|
||||
servername = self.irc.servers[numeric].name
|
||||
self._send(numeric, 'TB %s %s %s :%s' % (target, ts, servername, text))
|
||||
self._send_with_prefix(numeric, 'TB %s %s %s :%s' % (target, ts, servername, text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
|
||||
@ -214,7 +214,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
"""Sends an INVITE from a PyLink client.."""
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(numeric, 'INVITE %s %s %s' % (target, channel, self.irc.channels[channel].ts))
|
||||
self._send_with_prefix(numeric, 'INVITE %s %s %s' % (target, channel, self.irc.channels[channel].ts))
|
||||
|
||||
def knock(self, numeric, target, text):
|
||||
"""Sends a KNOCK from a PyLink client."""
|
||||
@ -225,14 +225,14 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
# No text value is supported here; drop it.
|
||||
self._send(numeric, 'KNOCK %s' % target)
|
||||
self._send_with_prefix(numeric, 'KNOCK %s' % target)
|
||||
|
||||
def updateClient(self, target, field, text):
|
||||
"""Updates the hostname of any connected client."""
|
||||
field = field.upper()
|
||||
if field == 'HOST':
|
||||
self.irc.users[target].host = text
|
||||
self._send(self.irc.sid, 'CHGHOST %s :%s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGHOST %s :%s' % (target, text))
|
||||
if not self.irc.isInternalClient(target):
|
||||
# If the target isn't one of our clients, send hook payload
|
||||
# for other plugins to listen to.
|
||||
@ -249,9 +249,9 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
if source is None:
|
||||
return
|
||||
if target is not None:
|
||||
self._send(source, 'PING %s %s' % (source, target))
|
||||
self._send_with_prefix(source, 'PING %s %s' % (source, target))
|
||||
else:
|
||||
self._send(source, 'PING %s' % source)
|
||||
self._send_with_prefix(source, 'PING %s' % source)
|
||||
|
||||
### Core / handlers
|
||||
|
||||
@ -407,7 +407,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
except IndexError:
|
||||
destination = self.irc.sid
|
||||
if self.irc.isInternalServer(destination):
|
||||
self._send(destination, 'PONG %s %s' % (destination, source), queue=False)
|
||||
self._send_with_prefix(destination, 'PONG %s %s' % (destination, source), queue=False)
|
||||
|
||||
if destination == self.irc.sid and not self.has_eob:
|
||||
# Charybdis' idea of endburst is just sending a PING. No, really!
|
||||
|
@ -109,7 +109,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
# SID generator for TS6.
|
||||
self.sidgen = TS6SIDGenerator(irc)
|
||||
|
||||
def _send(self, source, msg, **kwargs):
|
||||
def _send_with_prefix(self, source, msg, **kwargs):
|
||||
"""Sends a TS6-style raw command from a source numeric to the self.irc connection given."""
|
||||
self.irc.send(':%s %s' % (source, msg), **kwargs)
|
||||
|
||||
@ -130,7 +130,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
# Mangle the target for IRCds that require it.
|
||||
target = self._expandPUID(target)
|
||||
|
||||
self._send(source, '%s %s %s' % (numeric, target, text))
|
||||
self._send_with_prefix(source, '%s %s %s' % (numeric, target, text))
|
||||
|
||||
def kick(self, numeric, channel, target, reason=None):
|
||||
"""Sends kicks from a PyLink client/server."""
|
||||
@ -146,7 +146,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
# Mangle kick targets for IRCds that require it.
|
||||
real_target = self._expandPUID(target)
|
||||
|
||||
self._send(numeric, 'KICK %s %s :%s' % (channel, real_target, reason))
|
||||
self._send_with_prefix(numeric, 'KICK %s %s :%s' % (channel, real_target, reason))
|
||||
|
||||
# We can pretend the target left by its own will; all we really care about
|
||||
# is that the target gets removed from the channel userlist, and calling
|
||||
@ -183,7 +183,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
self.irc.name, numeric)
|
||||
killpath = self.irc.servers[self.irc.sid].name
|
||||
|
||||
self._send(numeric, 'KILL %s :%s (%s)' % (target, killpath, reason))
|
||||
self._send_with_prefix(numeric, 'KILL %s :%s (%s)' % (target, killpath, reason))
|
||||
self.removeClient(target)
|
||||
|
||||
def nick(self, numeric, newnick):
|
||||
@ -191,7 +191,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
|
||||
self._send(numeric, 'NICK %s %s' % (newnick, int(time.time())))
|
||||
self._send_with_prefix(numeric, 'NICK %s %s' % (newnick, int(time.time())))
|
||||
|
||||
self.irc.users[numeric].nick = newnick
|
||||
|
||||
@ -207,13 +207,13 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
msg = "PART %s" % channel
|
||||
if reason:
|
||||
msg += " :%s" % reason
|
||||
self._send(client, msg)
|
||||
self._send_with_prefix(client, msg)
|
||||
self.handle_part(client, 'PART', [channel])
|
||||
|
||||
def quit(self, numeric, reason):
|
||||
"""Quits a PyLink client."""
|
||||
if self.irc.isInternalClient(numeric):
|
||||
self._send(numeric, "QUIT :%s" % reason)
|
||||
self._send_with_prefix(numeric, "QUIT :%s" % reason)
|
||||
self.removeClient(numeric)
|
||||
else:
|
||||
raise LookupError("No such PyLink client exists.")
|
||||
@ -226,7 +226,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
# Mangle message targets for IRCds that require it.
|
||||
target = self._expandPUID(target)
|
||||
|
||||
self._send(numeric, 'PRIVMSG %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'PRIVMSG %s :%s' % (target, text))
|
||||
|
||||
def notice(self, numeric, target, text):
|
||||
"""Sends a NOTICE from a PyLink client or server."""
|
||||
@ -237,13 +237,13 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
# Mangle message targets for IRCds that require it.
|
||||
target = self._expandPUID(target)
|
||||
|
||||
self._send(numeric, 'NOTICE %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'NOTICE %s :%s' % (target, text))
|
||||
|
||||
def topic(self, numeric, target, text):
|
||||
"""Sends a TOPIC change from a PyLink client."""
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(numeric, 'TOPIC %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'TOPIC %s :%s' % (target, text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
|
||||
@ -273,7 +273,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
raise ValueError('Server %r is not a PyLink server!' % uplink)
|
||||
if not utils.isServerName(name):
|
||||
raise ValueError('Invalid server name %r' % name)
|
||||
self._send(uplink, 'SID %s 1 %s :%s' % (name, sid, desc))
|
||||
self._send_with_prefix(uplink, 'SID %s 1 %s :%s' % (name, sid, desc))
|
||||
self.irc.servers[sid] = IrcServer(uplink, name, internal=True, desc=desc)
|
||||
return sid
|
||||
|
||||
@ -281,16 +281,16 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
||||
"""SQUITs a PyLink server."""
|
||||
# -> SQUIT 9PZ :blah, blah
|
||||
log.debug('source=%s, target=%s', source, target)
|
||||
self._send(source, 'SQUIT %s :%s' % (target, text))
|
||||
self._send_with_prefix(source, 'SQUIT %s :%s' % (target, text))
|
||||
self.handle_squit(source, 'SQUIT', [target, text])
|
||||
|
||||
def away(self, source, text):
|
||||
"""Sends an AWAY message from a PyLink client. <text> can be an empty string
|
||||
to unset AWAY status."""
|
||||
if text:
|
||||
self._send(source, 'AWAY :%s' % text)
|
||||
self._send_with_prefix(source, 'AWAY :%s' % text)
|
||||
else:
|
||||
self._send(source, 'AWAY')
|
||||
self._send_with_prefix(source, 'AWAY')
|
||||
self.irc.users[source].away = text
|
||||
|
||||
### HANDLERS
|
||||
|
@ -106,7 +106,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
encoded_ip = encoded_ip.strip().decode()
|
||||
|
||||
# <- :001 UID GL 0 1441306929 gl localhost 0018S7901 0 +iowx * midnight-1C620195 fwAAAQ== :realname
|
||||
self._send(server, "UID {nick} 0 {ts} {ident} {realhost} {uid} 0 {modes} "
|
||||
self._send_with_prefix(server, "UID {nick} 0 {ts} {ident} {realhost} {uid} 0 {modes} "
|
||||
"{host} * {ip} :{realname}".format(ts=ts, host=host,
|
||||
nick=nick, ident=ident, uid=uid,
|
||||
modes=raw_modes, realname=realname,
|
||||
@ -119,7 +119,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
channel = self.irc.toLower(channel)
|
||||
if not self.irc.isInternalClient(client):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(client, "JOIN %s" % channel)
|
||||
self._send_with_prefix(client, "JOIN %s" % channel)
|
||||
self.irc.channels[channel].users.add(client)
|
||||
self.irc.users[client].channels.add(channel)
|
||||
|
||||
@ -207,7 +207,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
source = source or self.irc.sid
|
||||
target = target or self.irc.uplink
|
||||
if not (target is None or source is None):
|
||||
self._send(source, 'PING %s %s' % (self.irc.servers[source].name, self.irc.servers[target].name))
|
||||
self._send_with_prefix(source, 'PING %s %s' % (self.irc.servers[source].name, self.irc.servers[target].name))
|
||||
|
||||
def mode(self, numeric, target, modes, ts=None):
|
||||
"""
|
||||
@ -252,7 +252,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
# Thanks to kevin and Jobe for helping me debug this!
|
||||
for modestring in self.irc.wrapModes(modes, bufsize, max_modes_per_msg=12):
|
||||
self._send(numeric, 'MODE %s %s %s' % (target, modestring, ts))
|
||||
self._send_with_prefix(numeric, 'MODE %s %s %s' % (target, modestring, ts))
|
||||
else:
|
||||
# For user modes, the only way to set modes (for non-U:Lined servers)
|
||||
# is through UMODE2, which sets the modes on the caller.
|
||||
@ -264,13 +264,13 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
# XXX: I don't expect usermode changes to ever get cut off, but length
|
||||
# checks could be added just to be safe...
|
||||
joinedmodes = self.irc.joinModes(modes)
|
||||
self._send(target, 'UMODE2 %s' % joinedmodes)
|
||||
self._send_with_prefix(target, 'UMODE2 %s' % joinedmodes)
|
||||
|
||||
def topicBurst(self, numeric, target, text):
|
||||
"""Sends a TOPIC change from a PyLink server."""
|
||||
if not self.irc.isInternalServer(numeric):
|
||||
raise LookupError('No such PyLink server exists.')
|
||||
self._send(numeric, 'TOPIC %s :%s' % (target, text))
|
||||
self._send_with_prefix(numeric, 'TOPIC %s :%s' % (target, text))
|
||||
self.irc.channels[target].topic = text
|
||||
self.irc.channels[target].topicset = True
|
||||
|
||||
@ -286,18 +286,18 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
# It is one of our clients, use SETIDENT/HOST/NAME.
|
||||
if field == 'IDENT':
|
||||
self.irc.users[target].ident = text
|
||||
self._send(target, 'SETIDENT %s' % text)
|
||||
self._send_with_prefix(target, 'SETIDENT %s' % text)
|
||||
elif field == 'HOST':
|
||||
self.irc.users[target].host = text
|
||||
self._send(target, 'SETHOST %s' % text)
|
||||
self._send_with_prefix(target, 'SETHOST %s' % text)
|
||||
elif field in ('REALNAME', 'GECOS'):
|
||||
self.irc.users[target].realname = text
|
||||
self._send(target, 'SETNAME :%s' % text)
|
||||
self._send_with_prefix(target, 'SETNAME :%s' % text)
|
||||
else:
|
||||
# It is a client on another server, use CHGIDENT/HOST/NAME.
|
||||
if field == 'IDENT':
|
||||
self.irc.users[target].ident = text
|
||||
self._send(self.irc.sid, 'CHGIDENT %s %s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGIDENT %s %s' % (target, text))
|
||||
|
||||
# Send hook payloads for other plugins to listen to.
|
||||
self.irc.callHooks([self.irc.sid, 'CHGIDENT',
|
||||
@ -305,14 +305,14 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
elif field == 'HOST':
|
||||
self.irc.users[target].host = text
|
||||
self._send(self.irc.sid, 'CHGHOST %s %s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGHOST %s %s' % (target, text))
|
||||
|
||||
self.irc.callHooks([self.irc.sid, 'CHGHOST',
|
||||
{'target': target, 'newhost': text}])
|
||||
|
||||
elif field in ('REALNAME', 'GECOS'):
|
||||
self.irc.users[target].realname = text
|
||||
self._send(self.irc.sid, 'CHGNAME %s :%s' % (target, text))
|
||||
self._send_with_prefix(self.irc.sid, 'CHGNAME %s :%s' % (target, text))
|
||||
|
||||
self.irc.callHooks([self.irc.sid, 'CHGNAME',
|
||||
{'target': target, 'newgecos': text}])
|
||||
@ -321,7 +321,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
"""Sends an INVITE from a PyLink client.."""
|
||||
if not self.irc.isInternalClient(numeric):
|
||||
raise LookupError('No such PyLink client exists.')
|
||||
self._send(numeric, 'INVITE %s %s' % (target, channel))
|
||||
self._send_with_prefix(numeric, 'INVITE %s %s' % (target, channel))
|
||||
|
||||
def knock(self, numeric, target, text):
|
||||
"""Sends a KNOCK from a PyLink client."""
|
||||
@ -331,7 +331,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
assert utils.isChannel(target), "Can only knock on channels!"
|
||||
sender = self.irc.getServer(numeric)
|
||||
s = '[Knock] by %s (%s)' % (self.irc.getHostmask(numeric), text)
|
||||
self._send(sender, 'NOTICE @%s :%s' % (target, s))
|
||||
self._send_with_prefix(sender, 'NOTICE @%s :%s' % (target, s))
|
||||
|
||||
### HANDLERS
|
||||
|
||||
@ -378,7 +378,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
sdesc = self.irc.serverdata.get('serverdesc') or conf.conf['bot']['serverdesc']
|
||||
f('SERVER %s 1 U%s-h6e-%s :%s' % (host, self.proto_ver, self.irc.sid, sdesc))
|
||||
f('NETINFO 1 %s %s * 0 0 0 :%s' % (self.irc.start_ts, self.proto_ver, self.irc.serverdata.get("netname", self.irc.name)))
|
||||
self._send(self.irc.sid, 'EOS')
|
||||
self._send_with_prefix(self.irc.sid, 'EOS')
|
||||
|
||||
def handle_eos(self, numeric, command, args):
|
||||
"""EOS is used to denote end of burst."""
|
||||
@ -958,6 +958,6 @@ class UnrealProtocol(TS6BaseProtocol):
|
||||
|
||||
if args[0] == 'alltime':
|
||||
# XXX: We override notice() here because that abstraction doesn't allow messages from servers.
|
||||
self._send(self.irc.sid, 'NOTICE %s :*** Server=%s time()=%d' % (source, self.irc.hostname(), time.time()))
|
||||
self._send_with_prefix(self.irc.sid, 'NOTICE %s :*** Server=%s time()=%d' % (source, self.irc.hostname(), time.time()))
|
||||
|
||||
Class = UnrealProtocol
|
||||
|
Loading…
Reference in New Issue
Block a user