mirror of
https://github.com/littlecodersh/ItChat.git
synced 2026-10-17 05:30:31 +08:00
Add name card sending
This commit is contained in:
+2
-1
@@ -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
@@ -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']) + \
|
||||
|
||||
Reference in New Issue
Block a user