aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Kelly <bk@ancilla.ca>2017-07-12 12:02:54 -0400
committerGitHub <noreply@github.com>2017-07-12 12:02:54 -0400
commitef2712973ad95ddc06cc1cca73e6154fb87f7348 (patch)
tree72ee33556a32f8240a7cb293cf88b6c0f5a80439
parent8343a4e7cf8f40fa7b556644503604e590cbc869 (diff)
parentc7d43f82bf577cbc7a6d8de0cb7d77365a06886d (diff)
downloadwee-slack-ef2712973ad95ddc06cc1cca73e6154fb87f7348.tar.gz
Merge pull request #391 from trygveaa/fix/nick-coloring
Fix nick coloring in weechat < 1.5
-rw-r--r--README.md10
-rw-r--r--wee_slack.py15
2 files changed, 11 insertions, 14 deletions
diff --git a/README.md b/README.md
index b162d14..4b670fa 100644
--- a/README.md
+++ b/README.md
@@ -225,16 +225,6 @@ Example:
Optional settings
-----------------
-Turn off colorized nicks:
-```
-/set plugins.var.python.slack.colorize_nicks 0
-```
-
-Turn on colorized messages (messages match nick color):
-```
-/set plugins.var.python.slack.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.server_aliases "my-slack-subdomain:mysub,other-domain:coolbeans"
diff --git a/wee_slack.py b/wee_slack.py
index 341cb5e..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):
@@ -3350,8 +3357,8 @@ if __name__ == "__main__":
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, "script_unloaded", ""):
- version = w.info_get("version_number", "") or 0
- if int(version) < 0x1030000:
+ weechat_version = w.info_get("version_number", "") or 0
+ if int(weechat_version) < 0x1030000:
w.prnt("", "\nERROR: Weechat version 1.3+ is required to use {}.\n\n".format(SCRIPT_NAME))
else: