1 Star 0 Fork 0

关机闹钟/PythonSpiders

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wxpy_demo.py 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
关机闹钟 提交于 2018-09-03 15:35 . 微信自动回复
from wxpy import *
import requests
import json
def robot(param, province, city):
data = {
"reqType": 0,
"perception": {
"inputText": {
"text": param
},
"inputImage": {
"url": param
},
"selfInfo": {
"location": {
"city": city or '上海',
"province": province or '上海',
# "street": "虹漕路"
}
}
},
"userInfo": {
"apiKey": "cd328433aa3b9646743e2abc3d1a2286",
"userId": "6072C7CAF1FE468A8B36FE4DD0F03E92"
}
}
info = json.dumps(data)
res = requests.post('http://openapi.tuling123.com/openapi/api/v2', data=info)
res = json.loads(res.content.decode())
str = ''
results = res['results']
results.reverse()
for item in results:
if item['resultType'] == 'text':
str += item['values']['text'] + '\n'
else:
str += '你要找的都在这:<br>' + item['values']['url']
return str
bot = Bot(cache_path=True)
my_friends = bot.friends(update=True)
@bot.register(my_friends)
def my_friednd_message(msg):
print('[接收]' + str(msg))
try:
sender = bot.user_details(msg.sender)
if msg.type == 'Text': # 除文字外其他消息回复内容
ret = robot(msg.text, sender.province, sender.city)
else:
ret = '可以发文字吗?(#^.^#)[拜托]'
print('[发送]' + ret)
except Exception as e:
print(e)
return ret
# 进入交互式的 Python 命令行界面,并堵塞当前线程
embed()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/shiyilin/PythonSpiders.git
[email protected]:shiyilin/PythonSpiders.git
shiyilin
PythonSpiders
PythonSpiders
master

搜索帮助