From 63c97db12e1e748a4a904d984bd1f78197769b7d Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 31 May 2020 13:23:09 +0100 Subject: [PATCH] Function to select and merge IRC network defs --- modules/regproc.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/regproc.py b/modules/regproc.py index f1296bf..0b006b1 100644 --- a/modules/regproc.py +++ b/modules/regproc.py @@ -1,17 +1,26 @@ import main from modules import provision from utils.logging.log import * +from copy import deepcopy + +def selectInst(net): + if net in main.irc.keys(): + inst = deepcopy(main.irc[net]) + for i in main.irc["_"].keys(): + if not i in inst: + inst[i] = main.irc["_"][i] + else: + inst = main.irc["_"] + print(inst) + print("hello") + return inst def registerAccount(net, num): alias = main.alias[num] nickname = alias["nick"] username = nickname+"/"+net password = main.network[net].aliases[num]["password"] - if net in main.irc.keys(): - inst = main.irc[net] - else: - inst = main.irc["_"] - + inst = selectInst(net) if not inst["register"]: error("Cannot register for %s: function disabled" % (net)) return False @@ -25,10 +34,7 @@ def registerAccount(net, num): main.IRCPool[name].msg(entity, cmd) def confirmAccount(net, num, token): - if net in main.irc.keys(): - inst = main.irc[net] - else: - inst = main.irc["_"] + inst = selectInst(net) entity = inst["entity"] cmd = inst["confirm"] cmd = cmd.replace("{token}", token)