This commit is contained in:
NikolajDanger
2020-08-13 16:48:27 +02:00
parent 52dd554816
commit fcff2a0823
3 changed files with 0 additions and 66 deletions

9
.gitignore vendored
View File

@ -152,15 +152,7 @@ static
token.txt
credentials.txt
options.txt
resources/starWars/swcharacters.json
resources/games/games.json
resources/games/hexGames.json
resources/games/monopolyGames.json
resources/games/investments.json
resources/games/hangmanGames.json
resources/games/blackjackCards/
resources/games/hilo/
resources/starWars/destinyPoints.txt
resources/games/blackjackTables/
resources/games/oldImages/
resources/games/4InARowBoards/
@ -171,5 +163,4 @@ resources/lookup/monsters.json
resources/lookup/spells.json
resources/movies.txt
resources/names.txt
resources/users.json
gwendolynTest.py

View File

@ -1,4 +1,3 @@
import json
import pymongo
from funcs import logThis

View File

@ -205,59 +205,3 @@ def emojiToCommand(emoji):
elif emoji == "🎲":
return "roll"
else: return ""
def addToDict(userID,userName):
with open("resources/users.json", "r") as f:
data = json.load(f)
if userID in data:
if data[userID]["user name"] != userName:
logThis("changing name for "+userName)
data[userID]["user name"] = userName
with open("resources/users.json", "w") as f:
json.dump(data,f,indent=4)
else:
logThis("creating "+userName+" in the system")
with open("resources/games/games.json","r") as f:
games = json.load(f)
if userName.lower() in games["users"]:
money = games["users"][userName.lower()]
del games["users"][userName.lower()]
with open("resources/games/games.json", "w") as f:
json.dump(games,f,indent=4)
else:
money = 0
data[userID] = {"user name" : userName, "money" : money}
with open("resources/users.json", "w") as f:
json.dump(data,f,indent=4)
def transferUsers(database):
collist = database.list_collection_names()
if "users" not in collist and os.path.exists("resources/users.json"):
logThis("Transfering users")
with open("resources/users.json", "r") as f:
data = json.load(f)
userList = []
for key, value in list(data.items()):
user = {"_id":key,"user name":value["user name"],"money":value["money"]}
userList.append(user)
database["users"].insert_many(userList)
if "investments" not in collist and os.path.exists("resources/games/investments.json"):
logThis("Transfering investments")
with open("resources/games/investments.json", "r") as f:
data = json.load(f)
userList = []
for key, value in list(data.items()):
user = {"_id":key,"investments":value}
userList.append(user)
database["investments"].insert_many(userList)