Use the python WeChat library itchat to implement the WeChat automatic reply function, pythonitchat

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.