python itchat实现微信自动回复的示例代码
作者:第2梦
本篇文章主要介绍了python itchat实现微信自动回复的示例代码,可以实现微信自动回复,有兴趣的可以了解一下
今天在实验楼发现一个特别好玩的,Python 微信库itchat,可以实现自动回复等多种功能,好玩到根本停不下来啊,尤其是调戏调戏不懂计算机的,特别有成就感,哈哈!!
代码如下:
#coding=utf8
import requests
import itchat
KEY = '8edce3ce905a4c1dbb965e6b35c3834d'
def get_response(msg):
apiUrl = 'http://www.tuling123.com/openapi/api'
data = {
'key' : KEY,
'info' : msg,
'userid' : 'wechat-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):
defaultReply = 'I received: ' + msg['Text']
reply = get_response(msg['Text'])
return reply or defaultReply
itchat.auto_login(hotReload=True)
itchat.run()
安装一下 itchat即可跑上面程序,实现与图灵机器人的交互。
更多关于itchat的资料,如下:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
- 10分钟教你用Python实现微信自动回复功能
- python实现微信自动回复功能
- 利用python微信库itchat实现微信自动回复功能
- python实现微信小程序自动回复
- python微信公众号之关键词自动回复
- python实现微信机器人: 登录微信、消息接收、自动回复功能
- Python中re.compile函数的使用方法
- 关于Python中compile() 函数简单实用示例详解
- Python正则表达式re.compile()和re.findall()详解
- Python 正则 re.compile 真的必需吗
- Python中请不要再用re.compile了
- python内置函数compile(),complex()的使用
