diff --git a/.vs/Chatbot/v16/.suo b/.vs/Chatbot/v16/.suo index 546d546..430187f 100644 Binary files a/.vs/Chatbot/v16/.suo and b/.vs/Chatbot/v16/.suo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 05d6e56..2893cde 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/Chatbot.py b/Chatbot.py index c5cbf1a..5fecf2b 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -72,7 +72,38 @@ def steamAchievementPercentages(steamID, gameID): #Emily reply = ["You really don't have a life do you? You have all of the achievements for this game. \nDo they fill the hole in your life?"] return random.choice(reply) +def isUserBanned(steamID):#Emily + linkCheck="http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" + steamApiKey + "&steamids="+ str(steamID) + api = requests.get("http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" + steamApiKey + "&steamids="+ str(steamID)) + print (linkCheck) + api = api.text + #api = ['"CommunityBanned":true', '"VACBanned":true', '"NumberOfVACBans":1', '"DaysSinceLastBan":1', '"NumberOfGameBans":5', '"EconomyBan":"none"}]}'] + #this section turns the string into a list + api = list(api.split(",")) + api = api[1:7] + print (api) + + if api == ['"CommunityBanned":false', '"VACBanned":false', '"NumberOfVACBans":0', '"DaysSinceLastBan":0', '"NumberOfGameBans":0', '"EconomyBan":"yes"}]}']: + reply = ["Looks like you've been good! No bans all round"] + else: + banList = [] + if '"CommunityBanned":false' not in api: + banList.append("Community banned") + if '"VACBanned":false' not in api: + banList.append("VACBanned") + if '"EconomyBan":"none"}]}' not in api: + banList.append("Economy Banned") + if '"NumberOfGameBans":0' not in api: + gameBans = api[4] + gameBans = ''.join(x for x in gameBans if x.isdigit()) #for this list I used https://www.tutorialspoint.com/How-to-remove-characters-except-digits-from-string-in-Python for help + banList.append("you've had " + gameBans + " games ban you") + daysSinceBan = api[3] + daysSinceBan = ''.join(x for x in daysSinceBan if x.isdigit()) + banList.append("and it's been " + daysSinceBan + " days since you were last banned") + reply = ["Looks like you've been a bad little gamer because you have been: \n" + ", ".join(banList), + "Getting quite the ban collection here because you're: \n" + ", ".join(banList)] + return random.choice(reply) #================Emily=Function=End============================================ #================BenHB=Function=Start========================================== @@ -110,38 +141,6 @@ def findSteamID(message, discordID): return("To link your steam requires a SteamID64 which can be found at:") #SteamID END - - -def isUserBanned(steamID):#Emily - api = requests.get("http://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?key=" + steamApiKey + "&steamids="+ str(steamID)) - api = api.text - #api = ['"CommunityBanned":true', '"VACBanned":true', '"NumberOfVACBans":1', '"DaysSinceLastBan":1', '"NumberOfGameBans":5', '"EconomyBan":"none"}]}'] - #this section turns the string into a list - api = list(api.split(",")) - api = api[1:7] - print (api) - - if api == ['"CommunityBanned":false', '"VACBanned":false', '"NumberOfVACBans":0', '"DaysSinceLastBan":0', '"NumberOfGameBans":0', '"EconomyBan":"yes"}]}']: - reply = ["Looks like you've been good! No bans all round"] - else: - banList = [] - if '"CommunityBanned":false' not in api: - banList.append("Community banned") - if '"VACBanned":false' not in api: - banList.append("VACBanned") - if '"EconomyBan":"none"}]}' not in api: - banList.append("Economy Banned") - if '"NumberOfGameBans":0' not in api: - gameBans = api[4] - gameBans = ''.join(x for x in gameBans if x.isdigit()) #for this list I used https://www.tutorialspoint.com/How-to-remove-characters-except-digits-from-string-in-Python for help - banList.append("you've had " + gameBans + " games ban you") - daysSinceBan = api[3] - daysSinceBan = ''.join(x for x in daysSinceBan if x.isdigit()) - banList.append("and it's been " + daysSinceBan + " days since you were last banned") - reply = ["Looks like you've been a bad little gamer because you have been: \n" + ", ".join(banList), - "Getting quite the ban collection here because you're: \n" + ", ".join(banList)] - - return random.choice(reply) #==================END OF DEFINITIONS=================== @@ -175,10 +174,18 @@ async def on_message(message): #checks for a message achievementWords = ["achievement", "steam" ] # This is to call the steamAchievementPercentages() function #if [entry for entry in achievementWords if(entry in message.content.lower())]: - if "steam" and [entry for entry in achievementWords if(entry in message.content.lower())]: - await message.channel.send(steamAchievementPercentages(findSteamID(), fetchGameID())) - if "steam" and "banned" in message.content.lower(): - await message.channel.send(isUserBanned(fetchSteamID())) + if "steam" in message.content.lower() and [entry for entry in achievementWords if(entry in message.content.lower())]: + await message.channel.send(steamAchievementPercentages(findSteamID(message.content.lower(), message.author.id), fetchGameID())) + + banWords = ["banned", "ban", "bans"] + if "steam" in message.content.lower() and [entry for entry in banWords if(entry in message.content.lower())]: + try: + await message.channel.send(isUserBanned(findSteamID(message.content.lower(), message.author.id))) + except: + randomSteamIDErrorReplies = ["Ben get your SteamId function under control I can't work under these conditions", + "Something went wrong *looks pointedly at Ben*", + "Why it looks like the SteamID function broke down, I wonder why, *Ben*"] + await message.channel.send(random.choice(randomSteamIDErrorReplies)) # ================================================