From e44b4678f65bb0d0c50abc6d84624c4394436c85 Mon Sep 17 00:00:00 2001 From: ZKWolf Date: Mon, 19 Jun 2023 23:08:31 +0200 Subject: [PATCH] Added new handler (This will be the only handler in the future) --- src/logic/mongodb_handler.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/logic/mongodb_handler.py b/src/logic/mongodb_handler.py index 188fd65..4acaf04 100644 --- a/src/logic/mongodb_handler.py +++ b/src/logic/mongodb_handler.py @@ -38,7 +38,9 @@ class Mongo: 'currency_blood_cells': 0, 'currency_iron': 0, 'currency_ink_cells': 0, - 'unlocked_items': [] + 'unlocked_items': [], + 'is_banned': False, + 'special_unlocks': [] } self.dyn_collection.insert_one(new_document) @@ -109,5 +111,25 @@ class Mongo: print(e) return {"status": "error", "message": "Error in mongodb_handler"} + def get_data_with_list(self, login, items, server, db, collection): + try: + document = {} + self.dyn_server = server + self.dyn_db = db + self.dyn_collection = collection + client = pymongo.MongoClient(self.dyn_server) + self.dyn_db = client[self.dyn_db] + self.dyn_collection = self.dyn_db[self.dyn_collection] + existing_document = self.dyn_collection.find_one({"userid": login}) + if existing_document: + for item in items: + document[item] = existing_document.get(item) + else: + print(f"No user found with userId: {login}") + return None + except Exception as e: + print(e) + return None + mongo = Mongo()