用30行代码做一个微信智障机器人

in cn •  6 years ago 

头图.png

起因是某天早上看到这样一条朋友圈:

朋友圈.jpg

微信啥时候还有会员了?可怕,花里胡哨,这是要往QQ的方向发展吗。还是 Telegram 比较存粹。

《连IS恐怖组织都在使用,最安全的即时通讯软件——Telegram》https://mr96.me/441.html

(博客:https://Mr96.me

图片中看到他是自动回复,做个机器人不就完了吗?于是开始查资料,发现已经有很多现成的代码,而且调用第三方 “图灵机器人” 更是不需要再弄语料库之类的,代码精简,去掉注释行和空格也就20多行代码.

第一步:安装环境

运行 Python 程序需要先安装 python 环境

直接在官网 https://www.python.org/ 下载

python 下载.png

运行安装程序,选择自定义安装

安装1.png

然后点击 Next 下一步,来到下一个页面把这两个选项勾上。

安装2.png

install 安装,等待安装完成。

调出 cmd 命令窗口 执行:

python -V

检测版本.png

显示 Python 的版本信息就安装成功了

安装需要的库 执行:

pip install itchat requests

安装库.png

第二步:运行机器人脚本

下载脚本:微信机器人https://pan.mr96.me/index.php/s/k9moa5A3z37DZxD
(调用的第三方图灵机器人,可以自己申请一个更换api key,也可以直接用我这个)

到下载目录,shift + 鼠标右键 打开命令窗口

命令窗口.png

执行命令: python + 文件名

python weixin_Robot.py

扫描二维码登录微信就可以了

登录成功.png

显示登录成功 开启自动回复,看下效果:

房东对话.jpg
Screenshot_20181228-000944__01.jpg

图灵提供的技能拓展还是不少 自行测试:

功能1.png
功能2.png
功能3.png

注:18年申请的微信号无法使用机器人,因为18年的微信不支持网页端登录。

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hello @mr96! This is a friendly reminder that you have 3000 Partiko Points unclaimed in your Partiko account!

Partiko is a fast and beautiful mobile app for Steem, and it’s the most popular Steem mobile app out there! Download Partiko using the link below and login using SteemConnect to claim your 3000 Partiko points! You can easily convert them into Steem token!

https://partiko.app/referral/partiko

Congratulations @mr96! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made more than 10 upvotes. Your next target is to reach 50 upvotes.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @mr96! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!