try before connect logic

This commit is contained in:
Pratyush Desai 2022-08-31 17:34:32 +05:30
parent 1525887c9d
commit 6ad857ed29
Signed by: pratyush
GPG Key ID: DBA5BB7505946FAD

View File

@ -37,12 +37,11 @@ def ircregister(userip, username, password, email="*"):
# Inform the server that we support
# CAP 3.2
_send(irctokens.build("CAP", ["LS", "302"]))
# REGISTER can be attempted before-connect if server supports
# but if the server responds with the corresponding FAIL we
# need to try again. We can also handle email-required using
# the same keys. How to access these key-value pairs?
# reference: https://github.com/ProgVal/ircv3-specifications/blob/register/extensions/account-registration.md#commands
# lines = d.push(s.recv(1024))
if 'draft/account-registration=before-connnect' in lines.params:
# add extra conditional for custom account and email-required
_send(irctokens.build("REGISTER" ["*", password]))
else:
# NICK and USER
_send(irctokens.build("USER", ["u", "0", "*", username]))