Use the python library itchat to implement the automatic reply function, pythonitchat
Preface
On the forum, you can see Python login and automatic sign-in to learn about a new Python Library: itchat.
Using the Python library itchat, You can implement multiple functions such as automatic reply. It is so fun that you can't stop it at all. Especially when you are not familiar with computers, you have a sense of accomplishment. Haha !!
The Code is as follows:
# Coding = utf8import requestsimport itchatKEY = 'hangzhou' def get_response (msg): apiUrl = 'HTTP: // www.tuling123.com/openapi/api'data = {'key': key, 'info': msg, 'userid': 'wechat-robot ',} try: r = requests. post (apiUrl, data = data ). json () return r. get ('text') Comment T: return@itchat.msg _ register (itchat. content. TEXT) def tuling_reply (msg): defaultReply = 'I have ED:' + msg ['text'] reply = get_response (msg ['text']) return reply or defaultReplyitchat. auto_login (hotReload = True) itchat. run ()
Install itchat to run the above program and interact with the Turing robot.
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.