Joke Collection Website - Public benefit messages - How to set up WeChat automatic reply in python

How to set up WeChat automatic reply in python

Sometimes when we are busy, we can set up WeChat automatic reply, so that we will not ignore other people's information and save time. How to implement it specifically? The example in this article shares with you the specific implementation of WeChat automatic reply in python Code for your reference.

The specific content is as follows

Pre-installed:

python2.x or 3.x

pycharm

pipinstallitchatpillow

Create a new file on the desktop called newYear.py file

Open it and use the pyCharm software you just downloaded

Copy the following code:

p>

#encoding=utf8

importitchat,time,re

fromitchat.contentimport*

#If the other party sends text, we will give The other party replies with the following:

@itchat.msg_register([TEXT])

deftext_reply(msg):

match=re.search(year,msg[ Text])

ifmatch:

itchat.send((Then I wish you good luck in the Year of the Dog and everything goes well in the new year),msg[FromUserName])

#If the other party sends pictures, audios, videos and shared things, we will respond as follows.

@itchat.msg_register([PICTURE,RECORDING,VIDEO,SHARING])

defother_reply(msg):

itchat.send((Then I wish You have good luck in the Year of the Dog, and everything goes well in the new year),msg[FromUserName])

itchat.auto_login(hotReload=True)

itchat.run()

This program will always run in the background. It is OK if pycharm is not closed by you or the network is not disconnected.

Things after clicking Run:

①The QR.png pop-up image appears

②Use WeChat to scan the code to log in, provided that you log out of the previous computer Log in with WeChat, otherwise there will be no response.

③After logging in successfully, you can let your relatives and friends test it.