npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@re-ai/wechaty-puppet-gewe

v0.2.11

Published

GeWe Puppet for Wechaty

Downloads

57

Readme

Wechaty Puppet GeWe

这是一个基于 GeWe 云 API 的 Wechaty Puppet 实现,将 GeWe 开放平台的能力与 Wechaty 框架连接,使开发者可以通过统一的 Wechaty 接口操作微信。

安装

npm install @re-ai/wechaty-puppet-gewe

更新日志

使用方法

import { WechatyBuilder } from 'wechaty';
import { PuppetGeWe } from '@re-ai/wechaty-puppet-gewe';
import * as qrcode from 'qrcode-terminal';
import { types } from 'wechaty-puppet';
import { FileBox } from 'file-box';

// 创建 Puppet 实例
const puppet = new PuppetGeWe({
  name: 'gewe-bot',
  token: '你的GeWe Token',
  webhookUrl: 'http://your-domain.com',
  webhookPort: 8878, // 如果有公网地址,可以设置webhook
  debug: true, // 开启调试模式
  
  // SQLite 配置(可选)
  sqliteConfig: {
    dbPath: './data', // 数据库文件存储目录,会自动添加wxid作为文件名
    useWAL: true, // 启用WAL模式提高性能
    inMemory: false // 是否使用内存数据库(仅用于测试)
  },
});

// 创建 Wechaty 实例
const bot = WechatyBuilder.build({
  name: 'gewe-bot',
  puppet,
});

// 注册扫码事件处理函数
bot.on('scan', (qrcodeUrl: string, status: types.ScanStatus) => {
  console.log(`收到二维码,状态: ${status}`);
  
  // 在控制台显示二维码
  if (qrcodeUrl) {
    if (qrcodeUrl.startsWith('data:image')) {
      console.log('请扫描二维码登录 (请在微信中扫码)');
    } else {
      qrcode.generate(qrcodeUrl, { small: true });
      console.log('请扫描二维码登录 (请在微信中扫码)');
    }
  }
});

// 注册登录事件处理函数
bot.on('login', async (user) => {
  console.log(`用户 ${user.name()} (${user.id}) 已登录`);
  const avatar = await user.payload?.avatar;
  console.log(`用户头像: ${avatar}`);
});

// 注册消息事件处理函数
bot.on('message', async (message) => {
  console.log(`收到消息: ${message.text()}`, message.type());

  // 如果收到 "ping",回复 "pong"
  if (message.text() === 'ping') {
    await message.say('pong');
    return;
  }

  // 如果收到 "图片",发送一张图片
  if (message.text() === '图片') {
    const fileBox = FileBox.fromUrl(
      'https://wechaty.js.org/img/wechaty-logo.svg',
      'wechaty-logo.svg',
    );
    await message.say(fileBox);
    return;
  }
});

// 注册好友请求事件处理函数
bot.on("friendship", async (friendship) => {
  console.log(`收到好友请求: ${friendship.hello()}`);
  friendship.accept();
});

// 启动机器人
bot.start()
  .then(() => console.log('机器人已启动...'))
  .catch(console.error);

配置选项

| 选项 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | token | string | 是 | GeWe API 访问 token | | appId | string | 否 | 保存的appId,用于重复登录 | | regionId | string | 否 | 微信登录地区ID,默认为440000(广东省) | | webhookUrl | string | 否 | Webhook 回调地址,用于接收 GeWe 平台的事件通知 | | webhookPort | number | 否 | Webhook 服务器端口,默认为 8878 | | timeout | number | 否 | API 请求超时时间(毫秒),默认为 30000 | | retries | number | 否 | API 请求重试次数,默认为 3 | | debug | boolean | 否 | 是否开启调试模式,默认为 false | | sqliteConfig | object | 否 | SQLite 数据库配置,详见下表 |

SQLite 配置选项

| 选项 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | dbPath | string | 否 | 数据库文件路径,默认为 './gewe-store.db' | | useWAL | boolean | 否 | 是否启用WAL模式,默认为 true | | inMemory | boolean | 否 | 是否在内存中运行数据库(用于测试),默认为 false |

功能

  • 消息收发(文本、图片、文件等)
  • 联系人管理
  • 群组管理
  • 媒体文件处理
  • 好友请求处理

开发

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建
npm run build

# 运行示例
npm start

注意事项

  1. 请使用正规注册且已实名认证的微信账号
  2. 避免频繁切换登录设备
  3. 不要使用本项目进行违规操作,以免封号
  4. 合理控制消息发送频率
  5. 避免大量相同内容的消息

许可证

ISC