Coder Social home page Coder Social logo

wechat-robot's Introduction

使用 nodejs + wecharty 打造你的个人微信机器人

Powered by Wechaty Wechaty开源激励计划

好消息,web端协议可以使用啦!!!

重磅:使用 UOS 微信桌面版协议登录,wechaty 免费版 web 协议重放荣光

注 1: 本文需要微信账号能通过 web 端登录验证,如果网页版微信无法登陆,请参考如下 iPad 协议的开源仓库链接:

https://github.com/isnl/wechat-robot-ipad

注 2: 从 2017 年 6 月下旬开始,使用基于 web 版微信接入方案存在大概率的被限制登陆的可能性。 主要表现为:无法登陆 Web 微信,但不影响手机等其他平台。 验证是否被限制登陆: https://wx.qq.com 上扫码查看是否能登陆。 更多内容详见:

Can not login with error message: 当前登录环境异常。为了你的帐号安全,暂时不能登录 web 微信。

克隆代码

git clone [email protected]:isnl/wechat-robot.git

目录结构

  • config存放公共配置以及superagent请求相关配置
  • imgs存放相关图片
  • listeners存放机器人初始化后一系列 callback
    • on-friendship.js 处理好友请求
    • on-login.js 处理登录
    • on-message.js 处理用户消息、群消息
    • on-scan.js 处理登录二维码
  • schedulenode-schedule进行了封装
  • superagent 存放所有的数据请求、接口封装都在此
  • utils 公用方法的封装
  • app.js 入口文件

主要依赖

安装依赖

依赖中需要安装chromium,使用 npm 会下载失败或者很慢,国内嘛你懂得

强烈推荐 使用cnpm安装依赖

cnpm install  //npm install

实在不想用 cnpm 可以将 npm 源切换成淘宝源

npm config set registry https://registry.npm.taobao.org
npm config set disturl https://npm.taobao.org/dist
npm config set puppeteer_download_host https://npm.taobao.org/mirrors

修改config配置

打开config/index.js 文件,将里面的配置改为自己的。

修改天行接口配置

天行 api 官网 :https://tianapi.com/
注册成功后,申请以下接口:

注册后请打开superagent/index.js,将顶部APIKEY改为自己天行 api 的key即可

其他免费接口可随意申请,自行扩展~

运行测试

cnpm start //npm start

此工程有以下几个功能:

  • 热更新,修改代码后免重启,便于在线调试。
  • 新增全国肺炎、各省市肺炎数据,按关键字回复即可。
  • 添加转大小写、颜色的 rgb 与 base64 互转等开发者常用小工具。
  • 每日毒鸡汤、神回复、英语一句话、实时天气查询。
  • 自动同意好友请求
  • 发送加群指令自动邀请好友进群。

演示图片

底层 api 基于 wechaty

更多微信消息、群消息、好友、对话等相关 api 可查阅官方文档 wechaty 官方文档

wechat-robot's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.