3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 19:52:53 +01:00

NetworkCoreWithUtils: shortcut _get_SID/UID if the target already exists

This commit is contained in:
James Lu 2017-07-02 22:35:39 -07:00
parent e866e9eb7b
commit bbc4dec8dd

View File

@ -1100,6 +1100,10 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
def _get_SID(self, sname):
"""Returns the SID of a server with the given name, if present."""
name = sname.lower()
if name in self.servers:
return name
for k, v in self.servers.items():
if v.name.lower() == name:
return k
@ -1110,6 +1114,10 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
def _get_UID(self, target):
"""Converts a nick argument to its matching UID. This differs from irc.nick_to_uid()
in that it returns the original text instead of None, if no matching nick is found."""
if target in self.users:
return target
target = self.nick_to_uid(target) or target
return target
_getUid = _get_UID