aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2018-08-17 00:51:32 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2018-08-17 00:51:32 +0200
commit0eaf9ed4057f4adbfeb57289f7cc12774027a9aa (patch)
treef84646efc41823fea0420c00b3c04626c7547b98
parent66722bf4514bc53b12cfaa13a8c7a15d1b268cce (diff)
downloadwee-slack-0eaf9ed4057f4adbfeb57289f7cc12774027a9aa.tar.gz
Don't try to modify buffer line when message not found
If the timestamp given to change_message doesn't exist in the messages dict, just return. Previously an unknown ts would make modify_buffer_line crash unless text was set, because modify_buffer_line fails if text is None.
-rw-r--r--wee_slack.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/wee_slack.py b/wee_slack.py
index e62e215..e8c42e9 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1485,15 +1485,15 @@ class SlackChannel(object):
def change_message(self, ts, message_json=None, text=None):
ts = SlackTS(ts)
- if ts in self.messages:
- m = self.messages[ts]
- if message_json:
- m.message_json.update(message_json)
- if text:
- m.change_text(text)
- text = m.render(force=True)
- modify_buffer_line(self.channel_buffer, text, ts.major, ts.minor)
- return True
+ m = self.messages.get(ts)
+ if not m:
+ return
+ if message_json:
+ m.message_json.update(message_json)
+ if text:
+ m.change_text(text)
+ new_text = m.render(force=True)
+ modify_buffer_line(self.channel_buffer, new_text, ts.major, ts.minor)
def edit_nth_previous_message(self, n, old, new, flags):
message = self.my_last_message(n)