mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
protocols: format kills properly in ts6_common.handle_kill() (#239)
This separates the kill handling for InspIRCd and other TS6 protocols, as InspIRCd pre-formats kills when they are sent.
This commit is contained in:
parent
3457da16bd
commit
d549e2ae47
@ -770,4 +770,17 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
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.irc.users.get(killed)
|
||||||
|
if data:
|
||||||
|
self.removeClient(killed)
|
||||||
|
return {'target': killed, 'text': args[1], 'userdata': data}
|
||||||
|
|
||||||
Class = InspIRCdProtocol
|
Class = InspIRCdProtocol
|
||||||
|
@ -363,7 +363,29 @@ class TS6BaseProtocol(Protocol):
|
|||||||
data = self.irc.users.get(killed)
|
data = self.irc.users.get(killed)
|
||||||
if data:
|
if data:
|
||||||
self.removeClient(killed)
|
self.removeClient(killed)
|
||||||
return {'target': killed, 'text': args[1], 'userdata': data}
|
|
||||||
|
# TS6-style kills look something like this:
|
||||||
|
# <- :GL KILL 38QAAAAAA :hidden-1C620195!GL (test)
|
||||||
|
# What we actually want is to format a pretty kill message, in the form
|
||||||
|
# "Killed (killername (reason))".
|
||||||
|
|
||||||
|
if source in self.irc.users:
|
||||||
|
# Killer was a user (they're SO fired)
|
||||||
|
killer = self.irc.users[source].nick
|
||||||
|
elif source in self.irc.servers:
|
||||||
|
# Killer was a server (impossible, the machine is always right)
|
||||||
|
killer = self.irc.servers[source].name
|
||||||
|
else:
|
||||||
|
# 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:])
|
||||||
|
|
||||||
|
killmsg = "Killed (%s %s)" % (killer, reason)
|
||||||
|
|
||||||
|
return {'target': killed, 'text': killmsg, 'userdata': data}
|
||||||
|
|
||||||
def handle_kick(self, source, command, args):
|
def handle_kick(self, source, command, args):
|
||||||
"""Handles incoming KICKs."""
|
"""Handles incoming KICKs."""
|
||||||
|
Loading…
Reference in New Issue
Block a user