Merge branch 'master' of github.com:NikolajDanger/Gwendolyn
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import json
|
||||
import string
|
||||
import logging
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
def getName(user : str):
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
@@ -81,7 +84,7 @@ def characterSheet(character : dict):
|
||||
return name, text1+"\n\n"+text2+divider+text3
|
||||
|
||||
def charData(user : str,cmd : str):
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
key = string.capwords(cmd.split(" ")[0])
|
||||
@@ -107,7 +110,7 @@ def charData(user : str,cmd : str):
|
||||
|
||||
if type(lookUpResult) is dict:
|
||||
data[user][key] = lookUpResult
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key
|
||||
else:
|
||||
@@ -133,7 +136,7 @@ def charData(user : str,cmd : str):
|
||||
return "Can't add that"
|
||||
else:
|
||||
data[user][key] = cmd
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
|
||||
else:
|
||||
@@ -142,7 +145,7 @@ def charData(user : str,cmd : str):
|
||||
return "You don't have a character. You can make one with !swchar"
|
||||
|
||||
def parseChar(user : str, cmd : str):
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if cmd == " ":
|
||||
@@ -157,25 +160,30 @@ def parseChar(user : str, cmd : str):
|
||||
if user in data:
|
||||
return characterSheet(data[user])
|
||||
else:
|
||||
with open("funcs/swfuncs/templates.json", "r") as f:
|
||||
with open("resources/swtemplates.json", "r") as f:
|
||||
templates = json.load(f)
|
||||
newChar = templates["Character"]
|
||||
data[user] = newChar
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " created"
|
||||
else:
|
||||
if cmd == "purge":
|
||||
del data[user]
|
||||
with open("resources/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " deleted"
|
||||
return "", charData(user,cmd)
|
||||
|
||||
def lightsaberChar(user : str):
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
return data[user]["Lightsaber Characteristic"]
|
||||
|
||||
def userHasChar(user : str):
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
with open("resources/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
return user in data
|
||||
|
||||
Reference in New Issue
Block a user