diff options
author | Tollef Fog Heen <tfheen@err.no> | 2015-11-27 06:41:00 +0100 |
---|---|---|
committer | Tollef Fog Heen <tfheen@err.no> | 2015-11-27 06:41:00 +0100 |
commit | b4e6b1b9c03026731a77d8a6f6c23fdf1d8d6029 (patch) | |
tree | 5a1d9789db75917a33cec372008f3c376135271b | |
parent | 330537b8e591d801dcec342357462550b72e9a3f (diff) | |
download | wee-slack-b4e6b1b9c03026731a77d8a6f6c23fdf1d8d6029.tar.gz |
Check for bot_id earlier
Some bots have 'username' set for them, which could lead to an
inconsistent experience where some bots would have the robot smiley,
while others did not. Check for bot_id earlier and use the
formatted_name of the given bot.
Also add a space in front of the robot smiley to make it easier to
see.
-rw-r--r-- | wee_slack.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py index 8237341..194f8cf 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1680,12 +1680,12 @@ def unfurl_refs(text, ignore_alt_text=False): def get_user(message_json, server): - if 'user' in message_json: + if 'bot_id' in message_json: + name = u"{} :]".format(server.bots.find(message_json["bot_id"]).formatted_name()) + elif 'user' in message_json: name = server.users.find(message_json['user']).name elif 'username' in message_json: name = u"-{}-".format(message_json["username"]) - elif 'bot_id' in message_json: - name = u"{}:]".format(server.bots.find(message_json["bot_id"]).name) elif 'service_name' in message_json: name = u"-{}-".format(message_json["service_name"]) else: |