Implement writing and loading the wholist from a file
This commit is contained in:
parent
bef1875186
commit
3eb4e2dcb2
43
threshold
43
threshold
|
@ -321,6 +321,7 @@ class Helper(object):
|
||||||
wholist[network] = {}
|
wholist[network] = {}
|
||||||
for i in newObjects.keys():
|
for i in newObjects.keys():
|
||||||
wholist[network][i] = newObjects[i]
|
wholist[network][i] = newObjects[i]
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def setWhoSingle(self, network, nick, ident, host):
|
def setWhoSingle(self, network, nick, ident, host):
|
||||||
|
@ -344,22 +345,13 @@ class Helper(object):
|
||||||
result[i].append(wholist[i][x])
|
result[i].append(wholist[i][x])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def saveConfig(self):
|
|
||||||
global config
|
|
||||||
with open("config.json", "w") as f:
|
|
||||||
dump(config, f, indent=4)
|
|
||||||
return
|
|
||||||
|
|
||||||
def getKeywordConfig(self):
|
def getKeywordConfig(self):
|
||||||
with open("keyword.json", "r") as f:
|
with open("keyword.json", "r") as f:
|
||||||
keyconf = load(f)
|
return load(f)
|
||||||
return keyconf
|
|
||||||
|
|
||||||
def saveKeywordConfig(self):
|
def getWholist(self):
|
||||||
global keyconf
|
with open("wholist.json", "r") as f:
|
||||||
with open("keyword.json", "w") as f:
|
return load(f)
|
||||||
dump(keyconf, f, indent=4)
|
|
||||||
return
|
|
||||||
|
|
||||||
def getPool(self):
|
def getPool(self):
|
||||||
with open("pool.json", "r") as f:
|
with open("pool.json", "r") as f:
|
||||||
|
@ -370,6 +362,24 @@ class Helper(object):
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def saveConfig(self):
|
||||||
|
global config
|
||||||
|
with open("config.json", "w") as f:
|
||||||
|
dump(config, f, indent=4)
|
||||||
|
return
|
||||||
|
|
||||||
|
def saveKeywordConfig(self):
|
||||||
|
global keyconf
|
||||||
|
with open("keyword.json", "w") as f:
|
||||||
|
dump(keyconf, f, indent=4)
|
||||||
|
return
|
||||||
|
|
||||||
|
def saveWholist(self):
|
||||||
|
global wholist
|
||||||
|
with open("wholist.json", "w") as f:
|
||||||
|
dump(wholist, f, indent=4)
|
||||||
|
return
|
||||||
|
|
||||||
def savePool(self):
|
def savePool(self):
|
||||||
global pool
|
global pool
|
||||||
with open("pool.json", "w") as f:
|
with open("pool.json", "w") as f:
|
||||||
|
@ -540,6 +550,11 @@ class Helper(object):
|
||||||
log("Keyword configuration rehashed")
|
log("Keyword configuration rehashed")
|
||||||
success("Keyword configuration rehashed successfully")
|
success("Keyword configuration rehashed successfully")
|
||||||
|
|
||||||
|
elif cmd == "savewho":
|
||||||
|
self.saveWholist()
|
||||||
|
success("Saved WHO info to file")
|
||||||
|
return
|
||||||
|
|
||||||
elif cmd == "dist":
|
elif cmd == "dist":
|
||||||
if config["DistEnabled"]:
|
if config["DistEnabled"]:
|
||||||
rtrn = run(["./dist.sh"], shell=True, stdout=PIPE)
|
rtrn = run(["./dist.sh"], shell=True, stdout=PIPE)
|
||||||
|
@ -1018,6 +1033,8 @@ if __name__ == "__main__":
|
||||||
pool = helper.getPool()
|
pool = helper.getPool()
|
||||||
help = helper.getHelp()
|
help = helper.getHelp()
|
||||||
|
|
||||||
|
wholist = helper.getWholist()
|
||||||
|
|
||||||
for i in pool.keys():
|
for i in pool.keys():
|
||||||
if pool[i]["enabled"] == True:
|
if pool[i]["enabled"] == True:
|
||||||
helper.addBot(i)
|
helper.addBot(i)
|
||||||
|
|
Loading…
Reference in New Issue