From d0b7d44f1a80cfedf7943d4f03cbf0db09c6a60d Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 4 Jul 2016 23:34:05 -0700 Subject: [PATCH] ts6: implement kill paths in outgoing KILL (#239) --- protocols/ts6.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/protocols/ts6.py b/protocols/ts6.py index cb75112..646d38a 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -196,6 +196,7 @@ class TS6Protocol(TS6BaseProtocol): (not self.irc.isInternalServer(numeric)): raise LookupError('No such PyLink client/server exists.') + # From TS6 docs: # KILL: # parameters: target user, path @@ -204,7 +205,21 @@ class TS6Protocol(TS6BaseProtocol): # it is recommended not to add anything to the path. assert target in self.irc.users, "Unknown target %r for kill()!" % target - self._send(numeric, 'KILL %s :Killed (%s)' % (target, reason)) + + if numeric in self.irc.users: + # Killer was an user. Follow examples of setting the path to be "killer.host!killer.nick". + userobj = self.irc.users[numeric] + killpath = '%s!%s' % (userobj.host, userobj.nick) + elif numeric in self.irc.servers: + # Sender was a server; killpath is just its name. + killpath = self.irc.servers[numeric].name + else: + # Invalid sender?! This shouldn't happen, but make the killpath our server name anyways. + log.warning('(%s) Invalid sender %s for kill(); using our server name instead.', + self.irc.name, numeric) + killpath = self.irc.servers[self.irc.sid].name + + self._send(numeric, 'KILL %s :%s (%s)' % (target, killpath, reason)) self.removeClient(target) def topicBurst(self, numeric, target, text):