add ConnectionParams.from_hoststring("nick", "host:+port")
This commit is contained in:
parent
0edcbfa234
commit
6c91ebc7ec
1 changed files with 17 additions and 0 deletions
|
@ -50,3 +50,20 @@ class ConnectionParams(object):
|
|||
alt_nicknames: List[str] = field(default_factory=list)
|
||||
|
||||
autojoin: List[str] = field(default_factory=list)
|
||||
|
||||
@staticmethod
|
||||
def from_hoststring(
|
||||
nickname: str,
|
||||
hoststring: str
|
||||
) -> "ConnectionParams":
|
||||
|
||||
host, _, port_s = hoststring.strip().partition(":")
|
||||
|
||||
if port_s.startswith("+"):
|
||||
tls = True
|
||||
port_s = port_s.lstrip("+") or "6697"
|
||||
elif not port_s:
|
||||
tls = False
|
||||
port_s = "6667"
|
||||
|
||||
return ConnectionParams(nickname, host, int(port_s), tls)
|
||||
|
|
Loading…
Add table
Reference in a new issue