diff --git a/slixmpp/plugins/xep_0030/stanza/info.py b/slixmpp/plugins/xep_0030/stanza/info.py index 53c1a59f..ff08366f 100644 --- a/slixmpp/plugins/xep_0030/stanza/info.py +++ b/slixmpp/plugins/xep_0030/stanza/info.py @@ -9,6 +9,7 @@ from typing import ( Set, Tuple, Union, + Dict, ) from slixmpp.xmlstream import ElementBase, ET @@ -144,6 +145,25 @@ class DiscoInfo(ElementBase): return True return False + def dict_identities(self, lang: Optional[str] = None) -> Set[Dict[str, str]]: + """ + Return the set of all identities, each one as a dict with + category, type, xml_lang, and name keys. + + :param lang: If there is a need to filter identities by lang. + """ + ids = self.get_identities(lang=lang, dedupe=True) + dict_ids = set() + for identity in ids: + dict_ids.add({ + 'category': identity[0], + 'type': identity[1], + 'xml_lang': identity[2], + 'name': identity[3], + }) + return dict_ids + + def get_identities(self, lang: Optional[str] = None, dedupe: bool = True ) -> Iterable[IdentityType]: """