🗃️ UserID's instead of display names
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import json
|
||||
import string
|
||||
|
||||
from funcs import logThis
|
||||
from funcs import logThis, getName
|
||||
|
||||
def getName(user : str):
|
||||
logThis("Getting name for "+user+"'s character")
|
||||
def getCharName(user : str):
|
||||
logThis("Getting name for "+getName(user)+"'s character")
|
||||
with open("resources/starWars/swcharacters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
@ -12,8 +12,8 @@ def getName(user : str):
|
||||
logThis("Name is "+data[user]["Name"])
|
||||
return data[user]["Name"]
|
||||
else:
|
||||
logThis("Just using "+user)
|
||||
return user
|
||||
logThis("Just using "+getName(user))
|
||||
return getName(user)
|
||||
|
||||
def setUpDict(cmd : dict):
|
||||
logThis("Setting up a dictionary in a nice way")
|
||||
@ -251,7 +251,7 @@ def charData(user : str,cmd : str):
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
logThis("Looking for "+user+"'s character")
|
||||
logThis("Looking for "+getName(user)+"'s character")
|
||||
if user in data:
|
||||
logThis("Foundt it! Looking for "+key+" in the data")
|
||||
if key in data[user]:
|
||||
@ -498,27 +498,29 @@ def parseChar(user : str, cmd : str):
|
||||
if cmd == "":
|
||||
break
|
||||
|
||||
|
||||
if cmd == "":
|
||||
if user in data:
|
||||
text1, text2 = characterSheet(data[user])
|
||||
return text1, replaceWithSpaces(text2)
|
||||
else:
|
||||
logThis("Makin' a character for "+user)
|
||||
logThis("Makin' a character for "+getName(user))
|
||||
with open("resources/starWars/swtemplates.json", "r") as f:
|
||||
templates = json.load(f)
|
||||
newChar = templates["Character"]
|
||||
data[user] = newChar
|
||||
with open("resources/starWars/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " created"
|
||||
return "", "Character for " + getName(user) + " created"
|
||||
else:
|
||||
if cmd == "Purge":
|
||||
logThis("Deleting "+user+"'s character")
|
||||
logThis("Deleting "+getName(user)+"'s character")
|
||||
del data[user]
|
||||
with open("resources/starWars/swcharacters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " deleted"
|
||||
return "", replaceWithSpaces(str(charData(user,cmd)))
|
||||
return "", "Character for " + getName(user) + " deleted"
|
||||
else:
|
||||
return "", replaceWithSpaces(str(charData(user,cmd)))
|
||||
|
||||
def lightsaberChar(user : str):
|
||||
with open("resources/starWars/swcharacters.json", "r") as f:
|
||||
|
@ -367,7 +367,7 @@ def parseRoll(user : str,cmd : str = ""):
|
||||
|
||||
simplified = simplify(rollResults)
|
||||
|
||||
name = swchar.getName(user)
|
||||
name = swchar.getCharName(user)
|
||||
|
||||
logThis("Returns results and simplified results")
|
||||
|
||||
|
Reference in New Issue
Block a user