diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-07 23:57:15 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-16 23:03:01 +0200 |
commit | e6446b84db52d9c5b6adf6c8869ab3d12e6f2ce4 (patch) | |
tree | f44f371c7c7fb5def5b6cf0cb528e8aa73c10e9f /wee_slack.py | |
parent | 7a4a95baafc78682288acaa1b4622d87eed1db3e (diff) | |
download | wee-slack-e6446b84db52d9c5b6adf6c8869ab3d12e6f2ce4.tar.gz |
Support colorizing attachment prefix or line
Thanks to @Informatic for the initial implementation of this in PR #426.
I have seen that most attachment colors are without the leading #, but a
few does include it, so we have to handle it.
Fixes #424, closes #426
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py index 8c9d358..1dc2bc9 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3812,7 +3812,18 @@ def unwrap_attachments(message_json, text_before): t.append(fallback) if t: lines = [line for part in t for line in part.strip().split("\n") if part] - attachment_texts.extend("| {}".format(line) for line in lines) + prefix = '|' + line_color = None + color = attachment.get('color') + if color and config.colorize_attachments != "none": + weechat_color = w.info_get("color_rgb2term", str(int(color.lstrip("#"), 16))) + if config.colorize_attachments == "prefix": + prefix = colorize_string(weechat_color, prefix) + elif config.colorize_attachments == "all": + line_color = weechat_color + attachment_texts.extend( + colorize_string(line_color, "{} {}".format(prefix, line)) + for line in lines) return "\n".join(attachment_texts) @@ -5230,6 +5241,10 @@ class PluginConfig(object): 'color_typing_notice': Setting( default='yellow', desc='Color to use for the typing notice.'), + 'colorize_attachments': Setting( + default='prefix', + desc='Whether to colorize attachment lines. Values: "prefix": Only colorize' + ' the prefix, "all": Colorize the whole line, "none": Don\'t colorize.'), 'colorize_private_chats': Setting( default='false', desc='Whether to use nick-colors in DM windows.'), @@ -5435,6 +5450,7 @@ class PluginConfig(object): get_color_reaction_suffix_added_by_you = get_string get_color_thread_suffix = get_string get_color_typing_notice = get_string + get_colorize_attachments = get_string get_debug_level = get_int get_external_user_suffix = get_string get_files_download_location = get_string |