Implement writing and loading the wholist from a file

This commit is contained in:
Mark Veidemanis 2017-12-25 22:27:09 +00:00
parent bef1875186
commit 3eb4e2dcb2
1 changed files with 30 additions and 13 deletions

View File

@ -321,6 +321,7 @@ class Helper(object):
wholist[network] = {}
for i in newObjects.keys():
wholist[network][i] = newObjects[i]
return
def setWhoSingle(self, network, nick, ident, host):
@ -344,22 +345,13 @@ class Helper(object):
result[i].append(wholist[i][x])
return result
def saveConfig(self):
global config
with open("config.json", "w") as f:
dump(config, f, indent=4)
return
def getKeywordConfig(self):
with open("keyword.json", "r") as f:
keyconf = load(f)
return keyconf
return load(f)
def saveKeywordConfig(self):
global keyconf
with open("keyword.json", "w") as f:
dump(keyconf, f, indent=4)
return
def getWholist(self):
with open("wholist.json", "r") as f:
return load(f)
def getPool(self):
with open("pool.json", "r") as f:
@ -370,6 +362,24 @@ class Helper(object):
else:
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):
global pool
with open("pool.json", "w") as f:
@ -540,6 +550,11 @@ class Helper(object):
log("Keyword configuration rehashed")
success("Keyword configuration rehashed successfully")
elif cmd == "savewho":
self.saveWholist()
success("Saved WHO info to file")
return
elif cmd == "dist":
if config["DistEnabled"]:
rtrn = run(["./dist.sh"], shell=True, stdout=PIPE)
@ -1018,6 +1033,8 @@ if __name__ == "__main__":
pool = helper.getPool()
help = helper.getHelp()
wholist = helper.getWholist()
for i in pool.keys():
if pool[i]["enabled"] == True:
helper.addBot(i)