Add name card sending

This commit is contained in:
LittleCoder
2016-10-25 17:30:03 +08:00
parent 1802989e61
commit fafff28cb8
2 changed files with 10 additions and 6 deletions
+2 -1
View File
@@ -3,7 +3,7 @@ import time
from .client import client
from . import content # this is for creating pyc
__version__ = '1.1.17'
__version__ = '1.1.18'
__client = client()
HOT_RELOAD = False
@@ -58,6 +58,7 @@ def get_batch_contract(groupUserName): return __client.update_chatroom(groupUser
# <<<
# if toUserName is set to None, msg will be sent to yourself
def send_raw_msg(msgType, content, toUserName): return __client.send_raw_msg(msgType, content, toUserName)
def send_msg(msg = 'Test Message', toUserName = None): return __client.send_msg(msg, toUserName)
def send_file(fileDir, toUserName): return __client.send_file(fileDir, toUserName)
def send_video(fileDir, toUserName): return __client.send_video(fileDir, toUserName)
+8 -5
View File
@@ -539,21 +539,24 @@ class client(object):
in msg['Content']
or
msg['Content'].endswith(atFlag))
def send_msg(self, msg ='Test Message', toUserName = None):
def send_raw_msg(self, msgType, content, toUserName):
url = '%s/webwxsendmsg'%self.loginInfo['url']
payloads = {
'BaseRequest': self.loginInfo['BaseRequest'],
'Msg': {
'Type': 1,
'Content': msg,
'Type': msgType,
'Content': content,
'FromUserName': self.storageClass.userName,
'ToUserName': (toUserName if toUserName else self.storageClass.userName),
'LocalID': int(time.time()),
'ClientMsgId': int(time.time()),
}, }
headers = { 'ContentType': 'application/json; charset=UTF-8' }
r = self.s.post(url, data = json.dumps(payloads, ensure_ascii = False).encode('utf8'), headers = headers)
return r.json()['BaseResponse']['Ret'] == 0
r = self.s.post(url, data=json.dumps(payloads, ensure_ascii=False).encode('utf8'), headers=headers)
return r.json()
def send_msg(self, msg='Test Message', toUserName=None):
r = self.send_raw_msg(1, msg, toUserName)
return r['BaseResponse']['Ret'] == 0
def __upload_file(self, fileDir, isPicture = False, isVideo = False):
if not tools.check_file(fileDir): return
url = self.loginInfo.get('fileUrl', self.loginInfo['url']) + \