summaryrefslogtreecommitdiff
path: root/src/multiuserchat.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/multiuserchat.py')
-rw-r--r--src/multiuserchat.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index b00b4599..264f0e4a 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -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