From 56c8b903622be3074a5f048c8570ad44b97d636d Mon Sep 17 00:00:00 2001 From: James Lu Date: Wed, 5 Jul 2017 02:25:13 -0700 Subject: [PATCH] IRCS2SProtocol: handle both killpath-based and preformatted kill reasons Also drop the override in protocols/inspircd, as it is no longer needed. --- protocols/inspircd.py | 13 ------------- protocols/ircs2s_common.py | 28 ++++++++++++++++++---------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 83a0fbe..55706e4 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -767,19 +767,6 @@ class InspIRCdProtocol(TS6BaseProtocol): Stub VERSION handler (does nothing) to override the one in ts6_common. """ - def handle_kill(self, source, command, args): - """Handles incoming KILLs.""" - killed = args[0] - # Depending on whether the IRCd sends explicit QUIT messages for - # killed clients, the user may or may not have automatically been - # removed from our user list. - # If not, we have to assume that KILL = QUIT and remove them - # ourselves. - data = self.users.get(killed) - if data: - self._remove_client(killed) - return {'target': killed, 'text': args[1], 'userdata': data} - def handle_sakick(self, source, command, args): """Handles forced kicks (SAKICK).""" # <- :1MLAAAAAD ENCAP 0AL SAKICK #test 0ALAAAAAB :test diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 066c377..b36e878 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -518,18 +518,26 @@ class IRCS2SProtocol(IRCCommonProtocol): # What we actually want is to format a pretty kill message, in the form # "Killed (killername (reason))". - try: - # Get the nick or server name of the caller. - killer = self.get_friendly_name(source) - except KeyError: - # Killer was... neither? We must have aliens or something. Fallback - # to the given "UID". - killer = source + if '!' in args[1].split(" ", 1)[0]: + try: + # Get the nick or server name of the caller. + killer = self.get_friendly_name(source) + except KeyError: + # Killer was... neither? We must have aliens or something. Fallback + # to the given "UID". + killer = source - # Get the reason, which is enclosed in brackets. - reason = ' '.join(args[1].split(" ")[1:]) + # Get the reason, which is enclosed in brackets. + reason = ' '.join(args[1].split(" ")[1:]) - killmsg = "Killed (%s %s)" % (killer, reason) + killmsg = "Killed (%s %s)" % (killer, reason) + else: + # We already have a preformatted kill, so just pass it on as is. + # InspIRCd: + # <- :1MLAAAAA1 KILL 0ALAAAAAC :Killed (GL (test)) + # ngIRCd: + # <- :GL KILL PyLink-devel :KILLed by GL: ? + killmsg = args[1] return {'target': killed, 'text': killmsg, 'userdata': data}