diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-11-14 04:23:24 +0000 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-11-14 04:23:24 +0000 |
commit | 2efa8aad6360d89d35c8d637bd60dee9468cc74b (patch) | |
tree | 41cc2baf949bd7cbed5eeff0b14e261ee65a3f98 | |
parent | e469a93cb35ae95c80a98865fdb1a6c06e11f7ad (diff) | |
download | wee-slack-2efa8aad6360d89d35c8d637bd60dee9468cc74b.tar.gz |
add exception back in
-rw-r--r-- | wee_slack.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/wee_slack.py b/wee_slack.py index c0e7b6c..9418e15 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1425,6 +1425,9 @@ def render_message(message_json): text += u" --- {}".format(unwrap_attachments(message_json)) text = text.lstrip() text = text.replace("\t", " ") + + text = text.encode('utf-8') + if "reactions" in message_json: text += create_reaction_string(message_json["reactions"]) @@ -1436,9 +1439,9 @@ def render_message(message_json): def process_message(message_json, cache=True): - global unfurl_ignore_alt_text + global unfurl_ignore_alt_text -# try: + try: # send these messages elsewhere known_subtypes = ['channel_join', 'channel_leave', 'channel_topic'] if "subtype" in message_json and message_json["subtype"] in known_subtypes: @@ -1458,13 +1461,14 @@ def process_message(message_json, cache=True): text = render_message(message_json) + message_json['rendered_text'] = text + time = message_json['ts'] name = get_user(message_json, server) - - text = text.encode('utf-8') name = name.encode('utf-8') + if message_json.get("subtype", "") == "message_changed" and "edited" in message_json["message"]: channel.change_message(message_json["message"]["ts"], text + " (edited)") cache=False @@ -1483,10 +1487,10 @@ def process_message(message_json, cache=True): if cache: channel.cache_message(message_json) -# except Exception: -# 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())) + except Exception: + 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): if "message" in message_json: |