aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2016-04-22 07:17:17 -0700
committerRyan Huber <rhuber@gmail.com>2016-04-22 07:17:17 -0700
commitc099148c62a1c32ecd2043d31b22538f2d6a972d (patch)
treee23b8218aaa83e4c0f1ac8c38b655a685839d4e0 /wee_slack.py
parent8f0c335f7aeaa1aa0d64a193d0858702faa49408 (diff)
parent30f18c58359dc113405833ee1025366af73cf3f3 (diff)
downloadwee-slack-c099148c62a1c32ecd2043d31b22538f2d6a972d.tar.gz
Merge pull request #205 from rawdigits/bot-for-rtm-api
Handle bots using the RTM API too
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index dfa2315..0f424e6 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -284,7 +284,7 @@ class SlackServer(object):
def create_slack_mappings(self, data):
for item in data["users"]:
- self.add_user(User(self, item["name"], item["id"], item["presence"], item["deleted"]))
+ self.add_user(User(self, item["name"], item["id"], item["presence"], item["deleted"], is_bot=item.get('is_bot', False)))
for item in data["bots"]:
self.add_bot(Bot(self, item["name"], item["id"], item["deleted"]))
@@ -804,7 +804,7 @@ class DmChannel(Channel):
class User(object):
- def __init__(self, server, name, identifier, presence="away", deleted=False):
+ def __init__(self, server, name, identifier, presence="away", deleted=False, is_bot=False):
self.server = server
self.name = name
self.identifier = identifier
@@ -814,6 +814,7 @@ class User(object):
self.channel_buffer = w.info_get("irc_buffer", "{}.{}".format(domain, self.name))
self.update_color()
self.name_regex = re.compile(r"([\W]|\A)(@{0,1})" + self.name + "('s|[^'\w]|\Z)")
+ self.is_bot = is_bot
if deleted:
return
@@ -1795,7 +1796,11 @@ def get_user(message_json, server):
if 'bot_id' in message_json and message_json['bot_id'] is not None:
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
+ u = server.users.find(message_json['user'])
+ if u.is_bot:
+ name = u"{} :]".format(u.formatted_name())
+ else:
+ name = u.name
elif 'username' in message_json:
name = u"-{}-".format(message_json["username"])
elif 'service_name' in message_json: