Reimplemented the /names command
This commit is contained in:
parent
99aa440fbf
commit
6a50a96be2
|
@ -224,7 +224,7 @@ class StandardChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
AUTOMATIC = True
|
AUTOMATIC = True
|
||||||
HOSTS = (ChatCommands,)
|
HOSTS = ChatCommands,
|
||||||
|
|
||||||
class StandardPrivateChatCommands(CommandContainer):
|
class StandardPrivateChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
@ -233,7 +233,7 @@ class StandardPrivateChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
AUTOMATIC = True
|
AUTOMATIC = True
|
||||||
HOSTS = (PrivateChatCommands,)
|
HOSTS = PrivateChatCommands,
|
||||||
|
|
||||||
class StandardGroupChatCommands(CommandContainer):
|
class StandardGroupChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
@ -242,7 +242,7 @@ class StandardGroupChatCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
AUTOMATIC = True
|
AUTOMATIC = True
|
||||||
HOSTS = (GroupChatCommands,)
|
HOSTS = GroupChatCommands,
|
||||||
|
|
||||||
@command(raw=True)
|
@command(raw=True)
|
||||||
@doc(_("Change your nickname in a group chat"))
|
@doc(_("Change your nickname in a group chat"))
|
||||||
|
@ -330,23 +330,24 @@ class StandardGroupChatCommands(CommandContainer):
|
||||||
@command
|
@command
|
||||||
@doc(_("Display names of all group chat occupants"))
|
@doc(_("Display names of all group chat occupants"))
|
||||||
def names(self, verbose=False):
|
def names(self, verbose=False):
|
||||||
get_contact = lambda nick: gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
ggc = gajim.contacts.get_gc_contact
|
||||||
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
gnl = gajim.contacts.get_nick_list
|
||||||
|
|
||||||
# First we do alpha-numeric sort and then role-based one.
|
get_contact = lambda nick: ggc(self.account, self.room_jid, nick)
|
||||||
nicks.sort()
|
get_role = lambda nick: get_contact(nick).role
|
||||||
nicks.sort(key=lambda nick: get_contact(nick).role)
|
nicks = gnl(self.account, self.room_jid)
|
||||||
|
|
||||||
if verbose:
|
nicks = sorted(nicks)
|
||||||
for nick in nicks:
|
nicks = sorted(nicks, key=get_role)
|
||||||
contact = get_contact(nick)
|
|
||||||
|
|
||||||
role = helpers.get_uf_role(contact.role)
|
if not verbose:
|
||||||
affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
return ", ".join(nicks)
|
||||||
|
|
||||||
self.echo("%s - %s - %s" % (nick, role, affiliation))
|
for nick in nicks:
|
||||||
else:
|
contact = get_contact(nick)
|
||||||
return ', '.join(nicks)
|
role = helpers.get_uf_role(contact.role)
|
||||||
|
affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
||||||
|
self.echo("%s - %s - %s" % (nick, role, affiliation))
|
||||||
|
|
||||||
@command('ignore', raw=True)
|
@command('ignore', raw=True)
|
||||||
@doc(_("Forbid an occupant to send you public or private messages"))
|
@doc(_("Forbid an occupant to send you public or private messages"))
|
||||||
|
|
Loading…
Reference in New Issue