diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2017-07-12 17:41:32 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2017-07-12 17:49:37 +0200 |
commit | 7f9c0d70bab290ddaa5af593fe7bf6bf8fbce155 (patch) | |
tree | 046fa3fac347dfa776a385c531615d5f65636f26 /wee_slack.py | |
parent | 9ac0622bfbec43ce683acf8fbb5d4963dc907989 (diff) | |
download | wee-slack-7f9c0d70bab290ddaa5af593fe7bf6bf8fbce155.tar.gz |
Get nick color name correctly in weechat < 1.5
In weechat 1.5, the info name 'irc_nick_color_name' was renamed to
'nick_color_name'. Since we want to support weechat < 1.5 and don't want
deprecation warnings in >= 1.5, we need to check the version and use the
appropriate name.
Fixes #364
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index ad68d75..09252c9 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -150,6 +150,13 @@ class WeechatWrapper(object): return decode_from_utf8(orig_attr) +##### Helpers + +def get_nick_color_name(nick): + info_name_prefix = "irc_" if int(weechat_version) < 0x1050000 else "" + return w.info_get(info_name_prefix + "nick_color_name", nick) + + ##### BEGIN NEW IGNORED_EVENTS = [ @@ -1537,7 +1544,7 @@ class SlackDMChannel(SlackChannel): def update_color(self): if config.colorize_private_chats: - self.color_name = w.info_get('irc_nick_color_name', self.name) + self.color_name = get_nick_color_name(self.name) self.color = w.color(self.color_name) else: self.color = "" @@ -1816,7 +1823,7 @@ class SlackUser(object): def update_color(self): # This will automatically be none/"" if the user has disabled nick # colourization. - self.color_name = w.info_get('nick_color_name', self.name) + self.color_name = get_nick_color_name(self.name) self.color = w.color(self.color_name) def formatted_name(self, prepend="", enable_color=True): |