aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2015-11-27 06:39:46 +0100
committerTollef Fog Heen <tfheen@err.no>2015-11-27 06:39:46 +0100
commit330537b8e591d801dcec342357462550b72e9a3f (patch)
treed3f859a0d8968d0372c87be8b7ac43da227fe5fe /wee_slack.py
parent40ca86d615db7687f0295aae7228ea1f24ea5b6f (diff)
downloadwee-slack-330537b8e591d801dcec342357462550b72e9a3f.tar.gz
Add colouring to bots as well
This adds a .formatted_name for bots too, making it so they are coloured appropriately, just like humans.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 505bbcf..8237341 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -830,6 +830,7 @@ class Bot(object):
self.name = name
self.identifier = identifier
self.deleted = deleted
+ self.update_color()
def __eq__(self, compare_str):
if compare_str == self.identifier or compare_str == self.name:
@@ -843,6 +844,21 @@ class Bot(object):
def __repr__(self):
return "{}".format(self.identifier)
+ def update_color(self):
+ if colorize_nicks:
+ self.color_name = w.info_get('irc_nick_color_name', self.name.encode('utf-8'))
+ self.color = w.color(self.color_name)
+ else:
+ self.color_name = ""
+ self.color = ""
+
+ def formatted_name(self, prepend="", enable_color=True):
+ if colorize_nicks and enable_color:
+ print_color = self.color
+ else:
+ print_color = ""
+ return print_color + prepend + self.name
+
class Message(object):
def __init__(self, message_json):