XEP-0045: Add missing reason for affiliation and role changes
This is especially useful for ban/kick reasons.
This commit is contained in:
parent
166b265de0
commit
c05cafc963
@ -242,7 +242,7 @@ class XEP_0045(BasePlugin):
|
|||||||
await iq.send(**iqkwargs)
|
await iq.send(**iqkwargs)
|
||||||
|
|
||||||
async def set_affiliation(self, room: JID, jid: Optional[JID] = None, nick: Optional[str] = None, *, affiliation: str,
|
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."""
|
""" Change room affiliation."""
|
||||||
if affiliation not in AFFILIATIONS:
|
if affiliation not in AFFILIATIONS:
|
||||||
raise ValueError('%s is not a valid affiliation' % affiliation)
|
raise ValueError('%s is not a valid affiliation' % affiliation)
|
||||||
@ -256,11 +256,13 @@ class XEP_0045(BasePlugin):
|
|||||||
item['nick'] = nick
|
item['nick'] = nick
|
||||||
if jid:
|
if jid:
|
||||||
item['jid'] = jid
|
item['jid'] = jid
|
||||||
|
if reason:
|
||||||
|
item['reason'] = reason
|
||||||
iq['mucadmin_query'].append(item)
|
iq['mucadmin_query'].append(item)
|
||||||
await iq.send(**iqkwargs)
|
await iq.send(**iqkwargs)
|
||||||
|
|
||||||
async def set_role(self, room: JID, nick: str, role: str, *,
|
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.
|
""" Change role property of a nick in a room.
|
||||||
Typically, roles are temporary (they last only as long as you are in the
|
Typically, roles are temporary (they last only as long as you are in the
|
||||||
room), whereas affiliations are permanent (they last across groupchat
|
room), whereas affiliations are permanent (they last across groupchat
|
||||||
@ -273,6 +275,8 @@ class XEP_0045(BasePlugin):
|
|||||||
item = MUCAdminItem()
|
item = MUCAdminItem()
|
||||||
item['role'] = role
|
item['role'] = role
|
||||||
item['nick'] = nick
|
item['nick'] = nick
|
||||||
|
if reason:
|
||||||
|
item['reason'] = reason
|
||||||
iq['mucadmin_query'].append(item)
|
iq['mucadmin_query'].append(item)
|
||||||
await iq.send(**iqkwargs)
|
await iq.send(**iqkwargs)
|
||||||
|
|
||||||
|
@ -220,7 +220,8 @@ class MUCAdminItem(ElementBase):
|
|||||||
namespace = NS_ADMIN
|
namespace = NS_ADMIN
|
||||||
name = 'item'
|
name = 'item'
|
||||||
plugin_attrib = 'item'
|
plugin_attrib = 'item'
|
||||||
interfaces = {'role', 'affiliation', 'nick', 'jid'}
|
interfaces = {'role', 'affiliation', 'nick', 'jid', 'reason'}
|
||||||
|
sub_interfaces = {'reason'}
|
||||||
|
|
||||||
|
|
||||||
class MUCStatus(ElementBase):
|
class MUCStatus(ElementBase):
|
||||||
|
Loading…
Reference in New Issue
Block a user