pip install itchat
来安装)pip install pymongo
来安装)代码:
import re import itchat import pymongo import requests from urllib.parse import quote
其中:
import pymongo
请根据自己的情况导入{face:14}
这种)s = requests.Session() msg_url = "http://api.qingyunke.com/api.php?key=free&appid=0&msg={message}" client = pymongo.MongoClient('localhost', 27017) db = client['wechat'] collection = db['wechat'] @itchat.msg_register(itchat.content.TEXT) def _(msg): print(msg) collection.insert_one(msg) if msg.toUserName == "filehelper": r = s.get(msg_url.format(message=quote(msg['Text']))) print(r.json()) msg.user.send(re.sub('\{.*?\}', '', r.json()["content"])) itchat.auto_login(hotReload=True) itchat.run()
其中:
import re import itchat import pymongo import requests from urllib.parse import quote s = requests.Session() msg_url = "http://api.qingyunke.com/api.php?key=free&appid=0&msg={message}" client = pymongo.MongoClient('localhost', 27017) db = client['wechat'] collection = db['wechat'] @itchat.msg_register(itchat.content.TEXT) def _(msg): print(msg) collection.insert_one(msg) if msg.toUserName == "filehelper": r = s.get(msg_url.format(message=quote(msg['Text']))) print(r.json()) msg.user.send(re.sub('\{.*?\}', '', r.json()["content"])) itchat.auto_login(hotReload=True) itchat.run()
数据库里:
(此为部分数据)