From edbd07cf54fb0ba58af8c9372d462c9ae885e7a4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 2 Jun 2011 00:32:42 +0200 Subject: Added a /names command --- src/tabs.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/tabs.py b/src/tabs.py index 2a409b1a..5edbac7c 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -396,6 +396,7 @@ class MucTab(ChatTab): self.commands['info'] = (self.command_info, _('Usage: /info \nInfo: Display some information about the user in the MUC: his/here role, affiliation, status and status message.'), None) self.commands['configure'] = (self.command_configure, _('Usage: /configure\nConfigure: Configure the current room, through a form.'), None) self.commands['version'] = (self.command_version, _('Usage: /version \nVersion: get the software version of the given JID or nick in room (usually its XMPP client and Operating System)'), None) + self.commands['names'] = (self.command_names, _('Usage: /names\nNames: get the list of the users in the room, and the list of the people assuming the different roles.'), None) self.resize() def scroll_user_list_up(self): @@ -544,6 +545,40 @@ class MucTab(ChatTab): subject = arg muc.change_subject(self.core.xmpp, self.get_room().name, subject) + def command_names(self, arg=None): + """ + /names + """ + room = self.get_room() + if not room.joined: + return + users, visitors, moderators, participants, others = [], [], [], [], [] + for user in room.users: + if user.role == 'visitor': + visitors.append(user.nick) + elif user.role == 'participant': + participants.append(user.nick) + elif user.role == 'moderator': + moderators.append(user.nick) + else: + others.append(user.nick) + users.append(user.nick) + + message = '' + roles = (('Users', users), ('Visitors', visitors), ('Participants', participants), ('Moderators', moderators), ('Others', others)) + for role in roles: + if role[1]: + role[1].sort() + message += '%s: %i\n ' % (role[0], len(role[1])) + last = role[1].pop() + for item in role[1]: + message += '%s, ' % item + message += '%s\n' % last + + self.core.add_message_to_text_buffer(room, message) + self.text_win.refresh(self.get_room()) + self.input.refresh() + def completion_topic(self, the_input): current_topic = self.get_room().topic return the_input.auto_completion([current_topic], ' ') -- cgit v1.2.3