简介
wechaty-puppet-bridge 是一个虚拟的Wechaty Puppet,实际上它只是一个桥接服务,它将GitHub中开源的微信机器人桥接到Wechaty 如果你想方便且高效的使用免费的微信机器人,那么它是一个很好的选择,它不需要token同时又能使用Wechaty进行聊天机器人开发
快速开始
- 安装依赖
npm i wechaty-puppet-bridge
- 示例代码
import {
WechatyBuilder,
log,
} from 'wechaty'
import { FileBox } from 'file-box'
import { PuppetBridge } from 'wechaty-puppet-bridge'
async function onLogin (user) {
log.info('onLogin', '%s login', user)
const roomList = await bot.Room.findAll()
console.info('room count:', roomList.length)
const contactList = await bot.Contact.findAll()
console.info('contact count:', contactList.length)
}
async function onMessage (message) {
log.info('onMessage', JSON.stringify(message))
// 1. send Image
if (/^ding$/i.test(message.text())) {
const fileBox = FileBox.fromUrl('https://wechaty.github.io/wechaty/images/bot-qr-code.png')
await message.say(fileBox)
}
// 2. send Text
if (/^dong$/i.test(message.text())) {
await message.say('dingdingding')
}
}
const puppet = new PuppetBridge({
nickName: '大师' // 登录微信的昵称
})
const bot = WechatyBuilder.build({
name: 'ding-dong-bot',
puppet,
})
bot.on('login', onLogin)
bot.on('message', onMessage)
bot.start()
.then(() => {
return log.info('StarterBot', 'Starter Bot Started.')
})
.catch(console.error)
与puppet-xp对比
| 项目 | puppet-xp | puppet-bridge |
|---|---|---|
| 注入 | ⭐⭐⭐ 不需要 | ⭐⭐⭐ 不需要 |
| 功能 | ⭐⭐⭐ 基于cixingguangming55555/wechat-bot项目 | ⭐⭐⭐ 基于cixingguangming55555/wechat-bot项目 |
| 梯子 | ⭐ 依赖frida,国内网络无法安装,需使用梯子 | ⭐⭐⭐ 不需要,下载funtool_wx=3.9.2.23.exe即可 |
| 启动 | ⭐⭐⭐ 直接运行nodejs程序 | ⭐⭐ 需先手动启动funtool_wx=3.9.2.23.exe |
| 环境 | ⭐⭐⭐ nodejs | ⭐⭐ nodejs + funtool_wx=3.9.2.23.exe |
开源机器人支持
- ✅ Wechat-bot 馈人玫瑰之手,历久犹有余香 cixingguangming55555/wechat-bot
- ✅ wxbot - 微信聊天机器人 jwping/wxbot
- ✅ wxhelper - PC端微信逆向学习 ttttupup/wxhelper