pbbot
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

使用说明

创建nodejs项目

安装npm install pbbot

代码

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,登陆机器人QQ

Package Sidebar

Install

npm i pbbot

Weekly Downloads

0

Version

0.0.8

License

ISC

Unpacked Size

1.9 MB

Total Files

19

Last publish

Collaborators

  • lz1998