0.0.8 • Published 2 years ago

pbbot v0.0.8

Weekly downloads
54
License
ISC
Repository
github
Last release
2 years ago

使用说明

创建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

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago