我是靠谱客的博主 害羞柠檬,这篇文章主要介绍7行python代码实现微信聊天自动回复,现在分享给大家,希望可以做个参考。

##7行python代码实现微信聊天自动回复

需要安装wxpy模块
安装方法:pip install wxpy

根据需要可自己注册图灵机器人,获取api_key
下面的代码可以直接使用。

可以将程序代码打包成exe(pyinstaller 文件名.py -F)存放在电脑中,方便使用。

#代码

from wxpy import *
bot = Bot(cache_path=True)
tuling = Tuling(api_key='4a0488cdce684468b95591a641f0971d')
@bot.register()
def auto_reply(msg):
tuling.do_reply(msg)
embed()

指定聊天对象

from wxpy import *
turing = Tuling(api_key='4a0488cdce684468b95591a641f0971d')
bot = Bot()
#只跟某一个好友聊天
nc=input("输入好友昵称:")
xianding = bot.friends().search(nc)
@bot.register(chats=xianding)
def communite(msg):
turing.do_reply(msg)
embed()

指定聊天群

from wxpy import *
turing = Tuling(api_key='你的apikey')
bot = Bot()
#只在某个群内聊天
xianding = bot.groups().search('群名称')
@bot.register(chats=xianding)
def communite(msg):
turing.do_reply(msg)
bot.join()

最后

以上就是害羞柠檬最近收集整理的关于7行python代码实现微信聊天自动回复的全部内容,更多相关7行python代码实现微信聊天自动回复内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(128)

评论列表共有 0 条评论

立即
投稿
返回
顶部