mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
classes: return valid channels as-is in get_friendly_name()
This makes it safe to use when processing message targets. (ref #153)
This commit is contained in:
parent
0ac5d424d8
commit
244c4fe0eb
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user