Fix completion and function names for /accept and /add

This commit is contained in:
mathieui 2020-05-09 23:32:26 +02:00
parent eda88a59a6
commit e03fb0b3ce
3 changed files with 14 additions and 5 deletions

View file

@ -520,7 +520,7 @@ class CommandCore:
@deny_anonymous
@command_args_parser.quoted(0, 1)
def command_accept(self, args):
def accept(self, args):
"""
Accept a JID. Authorize it AND subscribe to it
"""
@ -557,7 +557,7 @@ class CommandCore:
@deny_anonymous
@command_args_parser.quoted(1)
def command_add(self, args):
def add(self, args):
"""
Add the specified JID to the roster, and automatically
accept the reverse subscription

View file

@ -44,6 +44,14 @@ class CompletionCore:
' ',
quotify=False)
def roster_barejids(self, the_input):
"""Complete roster bare jids"""
jids = sorted(
str(contact.bare_jid) for contact in roster.contacts.values()
if contact.pending_in
)
return Completion(the_input.new_completion, jids, 1, '', quotify=False)
def presence(self, the_input):
"""
Completion of /presence

View file

@ -1770,14 +1770,15 @@ class Core:
completion=self.completion.bookmark)
self.register_command(
'accept',
self.command.command_accept,
self.command.accept,
usage='[jid]',
desc='Allow the provided JID (or the selected contact '
'in your roster), to see your presence.',
shortdesc='Allow a user your presence.',)
shortdesc='Allow a user your presence.',
completion=self.completion.roster_barejids)
self.register_command(
'add',
self.command.command_add,
self.command.add,
usage='<jid>',
desc='Add the specified JID to your roster, ask them to'
' allow you to see his presence, and allow them to'