summaryrefslogtreecommitdiff
path: root/src/user.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-12-24 01:00:34 +0100
committermathieui <mathieui@mathieui.net>2014-12-24 01:00:34 +0100
commit183a151d9934992efd4623bed4bf0335c81b4b69 (patch)
tree36b25b01043ff90e09f11011e134842b0ac0c725 /src/user.py
parent668c1eb67741304278dfa05c68a7e1f33ae3181b (diff)
parent9da530f8541ed96fe5fa7e3ff01df5290f511633 (diff)
downloadpoezio-183a151d9934992efd4623bed4bf0335c81b4b69.tar.gz
poezio-183a151d9934992efd4623bed4bf0335c81b4b69.tar.bz2
poezio-183a151d9934992efd4623bed4bf0335c81b4b69.tar.xz
poezio-183a151d9934992efd4623bed4bf0335c81b4b69.zip
Merge branch 'master_rebased' of https://github.com/Perdu/poezio
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