mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-28 05:29:25 +01:00
Move _get_SID/_get_UID to IRCCommonProtocol
This commit is contained in:
parent
bbc4dec8dd
commit
640e903dd6
26
classes.py
26
classes.py
@ -1096,32 +1096,6 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
|||||||
_clear()
|
_clear()
|
||||||
_apply()
|
_apply()
|
||||||
|
|
||||||
# TODO: these wrappers really need to be standardized
|
|
||||||
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
|
|
||||||
else:
|
|
||||||
return sname # Fall back to given text instead of None
|
|
||||||
_getSid = _get_SID
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -19,6 +19,30 @@ class IRCCommonProtocol(IRCNetwork):
|
|||||||
port = self.serverdata['port']
|
port = self.serverdata['port']
|
||||||
assert type(port) == int and 0 < port < 65535, "Invalid port %r for network %s" % (port, self.name)
|
assert type(port) == int and 0 < port < 65535, "Invalid port %r for network %s" % (port, self.name)
|
||||||
|
|
||||||
|
# TODO: these wrappers really need to be standardized
|
||||||
|
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
|
||||||
|
else:
|
||||||
|
return sname # Fall back to given text instead of None
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_args(args):
|
def parse_args(args):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user