diff options
author | Bryan Gilbert <gilbertw1@gmail.com> | 2016-03-12 18:12:43 -0500 |
---|---|---|
committer | Bryan Gilbert <gilbertw1@gmail.com> | 2016-03-12 18:21:27 -0500 |
commit | 362113186d0bb2859720c9b1ff80b7357aeba609 (patch) | |
tree | a348eeab21c8165341737b681a177f04c90171f4 /wee_slack.py | |
parent | b1770652b856407f76095e5a513631c340d5f072 (diff) | |
download | wee-slack-362113186d0bb2859720c9b1ff80b7357aeba609.tar.gz |
Added option to colorize messages the same color as the sending nick (defaults to off)
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index 4a1d000..e9751c2 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -649,11 +649,16 @@ class Channel(object): chat_color = w.config_string(w.config_get('weechat.color.chat')) if type(message) is not unicode: message = message.decode('UTF-8', 'replace') + curr_color = w.color(chat_color) + if colorize_nicks and colorize_messages and self.server.users.find(user): + curr_color = self.server.users.find(user).color + message = curr_color + message for user in self.server.users: if user.name in message: message = user.name_regex.sub( - r'\1\2{}\3'.format(user.formatted_name() + w.color(chat_color)), + r'\1\2{}\3'.format(user.formatted_name() + curr_color), message) + message = HTMLParser.HTMLParser().unescape(message) data = u"{}\t{}".format(name, message).encode('utf-8') w.prnt_date_tags(self.channel_buffer, time_int, tags, data) @@ -2108,7 +2113,7 @@ def create_slack_debug_buffer(): def config_changed_cb(data, option, value): global slack_api_token, distracting_channels, colorize_nicks, colorize_private_chats, slack_debug, debug_mode, \ - unfurl_ignore_alt_text + unfurl_ignore_alt_text, colorize_messages slack_api_token = w.config_get_plugin("slack_api_token") @@ -2117,6 +2122,7 @@ def config_changed_cb(data, option, value): distracting_channels = [x.strip() for x in w.config_get_plugin("distracting_channels").split(',')] colorize_nicks = w.config_get_plugin('colorize_nicks') == "1" + colorize_messages = w.config_get_plugin("colorize_messages") == "1" debug_mode = w.config_get_plugin("debug_mode").lower() if debug_mode != '' and debug_mode != 'false': create_slack_debug_buffer() @@ -2181,6 +2187,8 @@ if __name__ == "__main__": w.config_set_plugin('debug_mode', "") if not w.config_get_plugin('colorize_nicks'): w.config_set_plugin('colorize_nicks', "1") + if not w.config_get_plugin('colorize_messages'): + w.config_set_plugin('colorize_messages', "0") if not w.config_get_plugin('colorize_private_chats'): w.config_set_plugin('colorize_private_chats', "0") if not w.config_get_plugin('trigger_value'): |