Extra error handling around emails

This commit is contained in:
Mark Veidemanis 2022-07-21 13:39:52 +01:00
parent 1532cf482c
commit 757b22c4a1
3 changed files with 27 additions and 7 deletions

View File

@ -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

View File

@ -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,

View File

@ -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
if alias["emails"]:
email = choice(alias["emails"])
elif "domains" in inst:
gotemail = True
if "domains" in inst:
if inst["domains"]:
if not gotemail:
domain = choice(inst["domains"])
email = f"{alias['nickname']}@{domain}"
print("Constructed email: {email}")
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