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.