import itchat
import requests
itchat.auto_login(hotReload=True)
apiUrl = "http://openapi.tuling123.com/openapi/api/v2"
def get_info(message):
data = {
"key":"7ad120888a3d45fb843534a5aee4da46" ,
"info":message ,
"userid":"robot"
}
try:
r = requests.post(apiUrl, data=data).json()
info = r["text"]
print("robot reply:%s" %info)
return info
except:
return
@itchat.msg_register(itchat.conyent.TEXT)
def auto_reply(msg):
defaultReply = "我知道了"
realFriend = icthat.search_friends( name ="铭州")
realFriendsName =realFriend[0]["UserName"]
print("message:%s"%msg["Text"])
reply = get_info(msg["Text"])
if msg["FromUserName"] == realFriendsName:
itchat.send(reply, toUserName=realFriendsName)
itchat.run()
为什么会报错KeyError: 'User'
最新推荐文章于 2022-07-16 17:48:32 发布