5963966f by Barry

Added whoplayed to list games played.

1 parent 9d7c0982
......@@ -196,6 +196,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
!msg <username> on 12/22/2015 Happy Birthday!
!games <username> - Returns a list of games played for a username.
!gameslist - Returns a list of the top 20 games and the number of people who have played that game.
!whoplayed <gamename> - Returns a list of players who have played the game.
!lastseen <username> - Returns info on when the user was last seen and their status.
!addfortune <fortune> - Adds a new fortune.
!fortune - Returns your fortune
......@@ -276,6 +277,35 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention()))
return
if message.content.startswith('!whoplayed'):
member_data = None
try:
json_data=open(member_status).read()
member_data = json.loads(json_data)
except ValueError:
pass
if not member_data:
client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
else:
game_name = message.content[11:]
json_data=open(games_file).read()
data = json.loads(json_data)
game_id = 0
for game in data:
if game['name'].lower() == game_name.lower():
game_id = game['id']
if game_id == 0:
client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(game_name, message.author.mention()))
matched_usernames = []
for username in member_data:
if 'games_played' in member_data[username]:
for id in member_data[username]['games_played']:
if id == game_id:
matched_usernames.append(username)
client.send_message(message.channel, 'I have seen {} playing: {}'.format(', '.join(matched_usernames), game_name))
return
# !msg joe in 5 minutes YOU ARE A DICK
if message.content.startswith('!msg'):
try:
......