[avb] add /names command for GC

Fix /query [TAB] bug
This commit is contained in:
Dimitur Kirov 2006-06-08 10:09:15 +00:00
parent 9af2d254a1
commit 664e00c43c
2 changed files with 31 additions and 8 deletions

1
THANKS
View File

@ -1,4 +1,5 @@
Alexander Futász Alexander Futász
Alexander V. Butenko
Alexey Nezhdanov Alexey Nezhdanov
Alfredo Junix Alfredo Junix
Anders Ström Anders Ström

View File

@ -183,7 +183,7 @@ class GroupchatControl(ChatControlBase):
# alphanum sorted # alphanum sorted
self.muc_cmds = ['ban', 'chat', 'query', 'clear', 'close', 'compact', self.muc_cmds = ['ban', 'chat', 'query', 'clear', 'close', 'compact',
'help', 'invite', 'join', 'kick', 'leave', 'me', 'msg', 'nick', 'part', 'help', 'invite', 'join', 'kick', 'leave', 'me', 'msg', 'nick', 'part',
'say', 'topic'] 'names', 'say', 'topic']
# muc attention flag (when we are mentioned in a muc) # muc attention flag (when we are mentioned in a muc)
# if True, the room has mentioned us # if True, the room has mentioned us
self.attention_flag = False self.attention_flag = False
@ -1001,14 +1001,19 @@ class GroupchatControl(ChatControlBase):
# Open a chat window to the specified nick # Open a chat window to the specified nick
# example: /query foo # example: /query foo
if len(message_array): if len(message_array):
nick = message_array.pop(0) nick0 = message_array.pop(0)
if nick0[-1] == ' ':
nick1 = nick0[:-1]
else:
nick1 = nick0
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid) nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
for nick in [nick0, nick1]:
if nick in nicks: if nick in nicks:
self.on_send_pm(nick = nick) self.on_send_pm(nick = nick)
self.clear(self.msg_textview) self.clear(self.msg_textview)
else: return True
self.print_conversation(_('Nickname not found: %s') % nick, self.print_conversation(_('Nickname not found: %s') % \
'info') nick0, 'info')
else: else:
self.get_command_help(command) self.get_command_help(command)
return True return True
@ -1138,6 +1143,19 @@ class GroupchatControl(ChatControlBase):
else: else:
self.get_command_help(command) self.get_command_help(command)
return True return True
elif command == 'names':
# print the list of participants
nicklist=""
i=0
for contact in self.iter_contact_rows():
nicklist += '[ %-12.12s ] ' % (contact[C_NICK].decode('utf-8'))
i=i+1
if i == 3:
i=0
self.print_conversation(nicklist, 'info')
nicklist=""
self.clear(self.msg_textview)
return True
elif command == 'help': elif command == 'help':
if len(message_array): if len(message_array):
subcommand = message_array.pop(0) subcommand = message_array.pop(0)
@ -1221,6 +1239,10 @@ class GroupchatControl(ChatControlBase):
s = _('Usage: /%s <nickname>, changes your nickname in current room.')\ s = _('Usage: /%s <nickname>, changes your nickname in current room.')\
% command % command
self.print_conversation(s, 'info') self.print_conversation(s, 'info')
elif command == 'names':
s = _('Usage: /%s , display the names of room occupants.')\
% command
self.print_conversation(s, 'info')
elif command == 'topic': elif command == 'topic':
self.print_conversation(_('Usage: /%s [topic], displays or updates the' self.print_conversation(_('Usage: /%s [topic], displays or updates the'
' current room topic.') % command, 'info') ' current room topic.') % command, 'info')