summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-11-26 21:18:34 -0800
committerLance Stout <lancestout@gmail.com>2013-11-26 21:18:34 -0800
commit540d6e9dbb5c4be190f4d114a438f80a9d9cd623 (patch)
tree956d23e12aa8c6a44943726f3e791d5e344f005f /sleekxmpp
parent08a0fd5420c25108d3bff4096a2378fd2f288a50 (diff)
parent79a3a2befd866f168c2a8ab389f5a4f0ddeb9b5a (diff)
downloadslixmpp-540d6e9dbb5c4be190f4d114a438f80a9d9cd623.tar.gz
slixmpp-540d6e9dbb5c4be190f4d114a438f80a9d9cd623.tar.bz2
slixmpp-540d6e9dbb5c4be190f4d114a438f80a9d9cd623.tar.xz
slixmpp-540d6e9dbb5c4be190f4d114a438f80a9d9cd623.zip
Merge pull request #267 from juanrmn/develop
Added a MUC method 'setRole'. Change role property of a nick in a room, ...
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/xep_0045.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0045.py b/sleekxmpp/plugins/xep_0045.py
index 1d5f3c83..6e3f10a9 100644
--- a/sleekxmpp/plugins/xep_0045.py
+++ b/sleekxmpp/plugins/xep_0045.py
@@ -289,6 +289,24 @@ class XEP_0045(BasePlugin):
return False
return True
+ def setRole(self, room, nick, role):
+ """ Change role property of a nick in a room.
+ Typically, roles are temporary (they last only as long as you are in the
+ room), whereas affiliations are permanent (they last across groupchat
+ sessions).
+ """
+ if role not in ('outcast', 'member', 'admin', 'owner', 'none'):
+ raise TypeError
+ query = ET.Element('{http://jabber.org/protocol/muc#admin}query')
+ item = ET.Element('item', {'role':role, 'nick':nick})
+ query.append(item)
+ iq = self.xmpp.makeIqSet(query)
+ iq['to'] = room
+ result = iq.send()
+ if result is False or result['type'] != 'result':
+ raise ValueError
+ return True
+
def invite(self, room, jid, reason='', mfrom=''):
""" Invite a jid to a room."""
msg = self.xmpp.makeMessage(room)