Using Python micro-Library itchat to realize WeChat auto-reply function

Source: Internet
Author: User
Recently found a special Fun Python library itchat, can implement automatic reply and other functions, the following this article mainly introduces the use of Python library itchat to implement the automatic response function of the relevant information, the need for friends can refer to the study, the following to see together.

Objective

See a new Python library by signing in with Python and automating check-ins on the forum: itchat

The use of Python library itchat, can realize the automatic reply and other functions, fun to the basic stop Ah, especially flirt do not understand the computer, especially a sense of accomplishment, haha!!

The code is as follows:

#coding =utf8import requestsimport itchatkey = ' 8edce3ce905a4c1dbb965e6b35c3834d ' 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 ') except:  Return@itchat.msg_register ( Itchat.content.TEXT) def tuling_reply (msg): Defaultreply = ' I Received: ' + msg[' text '] reply = get_response (msg[' text ']) r Eturn reply or Defaultreplyitchat.auto_login (hotreload=true) Itchat.run ()

Install Itchat can run the above program, to achieve the interaction with the Turing man.

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.