pywxclient.core.client module¶
WeChat Client module.
-
class
pywxclient.core.client.
Client
(session, api_cls=<class 'pywxclient.core.api.WeChatAPI'>)¶ Bases:
object
WeChat client base class.
Request WeChat authorize.
-
close
()¶ Close client.
-
dump
()¶ Dump client object as dict.
-
flush_sync_key
()¶ Update WeChat session sync key.
This must be invoked after successfully handling new messages. Otherwise client is at risk of losing messages.
Get WeChat authorize url.
-
get_batch_contact
(user_list)¶ Batch getting WeChat contacts.
Parameters: user_list – a list contains dict like { ‘UserName’: ‘username’, ‘EncryChatRoomId’: ‘’}.
-
get_contact
()¶ Get WeChat contacts.
-
classmethod
load
(client_dict)¶ Restore client from dict.
-
login
()¶ Login in WeChat.
-
logout
()¶ Logout WeChat.
-
ok_login_code
= (200, 201, 400, 408)¶
-
send_message
(message)¶ Send WeChat message.
-
sync_check
()¶ Check WeChat sync status.
-
sync_message
()¶ Sync WeChat message.
-
upload
(file_obj, to_username)¶ Upload message resource to WeChat.
-
class
pywxclient.core.client.
SyncClient
(session, api_cls=<class 'pywxclient.core.api.WeChatAPI'>)¶ Bases:
pywxclient.core.client.Client
Sync request WeChat client.
Start wechat authorization.
Get WeChat authorize url.
-
get_batch_contact
(user_list)¶ Batch getting contact.
-
get_contact
()¶ Get wechat contact.
-
get_head_img
(headimg_url)¶ Get user head image.
Parameters: headimg_url – headimg url.
-
get_icon
(icon_url)¶ Get user icon.
Parameters: icon_url – icon url.
-
get_message_media
(message)¶ Get message media content.
-
login
()¶ Login wechat session.
-
logout
()¶ Logout wechat session.
-
msg_send_routines
= {1: <bound method WeChatAPI.send_text_message of <class 'pywxclient.core.api.WeChatAPI'>>, 3: <bound method WeChatAPI.send_image_message of <class 'pywxclient.core.api.WeChatAPI'>>, 6: <bound method WeChatAPI.send_file_message of <class 'pywxclient.core.api.WeChatAPI'>>, 43: <bound method WeChatAPI.send_video_message of <class 'pywxclient.core.api.WeChatAPI'>>, 47: <bound method WeChatAPI.send_gif_message of <class 'pywxclient.core.api.WeChatAPI'>>}¶
Open WeChat authorization url in system-default browser.
-
send_message
(message)¶ Send message to WeChat.
-
set_user_remark
(username, remark)¶ Set user wechat remark.
-
sync_check
()¶ Check session status.
-
sync_message
()¶ Sync wechat message.
-
upload
(file_obj, to_username)¶ Upload resource to WeChat.