From 4734a271a1701f1e9813dfe6ced31840f20d18c3 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:39:52 +0100 Subject: [PATCH] Extra error handling around emails --- core/bot.py | 3 +++ modules/provision.py | 8 +++++++- modules/regproc.py | 23 +++++++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/core/bot.py b/core/bot.py index b735e96..04e32dd 100644 --- a/core/bot.py +++ b/core/bot.py @@ -658,6 +658,9 @@ class IRCBot(IRCClient): if self.authenticated: return sinst = regproc.substitute(self.net, self.num) + if not sinst: + error(f"Registration ping failed for {self.net} - {self.num}") + return if not self._negativePass == True: if negativepass == False: self._negativePass = False diff --git a/modules/provision.py b/modules/provision.py index 8e1dab2..1f17a20 100644 --- a/modules/provision.py +++ b/modules/provision.py @@ -5,7 +5,12 @@ from twisted.internet import reactor import modules.regproc -def provisionUserNetworkData(num, nick, altnick, emails, ident, realname, network, host, port, security, auth, password): +def provisionUserNetworkData(num, nick, altnick, ident, realname, emails, network, host, port, security, auth, password): + print("nick", nick) + print("altnick", altnick) + print("emails", emails) + print("ident", ident) + print("realname", realname) commands = {} stage2commands = {} stage2commands["status"] = [] @@ -56,6 +61,7 @@ def provisionAuthenticationData(num, nick, network, security, auth, password): def provisionRelay(num, network): # provision user and network data aliasObj = main.alias[num] + print("ALIASOBJ FALUES", aliasObj.values()) alias = aliasObj["nick"] provisionUserNetworkData( num, diff --git a/modules/regproc.py b/modules/regproc.py index fe19cc7..5cf52f6 100644 --- a/modules/regproc.py +++ b/modules/regproc.py @@ -28,13 +28,21 @@ def selectInst(net): def substitute(net, num, token=None): inst = selectInst(net) alias = main.alias[num] - if "emails" in inst: + gotemail = False + if "emails" in alias: # First priority is explicit email lists - email = choice(alias["emails"]) - elif "domains" in inst: - domain = choice(inst["domains"]) - email = f"{alias['nickname']}@{domain}" - print("Constructed email: {email}") + if alias["emails"]: + email = choice(alias["emails"]) + gotemail = True + if "domains" in inst: + if inst["domains"]: + if not gotemail: + domain = choice(inst["domains"]) + email = f"{alias['nickname']}@{domain}" + gotemail = True + if not gotemail: + error(f"Could not get email for {net} - {num}") + return False nickname = alias["nick"] username = nickname + "/" + net password = main.network[net].aliases[num]["password"] @@ -53,6 +61,9 @@ def substitute(net, num, token=None): def registerAccount(net, num): debug("Attempting to register: %s - %i" % (net, num)) sinst = substitute(net, num) + if not sinst: + error(f"Register account failed for {net} - {num}") + return if not sinst["register"]: error("Cannot register for %s: function disabled" % (net)) return False