Reformat code with pre-commit
This commit is contained in:
@@ -4,6 +4,7 @@ from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from copy import deepcopy
|
||||
|
||||
|
||||
def needToRegister(net):
|
||||
inst = selectInst(net)
|
||||
if "register" in inst.keys():
|
||||
@@ -12,6 +13,7 @@ def needToRegister(net):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def selectInst(net):
|
||||
if net in main.irc.keys():
|
||||
inst = deepcopy(main.irc[net])
|
||||
@@ -22,11 +24,12 @@ def selectInst(net):
|
||||
inst = main.irc["_"]
|
||||
return inst
|
||||
|
||||
|
||||
def substitute(net, num, token=None):
|
||||
inst = selectInst(net)
|
||||
alias = main.alias[num]
|
||||
nickname = alias["nick"]
|
||||
username = nickname+"/"+net
|
||||
username = nickname + "/" + net
|
||||
password = main.network[net].aliases[num]["password"]
|
||||
inst["email"] = inst["email"].replace("{nickname}", nickname)
|
||||
for i in inst.keys():
|
||||
@@ -39,29 +42,32 @@ def substitute(net, num, token=None):
|
||||
inst[i] = inst[i].replace("{token}", token)
|
||||
return inst
|
||||
|
||||
|
||||
def registerAccount(net, num):
|
||||
debug("Attempting to register: %s - %i" % (net, num))
|
||||
sinst = substitute(net, num)
|
||||
if not sinst["register"]:
|
||||
error("Cannot register for %s: function disabled" % (net))
|
||||
return False
|
||||
name = net+str(num)
|
||||
name = net + str(num)
|
||||
main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"])
|
||||
|
||||
|
||||
def confirmAccount(net, num, token):
|
||||
sinst = substitute(net, num, token=token)
|
||||
name = net+str(num)
|
||||
name = net + str(num)
|
||||
main.IRCPool[name].msg(sinst["entity"], sinst["confirm"])
|
||||
enableAuthentication(net, num)
|
||||
|
||||
|
||||
def confirmRegistration(net, num, negativepass=None):
|
||||
obj = main.network[net]
|
||||
name = net+str(num)
|
||||
name = net + str(num)
|
||||
if name in main.IRCPool.keys():
|
||||
if not negativepass == None:
|
||||
main.IRCPool[name].regPing(negativepass=negativepass)
|
||||
return
|
||||
debug("Relay authenticated: %s - %i" %(net, num))
|
||||
debug("Relay authenticated: %s - %i" % (net, num))
|
||||
main.IRCPool[name].authenticated = True
|
||||
main.IRCPool[name].recheckList()
|
||||
if obj.relays[num]["registered"]:
|
||||
@@ -75,21 +81,23 @@ def confirmRegistration(net, num, negativepass=None):
|
||||
obj.relays[num]["registered"] = True
|
||||
main.saveConf("network")
|
||||
|
||||
|
||||
def enableAuthentication(net, num):
|
||||
obj = main.network[net]
|
||||
nick = main.alias[num]["nick"]
|
||||
security = obj.security
|
||||
auth = obj.auth
|
||||
password = obj.aliases[num]["password"]
|
||||
uname = main.alias[num]["nick"]+"/"+net
|
||||
provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth
|
||||
main.IRCPool[net+str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"]+"status", "Jump")
|
||||
uname = main.alias[num]["nick"] + "/" + net
|
||||
provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth
|
||||
main.IRCPool[net + str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"] + "status", "Jump")
|
||||
if selectInst(net)["check"] == False:
|
||||
confirmRegistration(net, num)
|
||||
|
||||
|
||||
def registerTest(c):
|
||||
sinst = substitute(c["net"], c["num"])
|
||||
name = c["net"]+str(c["num"])
|
||||
name = c["net"] + str(c["num"])
|
||||
if sinst["check"] == False:
|
||||
return
|
||||
if "msg" in c.keys() and not c["msg"] == None:
|
||||
@@ -98,19 +106,19 @@ def registerTest(c):
|
||||
if not main.IRCPool[name]._negativePass == True:
|
||||
if c["type"] == "query" and c["nick"] == sinst["entity"]:
|
||||
if sinst["checknegativemsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"], negativepass=False) # Not passed negative check, report back
|
||||
confirmRegistration(c["net"], c["num"], negativepass=False) # Not passed negative check, report back
|
||||
return
|
||||
if sinst["checkendnegative"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"], negativepass=True) # Passed the negative check, report back
|
||||
confirmRegistration(c["net"], c["num"], negativepass=True) # Passed the negative check, report back
|
||||
return
|
||||
if sinst["ping"]:
|
||||
if sinst["checkmsg2"] in c["msg"] and c["nick"] == sinst["entity"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
if sinst["checktype"] == "msg":
|
||||
if sinst["checkmsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
if sinst["checkmsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
elif sinst["checktype"] == "mode":
|
||||
if c["type"] == "self":
|
||||
if c["mtype"] == "mode":
|
||||
|
||||
Reference in New Issue
Block a user