diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2020-12-27 02:19:21 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2020-12-27 02:59:09 +0100 |
commit | c05cafc9637854d21c1a7d6709c69f7e8dd1497a (patch) | |
tree | c4f7fd6ae8360fb63da938fe0b429ad2cbbea05d | |
parent | 166b265de0327267ae47234ca6f13d17e2647aca (diff) | |
download | slixmpp-c05cafc9637854d21c1a7d6709c69f7e8dd1497a.tar.gz slixmpp-c05cafc9637854d21c1a7d6709c69f7e8dd1497a.tar.bz2 slixmpp-c05cafc9637854d21c1a7d6709c69f7e8dd1497a.tar.xz slixmpp-c05cafc9637854d21c1a7d6709c69f7e8dd1497a.zip |
XEP-0045: Add missing reason for affiliation and role changes
This is especially useful for ban/kick reasons.
-rw-r--r-- | slixmpp/plugins/xep_0045/muc.py | 8 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0045/stanza.py | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/slixmpp/plugins/xep_0045/muc.py b/slixmpp/plugins/xep_0045/muc.py index 1ff7632b..aa1ed9e9 100644 --- a/slixmpp/plugins/xep_0045/muc.py +++ b/slixmpp/plugins/xep_0045/muc.py @@ -242,7 +242,7 @@ class XEP_0045(BasePlugin): await iq.send(**iqkwargs) async def set_affiliation(self, room: JID, jid: Optional[JID] = None, nick: Optional[str] = None, *, affiliation: str, - ifrom: Optional[JID] = None, **iqkwargs): + reason: str = '', ifrom: Optional[JID] = None, **iqkwargs): """ Change room affiliation.""" if affiliation not in AFFILIATIONS: raise ValueError('%s is not a valid affiliation' % affiliation) @@ -256,11 +256,13 @@ class XEP_0045(BasePlugin): item['nick'] = nick if jid: item['jid'] = jid + if reason: + item['reason'] = reason iq['mucadmin_query'].append(item) await iq.send(**iqkwargs) async def set_role(self, room: JID, nick: str, role: str, *, - ifrom: Optional[JID] = None, **iqkwargs): + reason: str = '', ifrom: Optional[JID] = None, **iqkwargs): """ Change role property of a nick in a room. Typically, roles are temporary (they last only as long as you are in the room), whereas affiliations are permanent (they last across groupchat @@ -273,6 +275,8 @@ class XEP_0045(BasePlugin): item = MUCAdminItem() item['role'] = role item['nick'] = nick + if reason: + item['reason'] = reason iq['mucadmin_query'].append(item) await iq.send(**iqkwargs) diff --git a/slixmpp/plugins/xep_0045/stanza.py b/slixmpp/plugins/xep_0045/stanza.py index 64224949..8de938fb 100644 --- a/slixmpp/plugins/xep_0045/stanza.py +++ b/slixmpp/plugins/xep_0045/stanza.py @@ -220,7 +220,8 @@ class MUCAdminItem(ElementBase): namespace = NS_ADMIN name = 'item' plugin_attrib = 'item' - interfaces = {'role', 'affiliation', 'nick', 'jid'} + interfaces = {'role', 'affiliation', 'nick', 'jid', 'reason'} + sub_interfaces = {'reason'} class MUCStatus(ElementBase): |