diff options
-rw-r--r-- | wee_slack.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py index d13d64c..9722bbd 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1337,7 +1337,11 @@ def process_message(message_json, cache=True): text = text.decode('utf-8') - text = unfurl_refs(text) + ignore_alt_text = False + if w.config_get_plugin('unfurl_ignore_alt_text') != "0": + ignore_alt_text = True + text = unfurl_refs(text, ignore_alt_text=ignore_alt_text) + if "attachments" in message_json: text += u" --- {}".format(unwrap_attachments(message_json)) text = text.lstrip() @@ -1404,7 +1408,7 @@ def unwrap_attachments(message_json): return attachment_text -def unfurl_refs(text): +def unfurl_refs(text, ignore_alt_text=False): """ Worst code ever written. this needs work """ @@ -1422,7 +1426,10 @@ def unfurl_refs(text): suffix = item[end+1:] item = item[start + 1:end] if item.find('|') > -1: - item = item.split('|')[0] + if ignore_alt_text: + item = item.split('|')[1] + else: + item = item.split('|')[0] if item.startswith('@U'): if users.find(item[1:]): try: @@ -1831,6 +1838,8 @@ if __name__ == "__main__": w.config_set_plugin('colorize_nicks', "1") if not w.config_get_plugin('trigger_value'): w.config_set_plugin('trigger_value', "0") + if not w.config_get_plugin('unfurl_ignore_alt_text'): + w.config_set_plugin('unfurl_ignore_alt_text', "0") version = w.info_get("version_number", "") or 0 if int(version) >= 0x00040400: |