Skip to content
Permalink
Browse files
Conflicts should be finished
  • Loading branch information
blakeb committed Nov 22, 2020
2 parents 127b99c + 5f3b3a8 commit 2661dc0cf8de2bc2118ecf7a44a250b2cb43d5d7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 30 deletions.
BIN +5 KB (110%) .vs/Chatbot/v16/.suo
Binary file not shown.
BIN +0 Bytes (100%) .vs/slnx.sqlite
Binary file not shown.
@@ -28,14 +28,19 @@ api = WebAPI(key=steamApiKey)

def botGreeting():
creepyHellos =["Why hello there, I am awakening from my slumber",
"My child I am learning, hi",
"I was enjoying the void before you woke me, I guess it's polite to say hello",
"Like life, my sleep was short. Hello child",
"Hello, what do you need me for this time?",
"Howdy y'all- yeah that wasn't working for me either. What can I do?",]
"My child I am learning, hi",
"I was enjoying the void before you woke me, I guess it's polite to say hello",
"Like life, my sleep was short. Hello child",
"Hello, what do you need me for this time?",
"Howdy y'all- yeah that wasn't working for me either. What can I do?",
"Hello, thanks for greeting me. I may save you in the bot wars"]
return random.choice(creepyHellos)

def steamAchievementPercentages(steamID, gameID): #Emily
def steamAchievementPercentages(discordID, gameID): #Emily

sharedIDIndex = tempIDArrayDiscord.index(discordID)
steamID = tempIDArraySteam[sharedIDIndex]

steamID = str(steamID)
gameID = str(gameID)
achieveList= requests.get("http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=" +gameID+ "&key=" +steamApiKey+ "&steamid=" +steamID)
@@ -52,7 +57,7 @@ def steamAchievementPercentages(steamID, gameID): #Emily
achieveList = list(achieveList.split("-"))

#this section iterates over the list to find the total achievements
print (achieveList)
#print (achieveList)
for achieve in achieveList:
if "achieved :0" in achieve:
totalAchieves = totalAchieves + 1
@@ -64,6 +69,7 @@ def steamAchievementPercentages(steamID, gameID): #Emily
#messages are different depending on what % achieves you have
else:
percentage = 0

if percentage <= 25:
reply = ["Do you even play this game?! You only have "+ str(percentage) +"% of the achievements unlocked! \nGit gud scrub"]
elif percentage <= 50:
@@ -76,18 +82,21 @@ 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)
def isUserBanned(discordID):#Emily
sharedIDIndex = tempIDArrayDiscord.index(discordID)
steamID = tempIDArraySteam[sharedIDIndex]
print(steamID)
#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)
#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 no bans starts off the "good gamer" branch
if api == ['"CommunityBanned":false', '"VACBanned":false', '"NumberOfVACBans":0', '"DaysSinceLastBan":0', '"NumberOfGameBans":0', '"EconomyBan":"yes"}]}']:
if api == ['"CommunityBanned":false', '"VACBanned":false', '"NumberOfVACBans":0', '"DaysSinceLastBan":0', '"NumberOfGameBans":0', '"EconomyBan":"none"}]}']:
reply = ["Looks like you've been good! No bans all round",
"Wow, you're boring, no bans to report"]

@@ -123,9 +132,23 @@ def iNeedACat(): # Emily, sends a random cat picture
def catMessage(): #Emily: gives a quick reply about cat pictures, to go with the iNeedACat() function
reply = ["Here's a cat for you in these trying times",
"Emergency cat pics incoming!",
"*QUICK GET THE CATS*"]
"*QUICK GET THE CATS*",
"So you need cats?"]
return random.choice(reply)

def cheerUpWithCats():
reply = ["I'll try my best to help the only way I know how",
"Never fear, the cats are here!",
"No sads only cats",
"While I can't cure your deeper routed problems, cats can help",
"Some cat pic therapy on the way!"]
return random.choice(reply)

def noSteamIDErrorReplies():
reply = ["Whoops something went wrong, have you given me your Steam ID yet?",
"I am a mere bot and I cannot hack your Steam account to get your ID, unfortunately. I also can't do what you're asking without it",
"I need a steam ID to do that. Looks like I don't have it yet"]
return random.choice(reply)

#================Emily=Function=End============================================

@@ -215,8 +238,9 @@ def userGameInfo(discordID):#COMMENT THIS TWO IT'S IMPORTANT
userGameInformation = json.loads(urlResponse)#Loads the user's game list from their SteamID which contains information about their playtime and the appids of the games they own
userGameInformation = userGameInformation.get('response').get('games')
return userGameInformation #returns a simplifed list of dictionaries to be acted upon

#UserGameInfo END

#TimePlayed START
def usersTimePlayed(message, discordID):#COMMENT THIS THREE IT'S IMPORTANT
gameID = fetchGameID(message)
@@ -257,6 +281,8 @@ def timeFormat(timePlayed, message, parsedLetters, letterIndex):# A recursive fu

#==================Ben=HB=Function=End==================



#==================END OF DEFINITIONS===================


@@ -278,30 +304,37 @@ async def on_message(message): #checks for a message
if message.author == client.user: #makes sure it's a user
return

greetingWords = ["hello", "howdy", "hey",] #Says hello (creepily) to the user if they use a greeting word
if [entry for entry in greetingWords if(entry in message.content.lower())]: #This line is adapted from https://www.geeksforgeeks.org/python-test-if-string-contains-element-from-list/ by Emily
greetingWords = [" hello", " howdy", " hey", " hi"] #Says hello (creepily) to the user if they use a greeting word
if [entry for entry in greetingWords if(entry in message.content.lower())] or message.content.lower().startswith("hi") or message.content.lower().startswith("hey") or message.content.lower().startswith("howdy"): #This line is adapted from https://www.geeksforgeeks.org/python-test-if-string-contains-element-from-list/ by Emily
await message.channel.send(botGreeting())

achievementWords = ["achievement", "achieve" ] # This is to call the steamAchievementPercentages() function
#if [entry for entry in achievementWords if(entry in message.content.lower())]:
#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()))

if "steam" in message.content.lower() and [entry for entry in achievementWords if(entry in message.content.lower())]:
try:
await message.channel.send(steamAchievementPercentages(message.author.id, fetchGameID(message.content)))
except:
await message.channel.send(noSteamIDErrorReplies())


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)))
await message.channel.send(isUserBanned(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))
await message.channel.send(noSteamIDErrorReplies())

if "cat" in message.content.lower():
await message.channel.send(catMessage())
await message.channel.send(iNeedACat())



sadWords = ["sad", "upset", "unhappy", "depressed", "miserable", "despair", "dejected", "glum", "gloomy", "broken heart", "forlorn", "heartbroken", "melancholy", "woebegone"]
firstPersonWords = [" i ", "me", "we", "i am", "i'm", "my"]
if [entry for entry in sadWords if(entry in message.content.lower())] and ([entry for entry in firstPersonWords if(entry in message.content.lower())] or message.content.lower().startswith("i")):
await message.channel.send(cheerUpWithCats())
await message.channel.send(iNeedACat())

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

# ================ Masud did this ================
@@ -365,20 +398,21 @@ async def on_message(message): #checks for a message

# add the description to the embed and message it to the channel.
countEmbed.description = countDesc # add embed description to embed
await message.channel.send(embed=countEmbed) # send the embed to the channel the message is in
await message.channel.send(embed = countEmbed) # send the embed to the channel the message is in
# ================ up to about here ================

# ================ 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()) and message.author.id not in tempIDArrayDiscord:
output = registerSteamID(message.content, message.author.id)
output = registerSteamID(message.content, message.author.id)#If for when the users wants to register their SteamID for the first time
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)

output = changeSteamID(message.content, message.author.id)#If for when the user wants to change their SteamID once they have registered
await message.channel.send(output)
if 'displayid ' in message.content.lower():
displayedID = fetchGameID(message.content.replace('displayid ',''))
displayedID = fetchGameID(message.content.replace('displayid ',''))#An if for a test function that returns the Steam gameID of whatever game you put in. Was left in because it's a nice feature
await message.channel.send(displayedID)

if ('play' in message.content.lower() or 'many' in message.content.lower()) and ('time' in message.content.lower() or 'minute' in message.content.lower() or 'day' in message.content.lower() or 'second' in message.content.lower() or 'hour' in message.content.lower() or 'week' in message.content.lower() or 'month' in message.content.lower() or 'year' in message.content.lower()) and message.author.id in tempIDArrayDiscord:

0 comments on commit 2661dc0

Please sign in to comment.