From c0419e6a95552fcb8e0e4c5f42360f6cd0de706e Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 19 Aug 2018 21:30:12 +0200 Subject: Don't render messages surrounded by _ as actions Even though me_messages and messages surrounded by underlines render equally in the official client, it is two different types of messages. Converting messages surrounded by underlines to me_messages causes problems when editing, because the underlines will be removed from the message so it won't be shown as an action anymore. The official clients sends me_messages as that subtype, and after the previous commit, wee-slack also does this, so there is no reason for this conversion anymore. Since subtype isn't changed in SlackMessage anymore, we can use the subtype variable we have, and the comment is not needed anymore. --- wee_slack.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index 3078827..14b7964 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2108,10 +2108,6 @@ class SlackMessage(object): senders = self.get_sender() self.sender, self.sender_plain = senders[0], senders[1] self.ts = SlackTS(message_json['ts']) - text = self.message_json.get('text') - if text and text.startswith('_') and text.endswith('_') and 'subtype' not in message_json: - message_json['text'] = text[1:-1] - message_json['subtype'] = 'me_message' def __hash__(self): return hash(self.ts) @@ -2518,10 +2514,7 @@ def process_message(message_json, eventrouter, store=True, **kwargs): dbg("Rendered message: %s" % text) dbg("Sender: %s (%s)" % (message.sender, message.sender_plain)) - # Handle actions (/me). - # We don't use `subtype` here because creating the SlackMessage may - # have changed the subtype based on the detected message contents. - if message.message_json.get('subtype') == 'me_message': + if subtype == 'me_message': try: channel.unread_count_display += 1 except: -- cgit