diff --git a/.vs/Chatbot/v16/.suo b/.vs/Chatbot/v16/.suo index 646c360..cfbd3be 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 66b022c..4bcdaf2 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/Chatbot.py b/Chatbot.py index e7b64ec..15319a8 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -24,28 +24,30 @@ api = WebAPI(key=steamApiKey) steamID= "STEAM_0:0:73873614" #this is Emily's steamID which is useful to use as a stub when testing def steamAchievementPercentages(steamID, gameID): #Emily - as you can see it's going well achieveList= requests.get("http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=" +gameID+ "&key=" +steamApiKey+ "&steamid=" +steamID) - totalAchieves = 1 - achievesCompleted=0 - print (len(achieveList.text)) + totalAchieves = 0 + achievesCompleted = 0 achieveList = achieveList.text achieveList = achieveList.replace("\"", " ") - achieveList = achieveList.replace("{", "\"") - achieveList = achieveList.replace("}", "\"") - achieveList = achieveList.strip("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,:0123456789\" ") + achieveList = achieveList.replace("},{", "-") + achieveList = achieveList.strip("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,:0123456789\" {}") + achieveList = list(achieveList.split("-")) + print (achieveList) for achieve in achieveList: - print (achieve) - if "\"achieved\":0" in achieve: + if "achieved :0" in achieve: totalAchieves = totalAchieves + 1 - if "\"achieved\":1" in achieve: + if "achieved :1" in achieve: achievesCompleted = achievesCompleted + 1 totalAchieves = totalAchieves + 1 - percentage= round ((achievesCompleted/totalAchieves)*100, 2) - print(achievesCompleted) - print(totalAchieves) - return percentage - + if totalAchieves > 0: + percentage= round ((achievesCompleted/totalAchieves)*100, 2) + return percentage + else: + return 0 #print (steamAchievementPercentages("76561198108012956", "582010")) +#print (steamAchievementPercentages("76561198047733265", "582010")) + + #==================END OF DEFINITIONS===================