Reformat project
This commit is contained in:
@@ -15,7 +15,7 @@ def generate_alias():
|
||||
rand = random.randint(1, 4)
|
||||
while rand == 1:
|
||||
split = random.randint(0, len(nick) - 1)
|
||||
nick = nick[:split] + nick[split + 1 :]
|
||||
nick = nick[:split] + nick[split + 1 :] # noqa: E203
|
||||
rand = random.randint(1, 4)
|
||||
rand = random.randint(1, 3)
|
||||
if rand == 1 or rand == 4:
|
||||
@@ -53,7 +53,7 @@ def generate_alias():
|
||||
ident = namebase.split(" ")[0]
|
||||
ident = ident[:10]
|
||||
elif rand == 6:
|
||||
ident = re.sub("\s", "", namebase).lower()
|
||||
ident = re.sub("\s", "", namebase).lower() # noqa: W605
|
||||
ident = ident[:10]
|
||||
|
||||
realname = nick
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from utils.logging.log import log, warn, error
|
||||
from utils.logging.debug import debug
|
||||
from copy import deepcopy
|
||||
from math import ceil
|
||||
import modules.provision
|
||||
@@ -166,7 +166,7 @@ def _initialList(net, num, listinfo, chanlimit):
|
||||
|
||||
sigrelay = ceil(siglength / chanlimit)
|
||||
relay = ceil(listlength / chanlimit)
|
||||
netbase = "list.%s" % net
|
||||
# netbase = "list.%s" % net
|
||||
abase = "analytics.list.%s" % net
|
||||
p = main.g.pipeline()
|
||||
p.hset(abase, "mean", mean)
|
||||
|
||||
@@ -3,11 +3,11 @@ from twisted.internet.task import LoopingCall
|
||||
|
||||
|
||||
def event(name, eventType):
|
||||
if not "local" in main.counters.keys():
|
||||
if "local" not in main.counters.keys():
|
||||
main.counters["local"] = {}
|
||||
if not "global" in main.counters.keys():
|
||||
if "global" not in main.counters.keys():
|
||||
main.counters["global"] = {}
|
||||
if not name in main.counters["local"].keys():
|
||||
if name not in main.counters["local"].keys():
|
||||
main.counters["local"][name] = {}
|
||||
if eventType not in main.counters["local"][name].keys():
|
||||
main.counters["local"][name][eventType] = 0
|
||||
@@ -21,7 +21,7 @@ def event(name, eventType):
|
||||
|
||||
|
||||
def getEvents(name=None):
|
||||
if name == None:
|
||||
if name is None:
|
||||
if "global" in main.counters.keys():
|
||||
return main.counters["global"]
|
||||
else:
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
from copy import deepcopy
|
||||
from json import dumps
|
||||
|
||||
import main
|
||||
from core.relay import sendRelayNotification
|
||||
from core.logstash import sendLogstashNotification
|
||||
from modules import userinfo
|
||||
from modules import regproc
|
||||
from utils.dedup import dedup
|
||||
|
||||
order = [
|
||||
@@ -29,7 +24,7 @@ order = [
|
||||
|
||||
|
||||
def parsemeta(numName, c):
|
||||
if not "channel" in c.keys():
|
||||
if "channel" not in c.keys():
|
||||
c["channel"] = None
|
||||
# metadata scraping
|
||||
# need to check if this was received from a relay
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from twisted.internet.ssl import DefaultOpenSSLContextFactory
|
||||
import json
|
||||
|
||||
from modules import alias
|
||||
from modules.chankeep import nukeNetwork
|
||||
from modules.regproc import needToRegister
|
||||
from twisted.internet import reactor
|
||||
from core.bot import IRCBot, IRCBotFactory
|
||||
from core.bot import IRCBotFactory
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
from utils.logging.log import log
|
||||
from utils.get import getRelay
|
||||
|
||||
|
||||
@@ -41,7 +40,7 @@ class Network:
|
||||
"registered": registered,
|
||||
}
|
||||
password = alias.generate_password()
|
||||
if not num in main.alias.keys():
|
||||
if num not in main.alias.keys():
|
||||
main.alias[num] = alias.generate_alias()
|
||||
main.saveConf("alias")
|
||||
self.aliases[num] = {"password": password}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import main
|
||||
from utils.deliver_relay_commands import deliverRelayCommands
|
||||
from utils.logging.log import *
|
||||
from twisted.internet import reactor
|
||||
import modules.regproc
|
||||
|
||||
@@ -64,7 +63,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"]
|
||||
# alias = aliasObj["nick"]
|
||||
provisionUserNetworkData(
|
||||
num,
|
||||
*aliasObj.values(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import main
|
||||
from modules import provision
|
||||
from utils.logging.log import *
|
||||
from utils.logging.debug import *
|
||||
from utils.logging.log import error
|
||||
from utils.logging.debug import debug
|
||||
from copy import deepcopy
|
||||
from random import choice
|
||||
|
||||
@@ -24,7 +24,7 @@ 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:
|
||||
if i not in inst:
|
||||
inst[i] = main.irc["_"][i]
|
||||
else:
|
||||
inst = main.irc["_"]
|
||||
@@ -50,7 +50,7 @@ def substitute(net, num, token=None):
|
||||
error(f"Could not get email for {net} - {num}")
|
||||
return False
|
||||
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():
|
||||
@@ -88,7 +88,7 @@ def confirmRegistration(net, num, negativepass=None):
|
||||
obj = main.network[net]
|
||||
name = net + str(num)
|
||||
if name in main.IRCPool.keys():
|
||||
if not negativepass == None:
|
||||
if negativepass is not None:
|
||||
main.IRCPool[name].regPing(negativepass=negativepass)
|
||||
return
|
||||
debug("Relay authenticated: %s - %i" % (net, num))
|
||||
@@ -100,7 +100,7 @@ def confirmRegistration(net, num, negativepass=None):
|
||||
if main.IRCPool[name]._regAttempt:
|
||||
try:
|
||||
main.IRCPool[name]._regAttempt.cancel()
|
||||
except:
|
||||
except: # noqa
|
||||
pass
|
||||
obj.relays[num]["registered"] = True
|
||||
main.saveConf("network")
|
||||
@@ -112,22 +112,22 @@ def enableAuthentication(net, num):
|
||||
security = obj.security
|
||||
auth = obj.auth
|
||||
password = obj.aliases[num]["password"]
|
||||
uname = main.alias[num]["nick"] + "/" + net
|
||||
# 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:
|
||||
if selectInst(net)["check"] is False:
|
||||
confirmRegistration(net, num)
|
||||
|
||||
|
||||
def registerTest(c):
|
||||
sinst = substitute(c["net"], c["num"])
|
||||
name = c["net"] + str(c["num"])
|
||||
if sinst["check"] == False:
|
||||
if sinst["check"] is False:
|
||||
return
|
||||
if "msg" in c.keys() and not c["msg"] == None:
|
||||
if "msg" in c.keys() and not c["msg"] is None:
|
||||
if sinst["negative"]:
|
||||
if name in main.IRCPool.keys():
|
||||
if not main.IRCPool[name]._negativePass == True:
|
||||
if main.IRCPool[name]._negativePass is not True:
|
||||
if c["type"] == "query" and c["nick"] == sinst["entity"]:
|
||||
if sinst["checknegativemsg"] in c["msg"]:
|
||||
confirmRegistration(
|
||||
@@ -150,6 +150,6 @@ def registerTest(c):
|
||||
elif sinst["checktype"] == "mode":
|
||||
if c["type"] == "self":
|
||||
if c["mtype"] == "mode":
|
||||
if sinst["checkmode"] in c["mode"] and c["status"] == True:
|
||||
if sinst["checkmode"] in c["mode"] and c["status"] is True:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from twisted.internet.threads import deferToThread
|
||||
from string import digits
|
||||
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
from utils.logging.debug import debug, trace
|
||||
from utils.logging.log import warn
|
||||
from utils.logging.debug import trace
|
||||
from utils.parsing import parsen
|
||||
|
||||
|
||||
@@ -97,7 +96,7 @@ def _initialUsers(name, channel, users):
|
||||
|
||||
def initialUsers(name, channel, users):
|
||||
trace("Initialising WHO records for %s on %s" % (channel, name))
|
||||
d = deferToThread(_initialUsers, name, channel, users)
|
||||
deferToThread(_initialUsers, name, channel, users)
|
||||
# d.addCallback(testCallback)
|
||||
|
||||
|
||||
@@ -114,7 +113,7 @@ def _initialNames(name, channel, names):
|
||||
|
||||
def initialNames(name, channel, names):
|
||||
trace("Initialising NAMES records for %s on %s" % (channel, name))
|
||||
d = deferToThread(_initialNames, name, channel, names)
|
||||
deferToThread(_initialNames, name, channel, names)
|
||||
# d.addCallback(testCallback)
|
||||
|
||||
|
||||
@@ -260,5 +259,5 @@ def _delChannels(net, channels):
|
||||
|
||||
def delChannels(net, channels): # we have left a channel
|
||||
trace("Purging channel %s for %s" % (", ".join(channels), net))
|
||||
d = deferToThread(_delChannels, net, channels)
|
||||
deferToThread(_delChannels, net, channels)
|
||||
# d.addCallback(testCallback)
|
||||
|
||||
Reference in New Issue
Block a user