Exemple #1
0
 def worker():
     debug("start main loop")
     while True:
         sync_check_res = self.get_msg_signal()
         debug(f"sync_check_res: {sync_check_res}")
         retcode, selector = (
             sync_check_res["retcode"],
             sync_check_res["selector"],
         )
         if retcode == "0" and int(selector) > 0:
             msgs = self.get_msg_contents()
             debug(f"Contents: {msgs}")
             for msg in msgs["AddMsgList"]:
                 _, result = self.data_ctrl(msg)
                 self.send_back(result)
         elif retcode == "1101":
             self.__is_online = False
             warning("main loop offline")
             return
Exemple #2
0
 def send_text(self, target, msg):
     """
         文本消息发送
     """
     jsondata = self.get_base_request()
     LocalID = str(execjs.eval("+new Date()"))
     jsondata.update({
         "Msg": {
             "Type": 1,
             "Content": msg,
             "FromUserName": self.__person_data["User"]["UserName"],
             "ToUserName": target,
             "LocalID": LocalID,
             "ClientMsgId": LocalID,
         },
         "Scene": 0,
     })
     fakeHeader = {
         "Accept": "application/json, text/plain, */*",
         "Accept-Encoding": "gzip, deflate, br",
         "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
         "Content-Type": "application/json;charset=UTF-8",
         "Host": "wx.qq.com",
         "Origin": "https://wx.qq.com",
         "Referer": "https://wx.qq.com/?&lang=zh_CN",
         "User-Agent": "Webot/1.0",
     }
     resp = self.post(
         API_webwxsendmsg,
         params={
             "lang": "zh_CN",
             "pass_ticket": self.__auth_data["pass_ticket"]
         },
         data=json.dumps(jsondata, ensure_ascii=False).encode("utf-8"),
         headers=fakeHeader,
     )
     warning(self.translate_text(f"🤖️->【{target}】: {msg}"))
     debug(resp.json())
Exemple #3
0
    def export_all_contact(contacts, session, person_data):
        """
            导出通讯录
        """
        warning("Contact exporting...")
        wb = Workbook()
        sheet = wb.active
        keys = contacts["MemberList"][0].keys()
        for x, key in enumerate(keys):
            sheet.cell(row=1, column=x + 1, value=key)
        for y, item in progressbar.progressbar(
                enumerate(contacts["MemberList"])):
            y = y + 2
            for x, key in enumerate(keys):
                x = x + 1
                data = item[key]

                if key != "HeadImgUrl":
                    if key == "MemberList":
                        data = "".join(data)
                    sheet.cell(row=y, column=x, value=data)
                else:
                    picData = get_pic(session, data)
                    if picData:
                        x = x - 1
                        indexCode = string.ascii_uppercase[x]
                        size = (50, 50)
                        sheet.column_dimensions[
                            indexCode].width, sheet.row_dimensions[
                                y].height = size
                        img = openpyxlImage(BytesIO(picData))
                        img.width, img.height = size
                        sheet.add_image(img, f"{indexCode}{y}")
                    else:
                        sheet.cell(row=y, column=x, value="")
        wb.save(
            f'{API_conf_path}/{person_data["User"]["NickName"]}_contacts.xlsx')
        success("Complete!")
Exemple #4
0
 def get_encoding(resp):
     warning(f"Current Data's Encoding [{resp.encoding}]")
     return resp.encoding
Exemple #5
0
 def login_localwait(self):
     """
         等待本地终端扫描
     """
     warning("Waiting for app scan")
     self.login_wait(True)