diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-02-21 16:34:34 -0800 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-02-21 16:34:34 -0800 |
commit | 5532f7bc9b1ac7661fa246887f1936a94957f793 (patch) | |
tree | 0f520bba50dbb7cc78b184d074aa829814a27249 /wee_slack.py | |
parent | 759a702bfe3282e3811ba8f1116be20559e2e8e5 (diff) | |
download | wee-slack-5532f7bc9b1ac7661fa246887f1936a94957f793.tar.gz |
colorize nicks in lines like colorize_lines.pl
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index f61caf7..d6d437c 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -554,6 +554,13 @@ class Channel(SlackThing): else: name = user name = name.decode('utf-8') + #colorize nicks in each line + chat_color = w.config_string(w.config_get('weechat.color.chat')) + 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)), + message) message = message.decode('UTF-8', 'replace') message = HTMLParser.HTMLParser().unescape(message) data = u"{}\t{}".format(name, message).encode('utf-8') @@ -626,6 +633,7 @@ class User(SlackThing): self.presence = presence self.server = server self.update_color() + self.name_regex = re.compile(r"([\W]|\A)(@{0,1})" + self.name + "('s|[^'\w]|\Z)") if self.presence == 'away': self.nicklist_pointer = w.nicklist_add_nick(server.buffer, "", self.name, self.color_name, " ", "", 0) else: |