Fix the completion for /decline and /invite

This commit is contained in:
mathieui 2011-12-18 20:43:40 +01:00
parent caff8b43a1
commit 08b374cb29

View file

@ -387,14 +387,15 @@ class Core(object):
self.xmpp.plugin['xep_0045'].invite(room, to, reason) self.xmpp.plugin['xep_0045'].invite(room, to, reason)
def completion_invite(self, the_input): def completion_invite(self, the_input):
"""Completion for /invite"""
txt = the_input.get_text() txt = the_input.get_text()
args = common.shell_split(txt) args = common.shell_split(txt)
n = len(args) n = len(args)
if txt.endswith(' '): if txt.endswith(' '):
n += 1 n += 1
if len(args) == 1: if n == 2:
return the_input.auto_completion([contact.bare_jid for contact in roster.get_contacts()], '') return the_input.auto_completion([contact.bare_jid for contact in roster.get_contacts()], '')
elif len(args) == 2: elif n == 3:
rooms = [] rooms = []
for tab in self.tabs: for tab in self.tabs:
if isinstance(tab, tabs.MucTab) and tab.joined: if isinstance(tab, tabs.MucTab) and tab.joined:
@ -410,8 +411,19 @@ class Core(object):
if jid.bare not in self.pending_invites: if jid.bare not in self.pending_invites:
return return
reason = args[1] if len(args) > 1 else '' reason = args[1] if len(args) > 1 else ''
del self.pending_invites[jid.bare]
self.xmpp.plugin['xep_0045'].decline_invite(jid.bare, self.pending_invites[jid.bare], reason) self.xmpp.plugin['xep_0045'].decline_invite(jid.bare, self.pending_invites[jid.bare], reason)
def completion_decline(self, the_input):
"""Completion for /decline"""
txt = the_input.get_text()
args = common.shell_split(txt)
n = len(args)
if txt.endswith(' '):
n += 1
if n == 2:
return the_input.auto_completion(list(self.pending_invites.keys()), '')
def command_invitations(self, arg): def command_invitations(self, arg):
"""/invitations""" """/invitations"""
build = "" build = ""
@ -423,15 +435,6 @@ class Core(object):
build = "You are do not have any pending invitation." build = "You are do not have any pending invitation."
self.information(build, 'Info') self.information(build, 'Info')
def completion_decline(self, the_input):
txt = the_input.get_text()
args = common.shell_split(txt)
n = len(args)
if txt.endswith(' '):
n += 1
if len(args) == 1:
return the_input.auto_completion(list(self.pending_invites.keys()), '')
def on_groupchat_decline(self, decline): def on_groupchat_decline(self, decline):
pass pass