1.0.19 • Published 8 months ago

wxbot-puppet-bridge v1.0.19

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

WxBot Puppet Bridge

基于 wechaty 协议的微信机器人桥接服务。

已支持的微信机器人协议:

一、安装

npm install wxbot-puppet-bridge

二、功能列表

没有你想要的功能,可以提 issue 优先处理。

功能列表已支持
基础功能(二维码登录、登录回调、消息监听)
消息体解析(文本、图片、视频、表情、文件、小程序卡片等)
发消息(文本、图片、文件、视频、联系人、链接、小程序卡片)
联系人(添加/删除/修改联系人、获取联系人列表、搜索用户等)
群事件(加入群聊、退出群聊、修改群名称、群邀请)
群操作(创建/退出/解散群聊、修改群名称、添加/删除群成员、发布群公告、群邀请验证)
标签管理(标签列表、添加成员标签、移除成员标签、创建标签、删除标签)

适配中:

  • 转发消息(兼容多种消息格式);

三、如何使用

1. bot

iimport { WechatyBuilder, ScanStatus, Message, log, types } from 'wechaty';
import qrTerm from 'qrcode-terminal';
import { FileBox } from 'file-box';
import { WeChatSdkPuppetBridge_3_9_10_19 as PuppetBridge } from 'wxbot-puppet-bridge';
import { jsonStringify, createDir } from 'wxbot-puppet-bridge/dist/shared';

async function main() {
  const puppet = new PuppetBridge({
    apiUrl: 'http://127.0.0.1:8888',
    protocol: 'ws'
  });

  const bot = WechatyBuilder.build({ name: 'wechatsdk-bot', puppet });

  bot.on('scan', onScan);

  bot.on('login', user => {
    log.info('Bot use login: ', jsonStringify(user));
  });

  bot.on('ready', () => {
    log.info('Bot is ready');
  });

  bot.on('message', onMessage);

  bot.on('logout', user => {
    log.info('Bot user logout: ', jsonStringify(user));
  });

  bot.on('error', error => {
    log.error('Bot error:', error.message);
  });

  await bot.start();
}

main()
  .then(() => log.info('StarterBot', 'Ready'))
  .catch(console.error);

2. hack

wechaty puppet 功能会以 puppet[method] 的方式提供,例如:

async function main() {
  const puppet = new PuppetBridge({
    apiUrl: 'http://127.0.0.1:8888',
    protocol: 'ws'
  });
  
  // 1. create tag
  // const tag = await puppet.createTag('test-tag');
  // log.info('Tag created: ', jsonStringify(tag));

  // 2. delete tag
  // await puppet.deleteTag('59');
  // log.info('Tag deleted successfully');

  // 3. get tag members
  // const memberIds = await puppet.getTagMemberList('56');
  // log.info('Tag members: ', jsonStringify(memberIds));

  // 4. get tags of contact
  const tags = await puppet.getTags();
  log.info('Contact tags: ', jsonStringify(tags));
}

三、参考

1.0.19

8 months ago

1.0.18

10 months ago

1.0.17

10 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago