summaryrefslogtreecommitdiff
path: root/src/user.py
diff options
context:
space:
mode:
authorCélestin Matte <celestin.matte@gmail.com>2014-12-23 16:01:58 +0100
committerCélestin Matte <celestin.matte@gmail.com>2014-12-24 00:28:22 +0100
commit251a10ab0d78ef9f4f68fc59ab41e064466d9145 (patch)
tree857a5b9b56fccc9f5d543172f1875a342526f4a7 /src/user.py
parentf7e7836f977555bd589b693947b8e4d06c1134b1 (diff)
downloadpoezio-251a10ab0d78ef9f4f68fc59ab41e064466d9145.tar.gz
poezio-251a10ab0d78ef9f4f68fc59ab41e064466d9145.tar.bz2
poezio-251a10ab0d78ef9f4f68fc59ab41e064466d9145.tar.xz
poezio-251a10ab0d78ef9f4f68fc59ab41e064466d9145.zip
Add a muc_color section in the config file to permanently fix a color to a nick
Diffstat (limited to 'src/user.py')
-rw-r--r--src/user.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/user.py b/src/user.py
index 8b4ad94b..b1796bc3 100644
--- a/src/user.py
+++ b/src/user.py
@@ -13,9 +13,13 @@ An user is a MUC participant, not a roster contact (see contact.py)
from random import choice
from datetime import timedelta, datetime
from hashlib import md5
+import xhtml
from theming import get_theme
+import logging
+log = logging.getLogger(__name__)
+
ROLE_DICT = {
'':0,
'none':0,
@@ -28,14 +32,17 @@ class User(object):
"""
keep trace of an user in a Room
"""
- def __init__(self, nick, affiliation, show, status, role, jid, deterministic=True):
+ def __init__(self, nick, affiliation, show, status, role, jid, deterministic=True, color=''):
self.last_talked = datetime(1, 1, 1) # The oldest possible time
self.update(affiliation, show, status, role)
self.change_nick(nick)
- if deterministic:
- self.set_deterministic_color()
+ if color != '':
+ self.change_color(color, deterministic)
else:
- self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
+ if deterministic:
+ self.set_deterministic_color()
+ else:
+ self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
self.jid = jid
self.chatstate = None
@@ -56,6 +63,17 @@ class User(object):
def change_nick(self, nick):
self.nick = nick
+ def change_color(self, color_name, deterministic=False):
+ color = xhtml.colors.get(color_name)
+ if color == None:
+ log.error('Unknown color "%s"' % color_name)
+ if deterministic:
+ self.set_deterministic_color()
+ else:
+ self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
+ else:
+ self.color = (color, -1)
+
def set_last_talked(self, time):
"""
time: datetime object