diff --git a/classes.py b/classes.py index 0ee1a4b..ee35cbb 100644 --- a/classes.py +++ b/classes.py @@ -871,6 +871,16 @@ class Irc(): return '%s!%s@%s' % (nick, ident, host) + def getFriendlyName(self, entityid): + """ + Returns the friendly name of a SID or UID (server name for SIDs, nick for UID).""" + if entityid in self.servers: + return self.servers[entityid].name + elif entityid in self.users: + return self.users[entityid].nick + else: + raise KeyError("Unknown UID/SID %s" % entityid) + def isOper(self, uid, allowAuthed=True, allowOper=True): """ Returns whether the given user has operator status on PyLink. This can be achieved diff --git a/protocols/ircs2s_common.py b/protocols/ircs2s_common.py index 188f8c3..06a8909 100644 --- a/protocols/ircs2s_common.py +++ b/protocols/ircs2s_common.py @@ -24,13 +24,10 @@ class IRCS2SProtocol(Protocol): # 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: + try: + # Get the nick or server name of the caller. + killer = self.irc.getFriendlyName(source) + except KeyError: # Killer was... neither? We must have aliens or something. Fallback # to the given "UID". killer = source