muctab: Add a /request_voice for use in moderated rooms

It signals moderators that you want to speak.
This commit is contained in:
Emmanuel Gil Peyrot 2021-05-21 19:06:23 +02:00
parent 2b032b7d02
commit 6c0be69524

View file

@ -1795,6 +1795,30 @@ class MucTab(ChatTab):
self.ignores.remove(user)
self.core.information('%s is now unignored' % nick)
@command_args_parser.quoted(0, 1)
def command_request_voice(self, args: List[str]) -> None:
"""
/request_voice [role]
Request voice in a moderated room
role can be: participant, moderator
"""
room = JID(self.name)
if not room:
self.core.information('request_voice: requires a valid chat address', 'Error')
return
if len(args) > 1:
self.core.command.help('request_voice')
return
if args:
role = args[0]
else:
role = 'participant'
self.core.xmpp['xep_0045'].request_voice(room, role)
########################## COMPLETIONS #################################
def completion(self) -> None:
@ -1965,6 +1989,11 @@ class MucTab(ChatTab):
return Completion(the_input.auto_completion, users, quotify=False)
return None
def completion_request_voice(self, the_input: windows.MessageInput) -> Optional[Completion]:
"""Completion for /request_voice"""
allowed = ['participant', 'moderator']
return Completion(the_input.auto_completion, allowed, quotify=False)
########################## REGISTER STUFF ##############################
@ -2234,6 +2263,19 @@ class MucTab(ChatTab):
'Invite a contact to this room',
'completion':
self.completion_invite
}, {
'name':
'request_voice',
'func':
self.command_request_voice,
'desc':
'Request voice when we are a visitor in a moderated room',
'usage':
'[role]',
'shortdesc':
'Request voice in a moderated room',
'completion':
self.completion_request_voice
}])