import itchat
import requests
import re
@itchat.msg_register(itchat.content.TEXT)
def print_content(msg):
user = re.findall("'PYQuanPin': '(.*?)'",str(msg))
message = msg['Text']
print('{}的訊息:{}'.format(user[0],message))
url = 'http://api.qingyunke.com/api.php?key=free&appid=0&msg=' + message
text = requests.get(url).json()
print("機器人回應:%s"%text['content'])
itchat.send(text['content'],msg['FromUserName'])
itchat.auto_login()
itchat.run()
本作品採用《CC 協議》,轉載必須註明作者和本文連結