diff options
Diffstat (limited to 'slixmpp/plugins/xep_0405/mix_pam.py')
-rw-r--r-- | slixmpp/plugins/xep_0405/mix_pam.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0405/mix_pam.py b/slixmpp/plugins/xep_0405/mix_pam.py index cff22b51..1158a6f9 100644 --- a/slixmpp/plugins/xep_0405/mix_pam.py +++ b/slixmpp/plugins/xep_0405/mix_pam.py @@ -6,13 +6,16 @@ See the file LICENSE for copying permission. """ from typing import ( + List, Optional, Set, + Tuple, ) from slixmpp import JID, Iq from slixmpp.exceptions import IqError, IqTimeout from slixmpp.plugins import BasePlugin +from slixmpp.stanza.roster import RosterItem from slixmpp.plugins.xep_0405 import stanza from slixmpp.plugins.xep_0369 import stanza as mix_stanza @@ -86,3 +89,26 @@ class XEP_0405(BasePlugin): iq['client_leave']['channel'] = room iq['client_leave'].enable('mix_leave') return await iq.send(**iqkwargs) + + async def get_mix_roster(self, *, + ito: Optional[JID] = None, + ifrom: Optional[JID] = None, + **iqkwargs) -> Tuple[List[RosterItem], List[RosterItem]]: + """ + Get the annotated roster, with MIX channels. + + :return: A tuple of (contacts, mix channels) as RosterItem elements + """ + iq = self.xmpp.make_iq_get(ito=ito, ifrom=ifrom) + iq['roster'].enable('annotate') + result = await iq.send(**iqkwargs) + self.xmpp.event("roster_update", result) + contacts = [] + mix = [] + for item in result['roster']: + channel = item._get_plugin('channel', check=True) + if channel: + mix.append(item) + else: + contacts.append(item) + return (contacts, mix) |