def on_roster_update_notify(self, added_ls, removed_ls, modified_ls): """ roster添加成功通知 :param added_ls: added_ls RosterItem 列表 :param removed_ls: removed RosterItem 列表 :param modified_ls: modified RosterItem 列表 :return: """ added_ls = [roster_item_2_dic(roster_item) for roster_item in added_ls] removed_ls = [roster_item_2_dic(roster_item) for roster_item in removed_ls] modified_ls = [roster_item_2_dic(roster_item) for roster_item in modified_ls] s2c_message.xmpp_roster_update_notify(self.JID.bare().as_string(), removed_ls, modified_ls, added_ls)
def get_roster_items(self): """ 获取当前的roster items :return: """ roster_ls = [] if not self.xmpp_client.roster_client.roster: return [] for item in self.xmpp_client.roster_client.roster.items(): if item.subscription == "both": roster_ls.append(roster_item_2_dic(item)) return roster_ls