# pbbot

> JS/TS 开发QQ机器人

Latest version **0.0.8** (published 2021-12-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install pbbot
pnpm add pbbot
yarn add pbbot
bun add pbbot
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2021-12-28 |
| First published | 2021-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.8 MB |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | lz1998 |
| Maintainers | lz1998 |
| Keywords | bot, qqbot, cqhttp, protobufbot, pbbot, qqrobot, mirai |

## Links

- npm: https://www.npmjs.com/package/pbbot
- Repository: https://github.com/ProtobufBot/js-pbbot
- Issues: https://github.com/ProtobufBot/js-pbbot/issues
- npm.io page: https://npm.io/package/pbbot

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^7.5.6
- [long](https://npm.io/package/long.md) ^4.0.0
- [lru-cache](https://npm.io/package/lru-cache.md) ^6.0.0
- [protobufjs](https://npm.io/package/protobufjs.md) ^6.10.2
- [@types/long](https://npm.io/package/@types/long.md) ^4.0.1

## Recent versions

- 0.0.8 (latest) — 2021-12-28
- 0.0.7 — 2021-12-06
- 0.0.6 — 2021-08-04
- 0.0.5 — 2021-03-25
- 0.0.4 — 2021-02-22
- 0.0.3 — 2021-02-05
- 0.0.2 — 2021-01-31
- 0.0.1 — 2021-01-26

## README

# 使用说明

创建nodejs项目

安装`npm install pbbot`

代码
```javascript
let {createBotServer, EventHandler, Msg} = require('pbbot')

let port = 8081

console.log("开始启动")

EventHandler.handleConnect = async (bot) => {
  console.log(`机器人已连接: ${bot.botId.toString()}`)
}

EventHandler.handleDisconnect = async (bot) => {
  console.log(`机器人已断开: ${bot.botId.toString()}`)
}

EventHandler.handlePrivateMessage = async (bot, event) => {
  let rawMsg = event.rawMessage
  let userId = event.userId
  console.log(`收到私聊消息，发送者: ${userId.toString()}，内容: ${rawMsg}`)
  await bot.sendPrivateMessage(event.userId, "hello world")
}

EventHandler.handleGroupMessage = async (bot, event) => {
  let rawMsg = event.rawMessage
  let userId = event.userId
  let groupId = event.groupId
  console.log(`收到群聊消息，群号: ${groupId.toString()}，发送者: ${userId.toString()}，内容: ${rawMsg}`)
  if (rawMsg !== "hello") return
  let msg = Msg.builder().tts("hello world")
  await bot.sendGroupMessage(groupId, msg)
}

createBotServer(port)

console.log(`启动成功，端口：${port}`)
```

运行[GMC](https://github.com/protobufbot/Go-Mirai-Client/releases)，登陆机器人QQ

---
_Source: https://npm.io/package/pbbot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
