Added database thing
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
"""A collection of all Gwendolyn functions."""
|
||||
|
||||
__all__ = ["helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFiles", "emojiToCommand", "fiarReactionTest", "deleteGame", "stopServer", "checkBalance", "giveMoney", "addMoney", "triviaCountPoints", "triviaStart", "triviaAnswer", "spellFunc", "monsterFunc", "nameGen", "tavernGen", "movieFunc", "roll_dice", "parseChar", "parseRoll", "critRoll", "parseDestiny", "addToDict", "getName", "getID", "replaceMultiple", "monopolyReactionTest","parseInvest", "fiar", "runMonopoly", "runHex", "runHangman","hangmanReactionTest", "parseBlackjack"]
|
||||
__all__ = ["helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFiles", "emojiToCommand", "fiarReactionTest", "deleteGame", "stopServer", "checkBalance", "giveMoney", "addMoney", "triviaCountPoints", "triviaStart", "triviaAnswer", "spellFunc", "monsterFunc", "nameGen", "tavernGen", "movieFunc", "roll_dice", "parseChar", "parseRoll", "critRoll", "parseDestiny", "addToDict", "getName", "getID", "replaceMultiple", "monopolyReactionTest","parseInvest", "fiar", "runMonopoly", "runHex", "runHangman","hangmanReactionTest", "parseBlackjack","transferUsers"]
|
||||
|
||||
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand, fiarReactionTest, deleteGame, stopServer, addToDict, getName, getID, monopolyReactionTest, hangmanReactionTest
|
||||
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand, fiarReactionTest, deleteGame, stopServer, addToDict, getName, getID, monopolyReactionTest, hangmanReactionTest, transferUsers
|
||||
|
||||
from .games import checkBalance, giveMoney, addMoney, triviaCountPoints, triviaStart, triviaAnswer, fiar, runMonopoly, runHex, runHangman, parseBlackjack, parseInvest
|
||||
|
||||
|
@ -8,6 +8,7 @@ import logging # Used for... you know... logging
|
||||
import wikia # Used by findWikiPage
|
||||
import os # Used by makeFiles
|
||||
import git # Used by stopServer()
|
||||
import pymongo # Used by transferUsers
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
@ -342,3 +343,18 @@ def getID(userName):
|
||||
return userID
|
||||
except:
|
||||
logThis("Error getting ID")
|
||||
|
||||
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":int(key[1:]),"user name":value["user name"],"money":value["money"]}
|
||||
userList.append(user)
|
||||
|
||||
database["users"].insert_many(userList)
|
||||
|
Reference in New Issue
Block a user