diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-08-14 10:59:43 -0400 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-08-14 10:59:43 -0400 |
commit | fc5a278eb14378aeefb00acf6441039afc0acf36 (patch) | |
tree | 5120b6f7741d5b1ea1971aef96b4ba0b651faa25 /wee_slack.py | |
parent | 0d9ca835952ab88ffd1b7aa355ef30d6fc6cffef (diff) | |
download | wee-slack-fc5a278eb14378aeefb00acf6441039afc0acf36.tar.gz |
bugfix: save string in as unicode when changing text
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index 877721f..4770ecc 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -780,6 +780,8 @@ class Message(object): self.ts_time, self.ts_counter = message_json['ts'].split('.') def change_text(self, new_text): + if not isinstance(new_text, unicode): + new_text = unicode(new_text, 'utf-8') self.message_json["text"] = new_text def add_reaction(self, reaction): @@ -1400,8 +1402,8 @@ def process_message(message_json, cache=True): channel.cache_message(message_json) except Exception: - if channel and ("text" in message_json) and message_json['text'] != None: - channel.buffer_prnt('unknown', message_json['text'].encode('utf-8')) + if channel and ("text" in message_json) and message_json['text'] is not None: + channel.buffer_prnt('unknown', message_json['text']) dbg("cannot process message {}\n{}".format(message_json, traceback.format_exc())) def unwrap_message(message_json): |