3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

ts6: support legacy (non-sid) server introduction

Closes #119.

For the sake of simplicity, server swithout a SID are stored by their server names internally, which is convenient because no reverse lookup is needed when an SQUIT is received for it.
This commit is contained in:
James Lu 2015-10-12 17:49:03 -07:00
parent d21ce9983d
commit d4200424fa
2 changed files with 10 additions and 3 deletions

View File

@ -597,14 +597,14 @@ class TS6Protocol(TS6BaseProtocol):
self.irc.servers[sid] = IrcServer(numeric, servername, desc=sdesc)
return {'name': servername, 'sid': sid, 'text': sdesc}
def handle_server(self, numeric, command, args):
def handle_server(self, sender, command, args):
"""Handles incoming legacy (no SID) server introductions."""
# <- :services.int SERVER a.bc 2 :(H) [GL] a
raise NotImplementedError
numeric = self._getSid(sender) # Convert the server name prefix to a SID.
servername = args[0].lower()
sdesc = args[-1]
self.irc.servers[servername] = IrcServer(numeric, servername, desc=sdesc)
return {'name': servername, 'sid': sid, 'text': sdesc}
return {'name': servername, 'sid': None, 'text': sdesc}
def handle_tmode(self, numeric, command, args):
"""Handles incoming TMODE commands (channel mode change)."""

View File

@ -19,6 +19,13 @@ class TS6BaseProtocol(Protocol):
args[0] = args[0].split(':', 1)[1]
return args
def _getSid(self, sname):
"""Returns the SID of a server with the given name, if present."""
nick = sname.lower()
for k, v in self.irc.servers.items():
if v.name.lower() == nick:
return k
### OUTGOING COMMANDS
def _sendKick(self, numeric, channel, target, reason=None):