diff options
author | Ryan Huber <rhuber@gmail.com> | 2016-04-22 07:02:23 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2016-04-22 07:02:23 -0700 |
commit | fe16a7127f1c70ac11c8851c2e69ce0f23b2ed8e (patch) | |
tree | 527c29f691d1f72b916aef75b81e1a61996b9e01 | |
parent | fabd8894affd8b823924cf3366cf8088bb281b26 (diff) | |
parent | 362113186d0bb2859720c9b1ff80b7357aeba609 (diff) | |
download | wee-slack-fe16a7127f1c70ac11c8851c2e69ce0f23b2ed8e.tar.gz |
Merge pull request #183 from gilbertw1/colorized-messages
Added option to colorize messages the same color as the sending nick …
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | wee_slack.py | 12 |
2 files changed, 18 insertions, 5 deletions
@@ -44,7 +44,7 @@ In Development Dependencies ------------ - * WeeChat 1.3+ http://weechat.org/ + * WeeChat 1.3+ http://weechat.org/ * websocket-client https://pypi.python.org/pypi/websocket-client/ Setup @@ -101,7 +101,7 @@ If you don't want to store your API token in plaintext you can use the secure fe ``` ##### Optional: If you would like to connect to multiple groups, use the above command with multiple tokens separated by commas. (NO SPACES) - + ``` /set plugins.var.python.slack_extension.slack_api_token [token1],[token2],[token3] ``` @@ -170,6 +170,11 @@ Turn off colorized nicks: /set plugins.var.python.slack_extension.colorize_nicks 0 ``` +Turn on colorized messages (messages match nick color): +``` +/set plugins.var.python.slack_extension.colorize_nicks 1 +``` + Set channel prefix to something other than my-slack-subdomain.slack.com (e.g. when using buffers.pl): ``` /set plugins.var.python.slack_extension.server_alias.my-slack-subdomain "mysub" @@ -211,4 +216,4 @@ wee-slack is provided without any warranty whatsoever, but you are welcome to as - + diff --git a/wee_slack.py b/wee_slack.py index 4164f9d..69ea7a7 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -653,11 +653,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) @@ -2117,7 +2122,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") @@ -2126,6 +2131,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() @@ -2190,6 +2196,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'): |