Skip to content
Permalink
Browse files
Integrated proper steamID function instead of stub into ban and achie…
…ve function
  • Loading branch information
lycette2 committed Nov 20, 2020
1 parent 8f4c1a7 commit 975937287a995baedfc0d01af62206b9a19c068a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
BIN +1 KB (100%) .vs/Chatbot/v16/.suo
Binary file not shown.
BIN +0 Bytes (100%) .vs/slnx.sqlite
Binary file not shown.
@@ -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))

# ================================================

0 comments on commit 9759372

Please sign in to comment.