summaryrefslogtreecommitdiff
path: root/src/tabs
diff options
context:
space:
mode:
authorNicolas Braud-Santoni <nicolas@braud-santoni.eu>2015-12-29 14:50:21 +0100
committermathieui <mathieui@mathieui.net>2015-12-29 20:04:07 +0100
commita931886c3bd257bf31a03852f4f5cf73f893433f (patch)
treeddab4e87fa699b3a2ea4bea84da72c992c2b4977 /src/tabs
parenta351473ebfe7ee397aa9f27990fa0144329aa9e5 (diff)
downloadpoezio-a931886c3bd257bf31a03852f4f5cf73f893433f.tar.gz
poezio-a931886c3bd257bf31a03852f4f5cf73f893433f.tar.bz2
poezio-a931886c3bd257bf31a03852f4f5cf73f893433f.tar.xz
poezio-a931886c3bd257bf31a03852f4f5cf73f893433f.zip
muctab: Cleanup the /names implementation
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/muctab.py47
1 files changed, 13 insertions, 34 deletions
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index 21e4e550..7939792d 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -31,7 +31,7 @@ from decorators import refresh_wrapper, command_args_parser
from logger import logger
from roster import roster
from theming import get_theme, dump_tuple
-from user import User
+from user import User, ROLE_DICT
SHOW_NAME = {
@@ -669,11 +669,7 @@ class MucTab(ChatTab):
"""
if not self.joined:
return
- color_visitor = dump_tuple(get_theme().COLOR_USER_VISITOR)
- color_other = dump_tuple(get_theme().COLOR_USER_NONE)
- color_moderator = dump_tuple(get_theme().COLOR_USER_MODERATOR)
- color_participant = dump_tuple(get_theme().COLOR_USER_PARTICIPANT)
- visitors, moderators, participants, others = [], [], [], []
+
aff = {
'owner': get_theme().CHAR_AFFILIATION_OWNER,
'admin': get_theme().CHAR_AFFILIATION_ADMIN,
@@ -681,37 +677,20 @@ class MucTab(ChatTab):
'none': get_theme().CHAR_AFFILIATION_NONE,
}
- users = self.users[:]
- users.sort(key=lambda x: x.nick.lower())
- for user in users:
- color = aff.get(user.affiliation,
- get_theme().CHAR_AFFILIATION_NONE)
- if user.role == 'visitor':
- visitors.append((user, color))
- elif user.role == 'participant':
- participants.append((user, color))
- elif user.role == 'moderator':
- moderators.append((user, color))
- else:
- others.append((user, color))
+ colors = {}
+ colors["visitor"] = dump_tuple(get_theme().COLOR_USER_VISITOR)
+ colors["moderator"] = dump_tuple(get_theme().COLOR_USER_MODERATOR)
+ colors["participant"] = dump_tuple(get_theme().COLOR_USER_PARTICIPANT)
+ color_other = dump_tuple(get_theme().COLOR_USER_NONE)
buff = ['Users: %s \n' % len(self.users)]
- for moderator in moderators:
- buff.append('\x19%s}%s\x19o\x19%s}%s\x19o' % (
- color_moderator, moderator[1],
- dump_tuple(moderator[0].color), moderator[0].nick))
- for participant in participants:
- buff.append('\x19%s}%s\x19o\x19%s}%s\x19o' % (
- color_participant, participant[1],
- dump_tuple(participant[0].color), participant[0].nick))
- for visitor in visitors:
- buff.append('\x19%s}%s\x19o\x19%s}%s\x19o' % (
- color_visitor, visitor[1],
- dump_tuple(visitor[0].color), visitor[0].nick))
- for other in others:
+ for user in self.users:
+ affiliation = aff.get(user.affiliation,
+ get_theme().CHAR_AFFILIATION_NONE)
+ color = colors.get(user.role, color_other)
buff.append('\x19%s}%s\x19o\x19%s}%s\x19o' % (
- color_other, other[1],
- dump_tuple(other[0].color), other[0].nick))
+ color, affiliation, dump_tuple(user.color), user.nick))
+
buff.append('\n')
message = ' '.join(buff)