From 127b99c4febd59b4ba10d630e1b295682f041273 Mon Sep 17 00:00:00 2001 From: Ben Herrick-Blake Date: Sun, 22 Nov 2020 16:31:49 +0000 Subject: [PATCH] kk haha funny lolz --- Chatbot.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/Chatbot.py b/Chatbot.py index bf80438..1fce0fd 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -164,6 +164,35 @@ def registerSteamID(message, discordID): else: return("To link your steam requires a SteamID64 a guide for which can be found at: https://appuals.com/steam-64-id/") #SteamID END + +#ChangeSteamID START +def changeSteamID(message, discordID): #Changes a registered users steamID to whatever new id they input. + sharedRelationshipIndex = tempIDArrayDiscord.index(discordID) + formattedSteamID = message.lower() + formattedSteamID = formattedSteamID.replace(" ","") #Formats the recieved message into an acceptable form for the program to iterate through + for charNum in range(len(formattedSteamID)): + if charNum == 0: + count = 0 + adjacencyStartIndex = 0 + currentChar = formattedSteamID[charNum] + if currentChar.isdigit(): + count = count + 1 + else: + count = 0 + adjacencyStartIndex = charNum + 1 + if count == 17: + formattedSteamID = formattedSteamID[adjacencyStartIndex:charNum+1] + break + if len(formattedSteamID) == 17 and formattedSteamID.isdigit(): #and formattedSteamID.is_valid(): in the documentation but currently doesn't work + if (formattedSteamID not in tempIDArraySteam): + tempIDArraySteam[sharedRelationshipIndex] = formattedSteamID #This checks if the input steamID is valid and not already present in the database / two sorted lists that simulate a database + return("Thank You! \nI have now changed your SteamID! It is currently registered as " +formattedSteamID) + elif formattedSteamID in tempIDArraySteam: + return("This Steam ID is already taken sorry") + else: + return ("Sorry, I couldn't seem to find the new SteamID") +#ChangeSteamID END + #SpecificGameID START def fetchGameID(gameName): #This function fetches the appID of specific game on steam based on the name the user inputs gameName = gameName[gameName.find('(') +1 :gameName.find(')')]#Formats the recieved message so as to only search with text in between the brackets when looking for gameID @@ -341,10 +370,13 @@ async def on_message(message): #checks for a message # ================ up to about here ================ #BenHB Start================================================================== #These ifs are used to access a function when a user gives a valid input - if ' steamid ' in message.content.lower() or ' steam id ' in message.content.lower() or 'steamid' in message.content.lower() or 'steam id' in message.content.lower(): - messageInfo = registerSteamID(message.content, message.author.id) - await message.channel.send(messageInfo) - + if (' steamid ' in message.content.lower() or ' steam id ' in message.content.lower() or 'steamid' in message.content.lower() or 'steam id' in message.content.lower()) and message.author.id not in tempIDArrayDiscord: + output = registerSteamID(message.content, message.author.id) + await message.channel.send(output) + if (' steamid ' in message.content.lower() or ' steam id ' in message.content.lower() or 'steamid' in message.content.lower() or 'steam id' in message.content.lower()) and 'change' in message.content.lower() and 'my' in message.content.lower() and message.author.id in tempIDArrayDiscord: + output = changeSteamID(message.content, message.author.id) + await message.channel.send(output) + if 'displayid ' in message.content.lower(): displayedID = fetchGameID(message.content.replace('displayid ','')) await message.channel.send(displayedID)