From ed4f74faf1855a676c3407c0236baede34aba3ab Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 12 Feb 2012 00:51:01 +0100 Subject: Allow setting the affiliation of a JID, and add outcast affiliation (also, remove the reason of the affiliation change for the time being) --- src/multiuserchat.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/multiuserchat.py') diff --git a/src/multiuserchat.py b/src/multiuserchat.py index f537c2c1..3f0c80b8 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -88,21 +88,11 @@ def set_user_role(xmpp, jid, nick, reason, role): except Exception as e: return e.iq -def set_user_affiliation(xmpp, jid, nick, reason, affiliation): +def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason=None): """ (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 + return xmpp.plugin['xep_0045'].set_affiliation(muc_jid, jid, nick, affiliation) + except: + return False -- cgit v1.2.3