python实现微信机器人自动回复
2017-11-12 21:14
926 查看
import requests import itchat #这是一个用于微信回复的库 KEY = '8edce3ce905a4c1dbb965e6b35c3834d' #这个key可以直接拿来用 # 向api发送请求 def get_response(msg): apiUrl = 'http://www.tuling123.com/openapi/api' data = { 'key' : KEY, 'info' : msg, 'userid' : 'pth-robot', } try: r = requests.post(apiUrl, data=data).json() return r.get('text') except: return # 注册方法 \@itchat.msg_register(itchat.content.TEXT) def tuling_reply(msg): # 为了保证在图灵Key出现问题的时候仍旧可以回复,这里设置一个默认回复 defaultReply = 'I received: ' + msg['Text'] # 如果图灵Key出现问题,那么reply将会是None reply = get_response(msg['Text']) # a or b的意思是,如果a有内容,那么返回a,否则返回b return reply or defaultReply # 为了让修改程序不用多次扫码,使用热启动 itchat.auto_login(hotReload=True) itchat.run()
相关文章推荐
- python实现微信自动回复及接入聊天机器人等功能
- Python实现微信自动回复(机器人版本)
- Python实现微信自动回复机器人(简单)
- Python实现微信自动回复机器人
- 微信接入机器人实现对别人消息和群at消息的自动回复
- python之微信自动回复机器人
- python itchat实现微信自动回复
- Python实现微信自动拉群机器人
- 利用python微信库itchat实现微信自动回复功能
- 用python itchat写一个微信机器人自动回复
- python itchat实现微信自动回复的示例代码
- python实现微信自动回复功能
- 利用Python实现微信自动回复
- python 实现微信自动回复(自动聊天)
- 豆瓣机器人 自动加入/退出小组、自动在小组发帖/删帖、自动回复 Python实现代码 豆瓣爬虫
- Python包装网页微信API并实现简单自动回复
- python实现微信消息群发和微信自动回复
- Python写一个微信自动回复的机器人
- python实现微信小程序自动回复
- JAVA实现 springMVC方式的微信接入、实现消息自动回复实例