Added whoplayed to list games played.
Showing
2 changed files
with
30 additions
and
0 deletions
... | @@ -196,6 +196,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a | ... | @@ -196,6 +196,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a |
196 | !msg <username> on 12/22/2015 Happy Birthday! | 196 | !msg <username> on 12/22/2015 Happy Birthday! |
197 | !games <username> - Returns a list of games played for a username. | 197 | !games <username> - Returns a list of games played for a username. |
198 | !gameslist - Returns a list of the top 20 games and the number of people who have played that game. | 198 | !gameslist - Returns a list of the top 20 games and the number of people who have played that game. |
199 | !whoplayed <gamename> - Returns a list of players who have played the game. | ||
199 | !lastseen <username> - Returns info on when the user was last seen and their status. | 200 | !lastseen <username> - Returns info on when the user was last seen and their status. |
200 | !addfortune <fortune> - Adds a new fortune. | 201 | !addfortune <fortune> - Adds a new fortune. |
201 | !fortune - Returns your fortune | 202 | !fortune - Returns your fortune |
... | @@ -276,6 +277,35 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a | ... | @@ -276,6 +277,35 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a |
276 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) | 277 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(username, message.author.mention())) |
277 | return | 278 | return |
278 | 279 | ||
280 | if message.content.startswith('!whoplayed'): | ||
281 | member_data = None | ||
282 | try: | ||
283 | json_data=open(member_status).read() | ||
284 | member_data = json.loads(json_data) | ||
285 | except ValueError: | ||
286 | pass | ||
287 | if not member_data: | ||
288 | client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention())) | ||
289 | else: | ||
290 | game_name = message.content[11:] | ||
291 | json_data=open(games_file).read() | ||
292 | data = json.loads(json_data) | ||
293 | game_id = 0 | ||
294 | for game in data: | ||
295 | if game['name'].lower() == game_name.lower(): | ||
296 | game_id = game['id'] | ||
297 | if game_id == 0: | ||
298 | client.send_message(message.channel, 'I don\'t have any data on {} yet {}'.format(game_name, message.author.mention())) | ||
299 | |||
300 | matched_usernames = [] | ||
301 | for username in member_data: | ||
302 | if 'games_played' in member_data[username]: | ||
303 | for id in member_data[username]['games_played']: | ||
304 | if id == game_id: | ||
305 | matched_usernames.append(username) | ||
306 | client.send_message(message.channel, 'I have seen {} playing: {}'.format(', '.join(matched_usernames), game_name)) | ||
307 | |||
308 | return | ||
279 | # !msg joe in 5 minutes YOU ARE A DICK | 309 | # !msg joe in 5 minutes YOU ARE A DICK |
280 | if message.content.startswith('!msg'): | 310 | if message.content.startswith('!msg'): |
281 | try: | 311 | try: | ... | ... |
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment