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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tanebi

v1.0.0

Published

PC NTQQ Debugging Facade in TypeScript

Readme

面向 PC NTQQ 的调试门面

tanebi 是一个用 TypeScript 编写的 PC NTQQ 调试门面,提供一组 TypeScript API,用来驱动和调试 PC NTQQ 协议能力。

初始化

tanebi 并不能单独用于调试 PC NTQQ,你需要使用已有的或自行实现一个 PacketClient

interface PacketClient {
  send(packet: OutgoingSsoPacket): Promise<IncomingSsoPacket>;
  onPush(handler: (packet: IncomingSsoPacket) => void): void;
  offPush(handler: (packet: IncomingSsoPacket) => void): void;
  getSelfInfo(): Promise<SelfInfo>;
}

此外,还需要准备一个 AppInfo,包含了调试所使用或模拟的的客户端的相关信息,例如平台、版本号、App ID 等。在得到了一个 PacketClient 实例并且准备好了 AppInfo 之后,就可以创建一个 Bot 实例了:

const packetClient = new YourPacketClient(/* ... */);
const appInfo = {
  /* ... */
};
const bot = new Bot(appInfo, packetClient);

[!note]

如果难以确定 AppInfo 中的某些字段的值,可以使用 BundledAppInfo 中提供的预设来初始化 Bot 实例。但需要注意,对于部分依赖 AppInfo 具体内容的调试场景,使用与实际客户端不符的 AppInfo 可能会导致操作失败。

Bot 假定在调用构造器时客户端尚未上线。当你确保了客户端已经上线并且 PacketClient 已经准备好发送和接收数据包之后,就可以调用初始化方法了:

await bot.initialize();

initialize 方法会完成一系列的准备工作,包括但不限于:

  • 初始化好友列表和群列表
  • 获取并缓存 uin <-> uid 映射关系
  • 开始监听推送数据包

调用业务操作

Bot 提供了一系列 API 来调用 PC NTQQ 的业务操作。下面是一些示例:

const friends = await bot.getFriends();
const groups = await bot.getGroups();
const members = await bot.getGroupMembers(groupUin);

const uid = await bot.getUidByUin(userUin, groupUin);
const uin = await bot.getUinByUid(uid);

const history = await bot.getGroupHistoryMessages(groupUin, 20);
const forwarded = await bot.getForwardedMessages(resId);
const downloadUrl = await bot.getDownloadUrl(resourceId);

await bot.setGroupName(groupUin, "新的群名");
await bot.setGroupMemberCard(groupUin, memberUin, "新的群名片");
await bot.setGroupMemberMute(groupUin, memberUin, 60);
await bot.setGroupWholeMute(groupUin, true);
await bot.setGroupMessageReaction(groupUin, sequence, "66", 1, true);

要发送消息,可以调用 Bot.sendFriendMessageBot.sendGroupMessage 方法:

await bot.sendFriendMessage(friendUin, [
  { type: "text", text: "Hello, " },
  { type: "face", faceId: 14 },
]);

await bot.sendGroupMessage(groupUin, [
  {
    type: "mention",
    uin: memberUin,
    name: "Alice",
  },
  {
    type: "text",
    text: " 你好",
  },
  {
    type: "image",
    data: imageBuffer,
    format: ImageFormat.PNG,
    width: 640,
    height: 480,
  },
]);

监听事件与消息

可以使用 onEvent / offEvent 监听 BotEvent 中定义的事件:

bot.onEvent("messageReceive", (event) => {
  const message = event.message;
  // Do something with the incoming message
});

bot.onEvent("messageRecall", (event) => {
  console.log(event.scene, event.peerUin, event.messageSeq);
});

bot.onEvent("groupMemberIncrease", (event) => {
  console.log(event.groupUin, event.userUin);
});

要监听消息事件,可以使用 Bot.onMessage 方法,这是 onEvent("messageReceive") 的包装,直接提供了消息内容:

bot.onMessage((message) => {
  // Do something with the incoming message
});

日志

可以通过 onLog / offLog 监听内部日志:

bot.onLog((log) => {
  console.log(`[${log.level}] ${log.module}: ${log.message}`);
});

Special Thanks

tanebi 离不开以下前辈项目及贡献者:

项目名称源自日语「種火」(たねび),意为火种,向所有先前与当下的 QQ 协议实现致敬。无论是否还在活跃维护,这些项目都是点亮了今天的 QQ Bot 开发的当之无愧的“火种”。