CNode

新玩具!微信Nodejs版,可编程控制微信消息

分享
Iifeiteng发布于10 年前最后回复9 年前16 回复8883 浏览0 收藏

前言

过年的时候加入了泰稳大大主持的精进学堂 读书运动群,并主动请缨进入了策划组,因为要实行积分制,所以作为coder的我提出做一个群机器人,于是便有了这个项目,我也是近一阵才开始分析网页版微信的各种参数,所以还不太健全,欢迎pr

安装

npm install weixinbot --save

实例

// Require Nodejs v4+

// index.js
const Weixinbot = require('weixinbot')

// will send qrcode to your email address
const bot = new Weixinbot({ receiver: 'your@email.com' })

// will emit when bot fetch a new qrcodeUrl
bot.on('qrcode', (qrcodeUrl) => {
  console.log(qrcodeUrl)
})

bot.on('friend', (msg) => {
  console.log(msg.Member.NickName + ': ' + msg.Content)
  bot.sendText(msg.FromUserName, 'Got it')
})

bot.run()

运行

# 建议打开DEBUG标志,以便查看详细信息
DEBUG=weixinbot node index.js

项目地址

查看回复

回复 (16)

I
i5ting#1·10 年前

挺好的,写的比较规范,就是单个文件内代码太多,适当拆分一下

R
reverland#2·10 年前

微信干脆开放api好了2333 @stonexer 来看看

S
stonexer#3·10 年前

@reverland 哈哈哈哈,坐等第三方客户端

R
reverland#4·10 年前
S
stonexer#5·10 年前

@reverland 嗯啊,那个看上去是在微信 webapp 基础上的吧。

Y
yuanzhhh#6·10 年前

mark

N
naruto900814#7·10 年前

mark

L
leizongmin#8·10 年前

接收好友消息时有问题,比如有时候消息内容msg.Content是这样的:

&lt;msg&gt;<br/>&lt;op id='5'&gt;<br/>&lt;username&gt;919338054@chatroom&lt;/username&gt;<br/>&lt;/op&gt;<br/>&lt;/msg&gt;

应该是没有正确解析XML导致的。

L
leizongmin#9·10 年前
const qrcode = require('qrcode-terminal');

// 直接在控制台上打印二维码
bot.on('qrcode', (qrcodeUrl) => {
  qrcode.generate(qrcodeUrl.replace('/qrcode/', '/l/'), console.log);
});
X
XGHeaven#10·10 年前

挺有意思的

来自酷炫的 CNodeMD

I
ifeiteng#12·10 年前

@leizongmin +1

A
alsotang#13·10 年前

好东西

I
imfly#14·10 年前

不错

Y
YingjieChen#15·9 年前

群消息呢??

F
fightAndLearn#16·9 年前

mark From Noder

参与回复
登录后即可参与回复。登录