summaryrefslogtreecommitdiff
path: root/src/multiuserchat.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-10-17 21:59:20 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-10-17 21:59:20 +0200
commit842e4a3f4a8ed32c062bbbaed47496afba4b4bef (patch)
treec88d387bcaca8991deaa5d07cff506d3e780d838 /src/multiuserchat.py
parent20eeb00b9744eae068f894a98b3a355a0ef728ac (diff)
parentb29f11ce19188f277d8b94a640fe54c19f2b7972 (diff)
downloadpoezio-842e4a3f4a8ed32c062bbbaed47496afba4b4bef.tar.gz
poezio-842e4a3f4a8ed32c062bbbaed47496afba4b4bef.tar.bz2
poezio-842e4a3f4a8ed32c062bbbaed47496afba4b4bef.tar.xz
poezio-842e4a3f4a8ed32c062bbbaed47496afba4b4bef.zip
Merge branch 'master' of https://git.louiz.org/poezio
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