summaryrefslogtreecommitdiff
path: root/src/multiuserchat.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/multiuserchat.py')
-rw-r--r--src/multiuserchat.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 67fa32e6..264f0e4a 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -70,7 +70,7 @@ def leave_groupchat(xmpp, jid, own_nick, msg):
def set_user_role(xmpp, jid, nick, reason, role):
"""
(try to) Set the role of a MUC user
- (role =) 'none': eject user)
+ (role = 'none': eject user)
"""
iq = xmpp.makeIqSet()
query = ET.Element('{%s}query' % NS_MUC_ADMIN)
@@ -86,3 +86,22 @@ def set_user_role(xmpp, jid, nick, reason, role):
return iq.send()
except Exception as e:
return e.iq
+
+def set_user_affiliation(xmpp, jid, nick, reason, affiliation):
+ """
+ (try to) Set the affiliation of a MUC user
+ """
+ iq = xmpp.makeIqSet()
+ query = ET.Element('{%s}query' % NS_MUC_ADMIN)
+ item = ET.Element('{%s}item' % NS_MUC_ADMIN, {'nick':nick, 'affiliation':affiliation})
+ if reason:
+ reason_el = ET.Element('{%s}reason' % NS_MUC_ADMIN)
+ reason_el.text = reason
+ item.append(reason_el)
+ query.append(item)
+ iq.append(query)
+ iq['to'] = jid
+ try:
+ return iq.send()
+ except Exception as e:
+ return e.iq