diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-10-29 07:20:10 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-10-29 07:20:10 +0200 |
commit | 0451127ff8a1b96772b58ff9e246621d0df4c99e (patch) | |
tree | 00a650ba6f909ee1977bedeb3001798f39a38a0a /src/multiuserchat.py | |
parent | b98880b5269764ad69bb19262790d27b2575b174 (diff) | |
parent | aa6738800d67c5061d7e551b3d896f3366296045 (diff) | |
download | poezio-0451127ff8a1b96772b58ff9e246621d0df4c99e.tar.gz poezio-0451127ff8a1b96772b58ff9e246621d0df4c99e.tar.bz2 poezio-0451127ff8a1b96772b58ff9e246621d0df4c99e.tar.xz poezio-0451127ff8a1b96772b58ff9e246621d0df4c99e.zip |
Merge branch 'master' into plugins
Diffstat (limited to 'src/multiuserchat.py')
-rw-r--r-- | src/multiuserchat.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/multiuserchat.py b/src/multiuserchat.py index 10ea0daf..264f0e4a 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -67,13 +67,14 @@ def leave_groupchat(xmpp, jid, own_nick, msg): """ xmpp.plugin['xep_0045'].leaveMUC(jid, own_nick, msg) -def eject_user(xmpp, jid, nick, reason): +def set_user_role(xmpp, jid, nick, reason, role): """ - (try to) Eject an user from the room + (try to) Set the role of a MUC user + (role = 'none': eject user) """ iq = xmpp.makeIqSet() query = ET.Element('{%s}query' % NS_MUC_ADMIN) - item = ET.Element('{%s}item' % NS_MUC_ADMIN, {'nick':nick, 'role':'none'}) + item = ET.Element('{%s}item' % NS_MUC_ADMIN, {'nick':nick, 'role':role}) if reason: reason_el = ET.Element('{%s}reason' % NS_MUC_ADMIN) reason_el.text = reason @@ -81,4 +82,26 @@ def eject_user(xmpp, jid, nick, reason): query.append(item) iq.append(query) iq['to'] = jid - return iq.send() + try: + 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 |