diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2018-08-19 21:27:56 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2018-08-20 00:41:56 +0200 |
commit | 51c2e769de9b76fc8ca6ed413cee77f878ffbcf7 (patch) | |
tree | 8bfa9ec6982099ae7d9198d9e3184c2264d3e4c3 /wee_slack.py | |
parent | 9fc1226dbf4e3052df8035d0a3a2db2cf44a170e (diff) | |
download | wee-slack-51c2e769de9b76fc8ca6ed413cee77f878ffbcf7.tar.gz |
Send actions as actual me_messages
Previously, we would just surround the message with underlines. While
this renders equally in the official client, it's not actually a
me_message, which shows if you try to edit the message.
me_messages are not currently supported in threads. If you try to send
one in the official client you will get an error, so print an error in
wee-slack as well.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/wee_slack.py b/wee_slack.py index cea9e0c..3078827 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1460,13 +1460,20 @@ class SlackChannel(object): except: dbg("Problem processing buffer_prnt") - def send_message(self, message, request_dict_ext={}): - # team = self.eventrouter.teams[self.team] + def send_message(self, message, subtype=None, request_dict_ext={}): message = linkify_text(message, self.team, self) dbg(message) - request = {"type": "message", "channel": self.identifier, "text": message, "_team": self.team.team_hash, "user": self.team.myidentifier} - request.update(request_dict_ext) - self.team.send_to_websocket(request) + if subtype == 'me_message': + s = SlackRequest(self.team.token, "chat.meMessage", + {"channel": self.identifier, "text": message}, + team_hash=self.team.team_hash, + channel_identifier=self.identifier) + self.eventrouter.receive(s) + else: + request = {"type": "message", "channel": self.identifier, + "text": message} + request.update(request_dict_ext) + self.team.send_to_websocket(request) def store_message(self, message, team, from_me=False): if not self.active: @@ -1949,11 +1956,15 @@ class SlackThreadChannel(object): # channel.unread_count = 1 self.buffer_prnt(message.sender, text, message.ts) - def send_message(self, message): - # team = self.eventrouter.teams[self.team] + def send_message(self, message, subtype=None): + if subtype == 'me_message': + w.prnt("", "ERROR: /me is not supported in threads") + return w.WEECHAT_RC_ERROR message = linkify_text(message, self.team, self) dbg(message) - request = {"type": "message", "channel": self.parent_message.channel.identifier, "text": message, "_team": self.team.team_hash, "user": self.team.myidentifier, "thread_ts": str(self.parent_message.ts)} + request = {"type": "message", "text": message, + "channel": self.parent_message.channel.identifier, + "thread_ts": str(self.parent_message.ts)} self.team.send_to_websocket(request) def open(self, update_remote=True): @@ -3231,8 +3242,9 @@ def whois_command_cb(data, current_buffer, command): @slack_buffer_or_ignore @utf8_decode def me_command_cb(data, current_buffer, args): - message = "_{}_".format(args.split(' ', 1)[1]) - buffer_input_callback("EVENTROUTER", current_buffer, message) + channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer) + message = args.split(' ', 1)[1] + channel.send_message(message, subtype='me_message') return w.WEECHAT_RC_OK_EAT |