(self, word, dst='filehelper')
| 463 | time.sleep(0.5 - check_time) |
| 464 | |
| 465 | def send_msg_by_uid(self, word, dst='filehelper'): |
| 466 | url = self.base_uri + '/webwxsendmsg?pass_ticket=%s' % self.pass_ticket |
| 467 | msg_id = str(int(time.time() * 1000)) + str(random.random())[:5].replace('.', '') |
| 468 | if type(word) == 'str': |
| 469 | word = word.decode('utf-8') |
| 470 | params = { |
| 471 | 'BaseRequest': self.base_request, |
| 472 | 'Msg': { |
| 473 | "Type": 1, |
| 474 | "Content": word, |
| 475 | "FromUserName": self.user['UserName'], |
| 476 | "ToUserName": dst, |
| 477 | "LocalID": msg_id, |
| 478 | "ClientMsgId": msg_id |
| 479 | } |
| 480 | } |
| 481 | headers = {'content-type': 'application/json; charset=UTF-8'} |
| 482 | data = json.dumps(params, ensure_ascii=False).encode('utf8') |
| 483 | try: |
| 484 | r = self.session.post(url, data=data, headers=headers) |
| 485 | except (ConnectionError, ReadTimeout): |
| 486 | return False |
| 487 | dic = r.json() |
| 488 | return dic['BaseResponse']['Ret'] == 0 |
| 489 | |
| 490 | def get_user_id(self, name): |
| 491 | for contact in self.contact_list: |
no outgoing calls