MCPcopy
hub / github.com/liuwons/wxBot / send_msg_by_uid

Method send_msg_by_uid

wxbot.py:465–488  ·  view source on GitHub ↗
(self, word, dst='filehelper')

Source from the content-addressed store, hash-verified

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:

Callers 4

send_msgMethod · 0.95
handle_msg_allMethod · 0.80
auto_switchMethod · 0.80
handle_msg_allMethod · 0.80

Calls

no outgoing calls

Tested by 1

handle_msg_allMethod · 0.64