Beispiel #1
0
 def get_batch_contact(self):
     """
         获取群组联系人
     """
     jsondata = self.get_base_request()
     contact_list = [{
         "UserName": item,
         "EncryChatRoomId": ""
     } for item in self.__person_data["ChatSet"].split(",") if "@@" in item]
     jsondata.update({"Count": len(contact_list), "List": contact_list})
     resp = self.post(
         API_webwxbatchgetcontact,
         params={
             "type": "ex",
             "r": Device.get_timestamp(),
             "lang": "zh_CN",
             "pass_ticket": self.__auth_data["pass_ticket"],
         },
         json=jsondata,
     )
     self.__batch_contacts = resp.json()
     self.__person_map = Device.trans_map(self.__contacts,
                                          self.__batch_contacts)
     create_json(self.__batch_contacts,
                 API_static_path / "batch_contacts.json")
Beispiel #2
0
    def get_batch_contact(self, contact_list: list = None):
        """
        获取群组联系人
        """
        if not contact_list:
            contact_list = self.__person_data["ChatSet"].split(",")

        contact_list = list(
            filter(lambda name: name in self.__person_map, contact_list))

        if not contact_list:
            return

        for contact_list in [{
                "UserName": item,
                "EncryChatRoomId": ""
        } for item in contact_list if "@@" in item]:
            contact_list = [contact_list]
            jsondata = self.get_base_request()
            jsondata.update({"Count": len(contact_list), "List": contact_list})
            resp = self.post(
                API_webwxbatchgetcontact,
                params={
                    "type": "ex",
                    "r": Device.get_timestamp(),
                    "lang": "zh_CN",
                    "pass_ticket": self.__auth_data["pass_ticket"],
                },
                json=jsondata,
            )
            self.__batch_contacts.update(resp.json())
        self.__person_map = Device.trans_map(self.__contacts,
                                             self.__batch_contacts)
        create_json(self.__batch_contacts,
                    API_static_path / "batch_contacts.json")