summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-05-21 18:43:30 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-05-21 19:00:59 +0200
commit889cfaa95b589bf4789c8db928b07966619a60a9 (patch)
tree8e8b7cbcc5f14a73d7b621c58399660b20ef204f
parentb7f0160c0dbe9a63e9454818b1c228b9d007ef13 (diff)
downloadslixmpp-889cfaa95b589bf4789c8db928b07966619a60a9.tar.gz
slixmpp-889cfaa95b589bf4789c8db928b07966619a60a9.tar.bz2
slixmpp-889cfaa95b589bf4789c8db928b07966619a60a9.tar.xz
slixmpp-889cfaa95b589bf4789c8db928b07966619a60a9.zip
XEP-0045: Add a helper method to request voice
This can be used in a moderated room when we are only a visitor.
-rw-r--r--slixmpp/plugins/xep_0045/muc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0045/muc.py b/slixmpp/plugins/xep_0045/muc.py
index 4507be59..21f5c896 100644
--- a/slixmpp/plugins/xep_0045/muc.py
+++ b/slixmpp/plugins/xep_0045/muc.py
@@ -591,6 +591,19 @@ class XEP_0045(BasePlugin):
msg['muc']['decline']['reason'] = reason
self.xmpp.send(msg)
+ def request_voice(self, room: JID, role: str, *, mfrom: Optional[JID] = None):
+ """Request voice in a moderated room.
+
+ :param room: Room to request voice from.
+ """
+ #form = self.xmpp['xep_0004'].make_form(ftype='submit')
+ msg = self.xmpp.make_message(room, mfrom=mfrom)
+ form = msg['form']
+ form['type'] = 'submit'
+ form.add_field(var='FORM_TYPE', ftype='hidden', value='http://jabber.org/protocol/muc#request')
+ form.add_field(var='muc#role', ftype='list-single', label='Requested role', value=role)
+ self.xmpp.send(msg)
+
def jid_in_room(self, room: JID, jid: JID) -> bool:
"""Check if a JID is present in a room.