#!/usr/bin/env python
#-*-coding:utf-8-*-@Author: WUJF @Time: 2018/9/5 17:42
Import requests
Import Itchat
Import sys
Reload (SYS)
sys.setdefaultencoding (' UTF8 ')
def get_response (_info):
Print (_info) # Messages sent from a friend
Api_url = ' Http://www.tuling123.com/openapi/api ' # turing man URL
data = {
' k EY ': ' 7920999ef510477d93344ff2106e96ef ', # If this apiKey is not available, register
' info ': _info, # This is the message we received from a friend and forwarded to the Turing Man br> ' userid ': ' Wechat-robot ', # Here's what you want to change.
}
R = Requests.post (Api_url, Data=data). JSON () # Put the data Send
Print (R.get (' text)) # Robot reply message to friend
return R
@itchat. Msg_register (Itchat.content.TEXT)
Def t Ext_reply (msg):
Return Get_response (msg["text"]) ["text"]
If __name__ = = ' __main__ ':
Itchat.auto_ Login () # hotreload = True, keep online, the next run code can be automatically logged in hotreload=true (to be removed on Linux)
Itchat.run ()
is available on Windows, put on Linux error, Remove the
Itchat.auto_login (), no error, but does not work, to find the cause of
Python interacts with the Turing Machine 2 (Build smarter Robots)