diff --git a/AccessLevelUpdater.py b/AccessLevelUpdater.py index 4d07c50..a791055 100644 --- a/AccessLevelUpdater.py +++ b/AccessLevelUpdater.py @@ -1,47 +1,91 @@ from pymongo import MongoClient -# pprint library is used to make the output look more pretty -from pprint import pprint -# connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string +client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") +db = client.admin + +result = db.users.find() + +total_accounts = len(list(result)) +#Roles Default = 0 QA = 3 Moderator = 4 -ModeratorHidden = 5 SeniorQA = 6 +Developer = 6 SeniorModerator = 7 -SeniorModeratorHidden = 9 Admin = 10 -client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") -db = client.admin +#Shirts +AdminShirt = 1037 +BetaHeroShirt = 1038 +GlobalModShirt = 1040 +ModShirt = 1041 +QAShirt = 1042 -result = db.users.find() +Cmids = [39] #Enter Cmids for Users to Update [1, 2, 13] + +CmidsAccessLevels = SeniorQA #Enter Access Level list above. +for Cmid in Cmids: + db.Users.update_one( + {"UserId": Cmid}, + { "$set": { + "Profile.AccessLevel": CmidsAccessLevels}} + ) + AddShirts = True + GetUser = db.Users.find_one({"UserId": Cmid}) + Name = GetUser["Profile"]["Name"] + match CmidsAccessLevels: + case 10: + UserRole = "Admin" + ShirtstoAdd = [AdminShirt] + case 7: + UserRole = "Senior Moderator" + ShirtstoAdd = [GlobalModShirt, ModShirt] + case 6: + UserRole = "Senior QA" + ShirtstoAdd = [QAShirt] + case 4: + UserRole = "Moderator" + ShirtstoAdd = [ModShirt] + case 3: + UserRole = "QA" + ShirtstoAdd = [QAShirt] + case _: + UserRole = "Default" + AddShirts = False + + + + if AddShirts == True: + print(f"User: {Cmid} with Name: {Name} has been given {UserRole} Access and will receive the following shirts!") + for ItemId in ShirtstoAdd: + db.Users.update_one( + {"UserId": Cmid}, + { "$addToSet": { "Inventory" : + { + "AmountRemaining": -1, + "Cmid": Cmid, + "ExpirationDate": None, + "ItemId": ItemId + } + }} + ) + match ItemId: + case 1037: + Shirt = "Admin Shirt" + case 1038: + Shirt = "Beta Hero Shirt" + case 1040: + Shirt = "Global Moderator Shirt" + case 1041: + Shirt = "Moderator Shirt" + case 1042: + Shirt = "QA Shirt" + print(Shirt) + else: + print(f"User: {Cmid} with Name: {Name} has been given {UserRole} Access!") + + -total_accounts = len(list(result)) -cmid = 2 #Enter Cmid for User - -cmidAccess = Moderator #Enter Access Level from Enum Above - -db.Users.update_one( - {"UserId": cmid}, { "$set": { "Profile.AccessLevel": cmidAccess}} -) - -if cmidAccess == 10: - Role = "Admin" -elif cmidAccess == 9: - Role = "Senior Moderator Hidden" -elif cmidAccess == 7: - Role = "Senior Moderator" -elif cmidAccess == 6: - Role = "Senior QA" -elif cmidAccess == 5: - Role = "Moderator Hidden" -elif cmidAccess == 4: - Role = "Moderator" -elif cmidAccess == 3: - Role = "QA" -else: - Role = "Default" - -print("Cmid:",cmid,"has been given",Role,"Access!") + diff --git a/AddSpecialShirts.py b/AddSpecialShirts.py new file mode 100644 index 0000000..81b90f1 --- /dev/null +++ b/AddSpecialShirts.py @@ -0,0 +1,58 @@ +from pymongo import MongoClient + +client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") + +db = client.admin +result = db.Test.find() +total_accounts=len(list(result)) + +AdminShirt = 1037 +BetaHeroShirt = 1038 +GlobalModShirt = 1040 +ModShirt = 1041 +QAShirt = 1042 +SLDShirt = 1044 +DEDShirt = 1045 +C4CShirt = 1046 +ST6IXShirt = 1047 +#Admins [1, 530], SeniorModerator [3, 38], SeniorQA [39], Moderator [2, 4], QA [5, 6, 7, 9, 30, 105] +Cmids = [1] +ItemstoAdd = [AdminShirt] + +CmidRange = len(list(Cmids)) + +for i in Cmids: + print("Cmid:",i) + for Item in ItemstoAdd: + ItemId = Item + + db.Users.update_one( + {"UserId": i}, + { "$addToSet": { "Inventory" : + { + "AmountRemaining": -1, + "Cmid": i, + "ExpirationDate": None, + "ItemId": Item + } + }} + ) + if Item == AdminShirt: + ItemName = "Admin Shirt" + elif Item == BetaHeroShirt: + ItemName = "Beta Hero Shirt" + elif Item == GlobalModShirt: + ItemName = "Global Moderator Shirt" + elif Item == ModShirt: + ItemName = "Moderator Shirt" + elif Item == QAShirt: + ItemName = "QA Shirt" + elif Item == SLDShirt: + ItemName = "SLD Clan Shirt" + elif Item == C4CShirt: + ItemName = "C4C Clan Shirt" + elif Item == DEDShirt: + ItemName = "DED Clan Shirt" + elif Item == ST6IXShirt: + ItemName = "ST6IX Clan Shirt" + print("Item:",ItemName,"was added!") \ No newline at end of file diff --git a/DatabaseBackup.py b/DatabaseBackup.py new file mode 100644 index 0000000..7bcd276 --- /dev/null +++ b/DatabaseBackup.py @@ -0,0 +1,22 @@ +import os +from datetime import date +# Date is used for the Folder Name +GetDate = date.today() +Today=str(GetDate) +# Converted to String. +FormattedDate = Today.replace('-', '') +# Removes the '-' from the date. + +FolderName = "Backup_"+FormattedDate +# Assigns the Folder Name to be created +CurrentDirectory = os.getcwd() +# Retrieves the Current Directory from System +os.makedirs(FolderName) +# Creates the Backup Folder with date as unique identifier +os.chdir(FolderName) +# Changes the Directory to the current folder. +try: + os.system('cmd /k "mongodump --host localhost:27017 --username uber --password admin --authenticationDatabase admin"') +except: + print('Could not execute command') +# Opens CMD and Runs the MongoDump Command. \ No newline at end of file diff --git a/NameChanger.py b/NameChanger.py new file mode 100644 index 0000000..edaa8e2 --- /dev/null +++ b/NameChanger.py @@ -0,0 +1,27 @@ +from profile import Profile +from pymongo import MongoClient + +client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") +db = client.admin + +Cmid = 525 + +NameChange = "I am Cheater" + +CurrentUser = db.Users.find_one({"UserId": Cmid}) +CurrentName = CurrentUser["Profile"]["Name"] +db.Users.update_one( + {"UserId": Cmid}, + { "$set": + { "Profile.Name": NameChange } + } +) +db.Users.update_one( + {"UserId": Cmid}, + { "$addToSet" : + { "Names": CurrentName } + }, + upsert=True +) + +print("User", {Cmid}, "successfully changed their name from", [CurrentName], "to", [NameChange]) \ No newline at end of file diff --git a/PointsUpdater.py b/PointsUpdater.py index 82f1e0b..3e6cdc5 100644 --- a/PointsUpdater.py +++ b/PointsUpdater.py @@ -1,68 +1,72 @@ from pymongo import MongoClient -import json -client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") +client = MongoClient("mongodb://uber:admin@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin") db = client.admin -collection = db["FixedUsers"] -collection2 = db["BrokenUsers"] -collection3 = db["Users"] -result = db.Users.find() +CollectionFixedUsers = db["FixedUsers"] +CollectionBrokenUsers = db["BrokenUsers"] +CollectionCurrentUsers = db["Users"] +result = db.Users.find() total_accounts=len(list(result)) -print("Total accounts Database", total_accounts) - -for i in range(506,total_accounts+1): #Only 864 Accounts in Old Database - if i >= 1 and i <= 843: - CurrentUser = collection.find_one({"UserId": i}) - CurrentUser2 = collection2.find_one({"UserId": i}) - CurrentUser3 = collection3.find_one({"UserId": i}) - CurrentUserName = CurrentUser["Profile"]["Name"] - CurrentUserKillsCount = CurrentUser["Kills"] - CurrentUserKillsCount2 =CurrentUser2["Kills"] - points_balance_current = CurrentUser3["Wallet"]["Points"] +AwardWinners = [2, 5, 13, 69, 71, 114, 118, 140, 224, 491, 555, 670, 815, 883] - print("{", i,"}", "Name: ", CurrentUserName) - # if CurrentUser and "Wallet" in CurrentUser: - # points_balance = CurrentUser["Wallet"]["Points"] - # print("Fixed Database Points: ", points_balance) - - # if CurrentUser2 and "Wallet" in CurrentUser2: - # points_balance_old = CurrentUser2["Wallet"]["Points"] - # print("Broken Database Points: ", points_balance_old) - - CurrentUserKillsDifference = CurrentUserKillsCount - CurrentUserKillsCount2 - - # print("There is ", CurrentUserKillsDifference, "More kills in the New Database") - - PointBalanceMultiplier = CurrentUserKillsDifference * 10 +#for i in range(1,total_accounts+1): +for i in AwardWinners: + print("Cmid:",i) + BrokenDB = CollectionBrokenUsers.find_one({"UserId": i,}) + FixedDB = CollectionFixedUsers.find_one({"UserId": i}) + FixedPointsCount = FixedDB["Wallet"]["Points"] + BrokenPointsCount = BrokenDB["Wallet"]["Points"] - print("User",CurrentUserName, "will receive",PointBalanceMultiplier,"extra points added to their balance.") - - #if points_balance_old >= points_balance: + AwardPoints = BrokenPointsCount + 50000 - # NewPointsBalance = points_balance_old + PointBalanceMultiplier - - # print("Point Balance: ", NewPointsBalance) - - #else: - - # NewPointsBalance = points_balance + PointBalanceMultiplier - NewPointsBalance = points_balance_current + PointBalanceMultiplier - print("Point Balance: ", NewPointsBalance) + # AwardBalanceUsed = AwardPoints - FixedPointsCount - elif i >= 864: - CurrentUser = collection3.find_one({"UserId": i}) - CurrentUserName = CurrentUser["Profile"]["Name"] - CurrentUserKillsCount = CurrentUser["Kills"] - if CurrentUser and "Wallet" in CurrentUser: - points_balance = CurrentUser["Wallet"]["Points"] - - NewPointsBalance = points_balance + CurrentUserKillsCount * 10 + # print("Cmid:",{i},"Used",AwardBalanceUsed,"Points.") + db.BrokenUsers.update_one( + {"UserId": i}, + { "$set": {"Wallet.Points": AwardPoints}} + ) - print("User",CurrentUserName, "Points Balance will be set to",NewPointsBalance) +for j in range(1,total_accounts+1): + print("Cmid:",j) + if j >= 1 and j <= 312 or j >= 314 and j <= 504 or j >= 506 and j <= 894: + BrokenDB = CollectionBrokenUsers.find_one({"UserId": j,}) + FixedDB = CollectionFixedUsers.find_one({"UserId": j}) + CurrentDB = CollectionCurrentUsers.find_one({"UserId": j}) + FixedPointsCount = FixedDB["Wallet"]["Points"] + BrokenPointsCount = BrokenDB["Wallet"]["Points"] + CurrentPointsCount = CurrentDB["Wallet"]["Points"] + FixedKillsCount = FixedDB["Kills"] + BrokenKillsCount = BrokenDB["Kills"] + CurrentKillsCount = CurrentDB["Kills"] - db.Users.update_one( - - {"UserId": i}, - { "$set": { "Wallet.Points": NewPointsBalance}} - ) \ No newline at end of file + AccountBalanceUsed = BrokenPointsCount - FixedPointsCount + print("Balance Used w/o Adding New Kills.",AccountBalanceUsed) + KillsforPointsAdded = FixedKillsCount - BrokenKillsCount + KillsAddedBalance = KillsforPointsAdded * 20 + BalancebeforeLive = KillsAddedBalance + CurrentPointsCount + print("Balance w/ New Kills",BalancebeforeLive) + LiveBalance = BalancebeforeLive + AccountBalanceUsed + print("Live Balance",LiveBalance) + db.Users.update_one( + { "UserId": j}, + { "$set": {"Wallet.Points": LiveBalance}} + ) + if j >= 894 and j <=1915: + FixedDB = CollectionFixedUsers.find_one({"UserId": j}) + CurrentDB = CollectionCurrentUsers.find_one({"UserId": j}) + CurrentPointsCount = CurrentDB["Wallet"]["Points"] + FixedPointsCount = FixedDB["Wallet"]["Points"] + CurrentKillsCount = CurrentDB["Kills"] + KillsAddedBalance = CurrentKillsCount * 20 + + AccountBalanceUsed = 10000 - FixedPointsCount + print("Balance Used:",AccountBalanceUsed) + LiveBalance = AccountBalanceUsed + CurrentPointsCount + KillsAddedBalance + db.Users.update_one( + { "UserId": j}, + { "$set": {"Wallet.Points": LiveBalance}} + ) + print("User:",j,"Live Balance:",LiveBalance) + \ No newline at end of file