summaryrefslogtreecommitdiff
path: root/src/user.py
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-09-03 18:01:43 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2010-09-03 18:01:43 +0000
commit17eb99eea718191b619277754bf15e6a7554d916 (patch)
treeaa39d3583025b4a49f7492245981cd519c6855e9 /src/user.py
parent43654505fb2efa3994081e68613e5bd8dd033660 (diff)
downloadpoezio-17eb99eea718191b619277754bf15e6a7554d916.tar.gz
poezio-17eb99eea718191b619277754bf15e6a7554d916.tar.bz2
poezio-17eb99eea718191b619277754bf15e6a7554d916.tar.xz
poezio-17eb99eea718191b619277754bf15e6a7554d916.zip
python 3 only. Fixes all EncodingError bugs :))))
Diffstat (limited to 'src/user.py')
-rw-r--r--src/user.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/user.py b/src/user.py
index 646d8bd1..252764ae 100644
--- a/src/user.py
+++ b/src/user.py
@@ -1,5 +1,3 @@
-# -*- coding:utf-8 -*-
-#
# Copyright 2010 Le Coz Florent <louizatakk@fedoraproject.org>
#
# This file is part of Poezio.
@@ -22,6 +20,12 @@ from datetime import timedelta, datetime
import curses
import theme
+ROLE_DICT = {
+ 'none':0,
+ 'visitor':1,
+ 'participant':2,
+ 'moderator':3
+ }
class User(object):
"""
keep trace of an user in a Room
@@ -29,7 +33,7 @@ class User(object):
def __init__(self, nick, affiliation, show, status, role):
from common import debug
debug('NEW USER: nick:%s, affiliation:%s, show:%s, status:%s, role:%s\n' % (nick, affiliation, show, status, role))
- self.last_talked = None
+ self.last_talked = datetime(1, 1, 1) # The oldest possible time
self.update(affiliation, show, status, role)
self.change_nick(nick)
self.color = choice(theme.LIST_COLOR_NICKNAMES)
@@ -41,7 +45,7 @@ class User(object):
self.role = role
def change_nick(self, nick):
- self.nick = nick.encode('utf-8')
+ self.nick = nick
def set_last_talked(self, time):
"""
@@ -63,3 +67,26 @@ class User(object):
def __repr__(self):
return ">%s<" % (self.nick.decode('utf-8'))
+
+ def __eq__(self, b):
+ return self.role == b.role and self.nick.lower() == b.nick.lower()
+
+ def __gt__(self, b):
+ if ROLE_DICT[self.role] == ROLE_DICT[b.role]:
+ return self.nick.lower() > b.nick.lower()
+ return ROLE_DICT[self.role] < ROLE_DICT[b.role]
+
+ def __ge__(self, b):
+ if ROLE_DICT[self.role] == ROLE_DICT[b.role]:
+ return self.nick.lower() >= b.nick.lower()
+ return ROLE_DICT[self.role] <= ROLE_DICT[b.role]
+
+ def __lt__(self, b):
+ if ROLE_DICT[self.role] == ROLE_DICT[b.role]:
+ return self.nick.lower() < b.nick.lower()
+ return ROLE_DICT[self.role] > ROLE_DICT[b.role]
+
+ def __le__(self, b):
+ if ROLE_DICT[self.role] == ROLE_DICT[b.role]:
+ return self.nick.lower() <= b.nick.lower()
+ return ROLE_DICT[self.role] >= ROLE_DICT[b.role]