Implement ChanKeep joining functions
* Low-key channel joining with incrementally increasing delay * Spin up needed instances to be able to cover a certain channel space * Fix provisioning functions to prevent race conditions with lots of relays being created at once * Tweakable switchover from covering all channels to only covering channels with more users than the mean of the cumulative user count
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import main
|
||||
from core.bot import deliverRelayCommands
|
||||
from utils.logging.log import *
|
||||
from twisted.internet import reactor
|
||||
|
||||
def provisionUserData(num, nick, altnick, ident, realname, unused): # last field is password, which we don't want to inherit here, but still want to use * expansion, so this is a bit of a hack
|
||||
def provisionUserData(num, nick, altnick, ident, realname, unused): # last field is password,
|
||||
# which we don't want to inherit here, but still want to use * expansion, so this is a bit of a hack
|
||||
commands = {}
|
||||
commands["controlpanel"] = []
|
||||
commands["controlpanel"].append("AddUser %s %s" % (nick, main.config["Relay"]["Password"]))
|
||||
@@ -16,7 +18,7 @@ def provisionUserData(num, nick, altnick, ident, realname, unused): # last field
|
||||
def provisionNetworkData(num, nick, network, host, port, security, auth, password):
|
||||
commands = {}
|
||||
stage2commands = {}
|
||||
stage3commands = {}
|
||||
stage2commands["status"] = []
|
||||
commands["controlpanel"] = []
|
||||
commands["controlpanel"].append("AddNetwork %s %s" % (nick, network))
|
||||
if security == "ssl":
|
||||
@@ -25,26 +27,21 @@ def provisionNetworkData(num, nick, network, host, port, security, auth, passwor
|
||||
elif security == "plain":
|
||||
commands["controlpanel"].append("AddServer %s %s %s %s" % (nick, network, host, port))
|
||||
if auth == "sasl":
|
||||
stage2commands["status"] = []
|
||||
stage2commands["sasl"] = []
|
||||
stage2commands["status"].append("LoadMod sasl")
|
||||
stage2commands["sasl"].append("Mechanism plain")
|
||||
stage2commands["sasl"].append("Set %s %s" % (nick, password))
|
||||
elif auth == "ns":
|
||||
stage2commands["status"] = []
|
||||
stage2commands["nickserv"] = []
|
||||
stage2commands["status"].append("LoadMod nickserv")
|
||||
stage2commands["nickserv"].append("Set %s" % password)
|
||||
if not main.config["ConnectOnCreate"]:
|
||||
stage3commands["status"] = []
|
||||
stage3commands["status"].append("Disconnect")
|
||||
stage2commands["status"].append("Disconnect")
|
||||
if main.config["Toggles"]["CycleChans"]:
|
||||
stage2commands["status"] = []
|
||||
stage2commands["status"].append("LoadMod disconkick")
|
||||
stage2commands["status"].append("LoadMod chansaver")
|
||||
deliverRelayCommands(num, commands,
|
||||
stage2=[[nick+"/"+network, stage2commands],
|
||||
[nick+"/"+network, stage3commands]])
|
||||
stage2=[[nick+"/"+network, stage2commands]])
|
||||
return
|
||||
|
||||
def provisionRelayForNetwork(num, alias, network):
|
||||
@@ -60,14 +57,15 @@ def provisionRelay(num, network):
|
||||
aliasObj = main.alias[num]
|
||||
alias = aliasObj["nick"]
|
||||
provisionUserData(num, *aliasObj.values())
|
||||
provisionRelayForNetwork(num, alias, network)
|
||||
reactor.callLater(5, provisionRelayForNetwork, num, alias, network)
|
||||
if main.config["ConnectOnCreate"]:
|
||||
main.network[network].start_bot(num)
|
||||
return alias
|
||||
reactor.callLater(10, main.network[network].start_bot, num)
|
||||
return
|
||||
|
||||
def provisionMultipleRelays(net, relaysNeeded):
|
||||
for i in range(1, relaysNeeded):
|
||||
for i in range(relaysNeeded):
|
||||
num, alias = main.network[net].add_relay()
|
||||
print(relaysNeeded, "for", net, ":", num, alias)
|
||||
provisionRelay(num, net)
|
||||
main.saveConf("network")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user