import itchat
import requests as rq
@itchat.msg_register(itchat.content.TEXT)
def reply_msg(msg):
info = msg['Content'].encode('utf-8')
api_url = 'http://openapi.tuling123.com/openapi/api/v2'
data = {
"reqType": 0,
"perception": {
"inputText": {
"text": str(info)
}
},
"userInfo": {
"apiKey": "填入图灵机器人apikey",
"userId": "442534"
}
}
headers = {
'Content-Type': 'application/json',
'Host': 'openapi.tuling123.com',
'User-Agent': 'Mozilla/5.0 (Wi`ndows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3486.0 '
'Safari/537.36 '
}
result = rq.post(api_url, headers=headers, json=data).json()
itchat.send_msg(result['results'][0]['values']['text'], msg['FromUserName'])
if __name__ == '__main__':
itchat.auto_login(hotReload=True)
itchat.run()
用python将自己微信变成机器人
最新推荐文章于 2023-09-23 17:06:02 发布