Improve /names command

This commit is contained in:
mathieui 2011-12-10 16:36:18 +01:00 committed by Florent Le Coz
parent ef72674102
commit 0d5b96fd8d

View file

@ -781,7 +781,12 @@ class MucTab(ChatTab):
""" """
if not self.joined: if not self.joined:
return return
users, visitors, moderators, participants, others = [], [], [], [], [] color_visitor = get_theme().COLOR_USER_VISITOR[0]
color_other = get_theme().COLOR_USER_NONE[0]
color_moderator = get_theme().COLOR_USER_MODERATOR[0]
color_participant = get_theme().COLOR_USER_PARTICIPANT[0]
color_information = get_theme().COLOR_INFORMATION_TEXT[0]
visitors, moderators, participants, others = [], [], [], []
for user in self.users: for user in self.users:
if user.role == 'visitor': if user.role == 'visitor':
visitors.append(user.nick) visitors.append(user.nick)
@ -791,20 +796,18 @@ class MucTab(ChatTab):
moderators.append(user.nick) moderators.append(user.nick)
else: else:
others.append(user.nick) others.append(user.nick)
users.append(user.nick)
message = '' message = 'Users: %s \n' % len(self.users)
roles = (('Users', users), ('Visitors', visitors), ('Participants', participants), ('Moderators', moderators), ('Others', others)) for moderator in moderators:
for role in roles: message += ' \x19%s}%s\x19o -' % (color_moderator, moderator)
if role[1]: for participant in participants:
role[1].sort() message += ' \x19%s}%s\x19o -' % (color_participant, participant)
message += '%s: %i\n ' % (role[0], len(role[1])) for visitor in visitors:
last = role[1].pop() message += ' \x19%s}%s\x19o -' % (color_visitor, visitor)
for item in role[1]: for other in others:
message += '%s, ' % item message += ' \x19%s}%s\x19o -' % (color_other, other)
message += '%s\n' % last message = message[:-2]
# self.core.add_message_to_text_buffer(room, message)
self._text_buffer.add_message(message) self._text_buffer.add_message(message)
self.text_win.refresh() self.text_win.refresh()
self.input.refresh() self.input.refresh()