diff options
author | oda <oda@headjapan.com> | 2016-01-13 18:07:01 +0900 |
---|---|---|
committer | oda <oda@headjapan.com> | 2016-01-13 18:07:01 +0900 |
commit | 28f68ea88082d0380c949f265e84671059fcf8a9 (patch) | |
tree | c67f0babd14e4fb8ec300055a4094a385d5a5b1c /wee_slack.py | |
parent | 24b5d143282f9d210b4aea8c9b18f3a65029dea1 (diff) | |
download | wee-slack-28f68ea88082d0380c949f265e84671059fcf8a9.tar.gz |
Change to add ' (edited)' only when rendering
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/wee_slack.py b/wee_slack.py index c8d24ee..3132b33 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -655,7 +655,7 @@ class Channel(object): def has_message(self, ts): return self.messages.count(ts) > 0 - def change_message(self, ts, text=None): + def change_message(self, ts, text=None, suffix=''): if self.has_message(ts): message_index = self.messages.index(ts) @@ -667,7 +667,7 @@ class Channel(object): #we do this because time resolution in weechat is less than slack int_time = int(float(ts)) if self.messages.count(str(int_time)) == 1: - modify_buffer_line(self.channel_buffer, text, int_time) + modify_buffer_line(self.channel_buffer, text + suffix, int_time) #otherwise redraw the whole buffer, which is expensive else: self.buffer_redraw() @@ -1578,7 +1578,10 @@ def process_message(message_json, cache=True): channel.buffer_prnt(w.prefix("action").rstrip(), text, time) else: - channel.buffer_prnt(name, text, time) + suffix = '' + if 'edited' in message_json: + suffix = ' (edited)' + channel.buffer_prnt(name, text + suffix, time) if cache: @@ -1612,8 +1615,9 @@ def process_message_changed(message_json): m["text"] += unwrap_attachments(message_json, text_before) channel = channels.find(message_json["channel"]) if "edited" in m: - m["text"] += " (edited)" - channel.change_message(m["ts"], m["text"]) + channel.change_message(m["ts"], m["text"], ' (edited)') + else: + channel.change_message(m["ts"], m["text"]) def process_message_deleted(message_json): |