From 975937287a995baedfc0d01af62206b9a19c068a Mon Sep 17 00:00:00 2001 From: Emily Lycett Date: Fri, 20 Nov 2020 17:32:59 +0000 Subject: [PATCH] Integrated proper steamID function instead of stub into ban and achieve function --- .vs/Chatbot/v16/.suo | Bin 35328 -> 36352 bytes .vs/slnx.sqlite | Bin 90112 -> 90112 bytes Chatbot.py | 79 +++++++++++++++++++++++-------------------- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/.vs/Chatbot/v16/.suo b/.vs/Chatbot/v16/.suo index 546d546f8e7119d12a911b43ef5ddb893b18312e..430187fd08e246631580dc0c7609000082fceb4e 100644 GIT binary patch delta 436 zcmZpe!qhN_X@Y?)0}Kc-FmM9dOhEka|Ns9WVaCZDIlMO}WH3%*%3%`-3uQ^#zqyF% z9V4UK zH#>4Pvu-{jY{Rrk;0W{PBfK_Dlf+yWyQna3b`fu2nS8|9W|NFF^JHh&y^B1U7AY`o z5_17csZL=Q6H%SDKxE;M(B|h_P6=<6CbMtgp8V^@=64#`xF#Qww%KGdm1i=)yXa(v zFrCT94vRNeI-UZWBfoc%8_1kRUM!20m^KBpG6_xxIs^iA4(tRn0ya+zn!v)Sw^==W zBO^|0B9@Dy8lTU@j>o9#eD=vM^*)oc+C(^;7+e^v7-ATlH~(*%&WKf*k#TZ>O~GV= NHonbuZB5K5902~gjeGzA delta 408 zcmZpe!_+W^X@Y?)69W_oFfgzInIQhZ|NsAkM42aV>}R4GWm$H%_bRV=E=^kdlxA&E%Ia9 zB<2E?Qk}vqmheVtGW!PZ$-iD`IfaZNrVZL`T_D$nGa5J$#^ zlTX`~PL>bT-CXH-3TTr2-bHRqixij^d9eVE+!WBtBxnhA3IymJ@CGs(H%|+iz{1G4 zSv`CsBTkDVmW!fWkk7-8$FS;r_Q@&j0h1?0No{JL#t36CYG$0A&?Yz8rQT=qqb8Bf Ib!|<|0L9>olmGw# diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 05d6e5692a9a11b5aa367542f22bbaac78aaa659..2893cdebc44dccda93ebcc4a74dfacde1de673a7 100644 GIT binary patch delta 523 zcmZoTz}j$tb%Hcw(nJ|&#-xo2e`OerHpj_UF$owM=o=Xr87LTs93Duyfpih)eOXF(?DYbMsS5 zb5c>|#JSlRWI=M7#mOj|CcpEOg;^o!FXja?N|J+(K@q52FFms)Gd(ZAC>3stFgqKA zI0FZpUS>*aBFt(bHZ}%P2B7-XyfT>Bo$FCE`qM4DvutL9UK2 zzOH(?DKMRajBE_TAS=p>VM3b%e#Nu(Rv8^={5|0ccSsYOnSd3mWR%zG7>otY*Fo|k4~-ZS~keI=oN z0?f)xX{ja28SaU>sh%#(yEi?!%CCKZjhT^&m3cpe+6STbf+&85c@W+n2(^3BhXMd? CBeACd delta 523 zcmZoTz}j$tb%Hb__e2?IM(&LXe`OdAHpj_UF$ox2>Khpt87LSUTNxTy8C!0CA%BLS zQEu~A{R47rJw45*%MVSi_EQLkFvWP;7^E3F*~*fO^(u06*g0-M#HD!H7?gqHx%nxj zIjN{};@oTuvLLz4;$##}li&Ht!mJSV7xRJ`CCS0Ypa@j1m!4UYnVy$llnS>+n4OJ5 zoPmQ)FEb@I5oWaz8ykZt15kZxUKvbma-qKn%;au=c^Gqpznl@o5^*Lr26>>SAXi5h zUst`{6qrsyMm7dvkQHUcFriHWzv9_?RwOaE?AWw{Ux0lRzck+mzN4EJ71r}HYqZHt zK5|n z>P!yFIhm<>C3>l4K$2NjkXe-}vpBRkwa6(kFE2HPSw?}`nQ3z1d1)qQsmW*VD+x&p zFe@{qrIsXTxF_bOdb%)6ZhCN)Ut5linURT=Sr$UcKqzSt#m_Jg!jpnfl8ZhR004?e Bsn!4h 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)) # ================================================