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
for game in games_sorted:
#print('%s' % game)
out_string += ' {} - {}\n'.format(game[1], game[0])
client.send_message(message.channel, 'The games I have seen people playing are: \n{}'.format(out_string))
return
......@@ -319,8 +319,11 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
client.send_message(message.channel, 'I am a bit confused right now.. maybe I need more data. {}!'.format(message.author.mention()))
else:
username = message.content[9:].replace('@', '').lower()
if username.strip() == '':
client.send_message(message.channel, '{} please provide a username. !aliases <username>'.format(message.author.mention()))
return
if username in data and 'aliases' in data[username]:
client.send_message(message.channel, '{} has the following aliases:'.format(username, ', '.join(data[username]['aliases'])))
client.send_message(message.channel, '{} has the following aliases: {}'.format(username, ', '.join(data[username]['aliases'])))
else:
client.send_message(message.channel, 'No known alises for {} yet {}'.format(username, message.author.mention()))
return
......@@ -341,6 +344,9 @@ You can ask compound or questions and I will choose. Example: HellsBot Rui is a
if 'aliases' not in data[username]:
data[username]['aliases'] = []
data[username]['aliases'].append(alias)
jdata = json.dumps(data, ensure_ascii=False)
open(member_status, 'wb+').write(jdata.encode('utf8'))
client.send_message(message.channel, '{} has been added to your aliases'.format(alias))
else:
client.send_message(message.channel, 'Something horrible happened and it is all your fault.')
......