From 244c4fe0eb37e9858ee27963f5cc4f4bfe194757 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 11 May 2018 14:40:24 -0700 Subject: [PATCH] classes: return valid channels as-is in get_friendly_name() This makes it safe to use when processing message targets. (ref #153) --- classes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index 644113a..c9700a2 100644 --- a/classes.py +++ b/classes.py @@ -1172,12 +1172,16 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore): def get_friendly_name(self, entityid): """ - Returns the friendly name of a SID or UID (server name for SIDs, nick for UID). + Returns the friendly name of a SID (the server name), UID (the nick), or channel (returned as-is). """ if entityid in self.servers: return self.servers[entityid].name elif entityid in self.users: return self.users[entityid].nick + elif self.is_channel(entityid): + # We assume that channels don't conflict with the SID/UID format. For IRC, this is a + # relatively safe bet. + return entityid else: raise KeyError("Unknown UID/SID %s" % entityid)