From e0f86ec85330a59985095c9b8e3dc1c803dcb4d1 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:39:46 +0100 Subject: [PATCH] Fix provisioning with emails --- modules/provision.py | 2 +- modules/regproc.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/provision.py b/modules/provision.py index 990db63..8e1dab2 100644 --- a/modules/provision.py +++ b/modules/provision.py @@ -5,7 +5,7 @@ from twisted.internet import reactor import modules.regproc -def provisionUserNetworkData(num, nick, altnick, ident, realname, network, host, port, security, auth, password): +def provisionUserNetworkData(num, nick, altnick, emails, ident, realname, network, host, port, security, auth, password): commands = {} stage2commands = {} stage2commands["status"] = [] diff --git a/modules/regproc.py b/modules/regproc.py index 26cdae2..fe19cc7 100644 --- a/modules/regproc.py +++ b/modules/regproc.py @@ -3,7 +3,7 @@ from modules import provision from utils.logging.log import * from utils.logging.debug import * from copy import deepcopy - +from random import choice def needToRegister(net): inst = selectInst(net) @@ -28,16 +28,23 @@ def selectInst(net): def substitute(net, num, token=None): inst = selectInst(net) alias = main.alias[num] + if "emails" in inst: + # 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}") nickname = alias["nick"] username = nickname + "/" + net password = main.network[net].aliases[num]["password"] - inst["email"] = inst["email"].replace("{nickname}", nickname) + #inst["email"] = inst["email"].replace("{nickname}", nickname) for i in inst.keys(): if not isinstance(inst[i], str): continue inst[i] = inst[i].replace("{nickname}", nickname) inst[i] = inst[i].replace("{password}", password) - inst[i] = inst[i].replace("{email}", inst["email"]) + inst[i] = inst[i].replace("{email}", email) if token: inst[i] = inst[i].replace("{token}", token) return inst