468100b5 by Barry

Added alises to the bot.

1 parent 2639440f
...@@ -304,7 +304,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -304,7 +304,7 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
304 for game in games_sorted: 304 for game in games_sorted:
305 #print('%s' % game) 305 #print('%s' % game)
306 out_string += ' {} - {}\n'.format(game[1], game[0]) 306 out_string += ' {} - {}\n'.format(game[1], game[0])
307 307
308 client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string)) 308 client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string))
309 return 309 return
310 310
...@@ -319,8 +319,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -319,8 +319,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
319 client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention())) 319 client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
320 else: 320 else:
321 username = message.content[9:].replace('@', '').lower() 321 username = message.content[9:].replace('@', '').lower()
322 if username.strip() == '':
323 client.send_message(message.channel, '{} please provide a username. !aliases <username>'.format(message.author.mention()))
324 return
322 if username in data and 'aliases' in data[username]: 325 if username in data and 'aliases' in data[username]:
323 client.send_message(message.channel, '{} has the following aliases:'.format(username, ', '.join(data[username]['aliases']))) 326 client.send_message(message.channel, '{} has the following aliases: {}'.format(username, ', '.join(data[username]['aliases'])))
324 else: 327 else:
325 client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention())) 328 client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention()))
326 return 329 return
...@@ -341,6 +344,9 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a ...@@ -341,6 +344,9 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
341 if 'aliases' not in data[username]: 344 if 'aliases' not in data[username]:
342 data[username]['aliases'] = [] 345 data[username]['aliases'] = []
343 data[username]['aliases'].append(alias) 346 data[username]['aliases'].append(alias)
347 jdata = json.dumps(data, ensure_ascii=False)
348
349 open(member_status, 'wb+').write(jdata.encode('utf8'))
344 client.send_message(message.channel, '{} has been added to your aliases'.format(alias)) 350 client.send_message(message.channel, '{} has been added to your aliases'.format(alias))
345 else: 351 else:
346 client.send_message(message.channel, 'Something horrible happened and it is all your fault.') 352 client.send_message(message.channel, 'Something horrible happened and it is all your fault.')
......