You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@tencent-connect/bot-node-sdk

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencent-connect/bot-node-sdk

QQ频道机器人NodeSDK

Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
23
9.52%
Maintainers
4
Weekly downloads
 
Created
Source

QQ频道机器人bot-node-sdk

用于开发QQ频道机器人

使用文档

https://bot.q.qq.com/wiki/develop/nodesdk/

使用方式

1、安装

npm install --save-dev @tencent-connect/bot-node-sdk

2、引用

import { createOpenAPI, createWebsocket } from '@tencent-connect/bot-node-sdk';

3、配置入参

const botConfig = {
  appID: '',
  token: '',
  shards: [0, 1],
};

appID: QQ频道机器人开发者管理端申请机器人时获取到的机器人ID

token: QQ频道机器人开发者管理端申请机器人时获取到的机器人token

shards: Websocket分片信息,暂时默认为1,即为单例模式,后续会进行优化

4、方法引用

const client = createOpenAPI(botConfig);
const ws = createWebsocket(botConfig);

// 消息监听
ws.on('Event_Wss', (eventData) => {
  console.log('[Event_Wss] 事件接收 :', eventData);
})
ws.on('READY', (eventData) => {
  console.log('[READY] 事件接收 :', eventData);
})
ws.on('ERROR', (eventData) => {
  console.log('[ERROR] 事件接收 :', eventData);
})
ws.on('GUILDS', (eventData) => {
  console.log('[GUILDS] 事件接收 :', eventData);
})
ws.on('GUILGUILD_MEMBERSDS', (eventData) => {
  console.log('[GUILGUILD_MEMBERSDS] 事件接收 :', eventData);
})
ws.on('DIRECT_MESSAGE', (eventData) => {
  console.log('[DIRECT_MESSAGE] 事件接收 :', eventData);
})
ws.on('AUDIO_ACTION', (eventData) => {
  console.log('[AUDIO_ACTION] 事件接收 :', eventData);
})
ws.on('AT_MESSAGES', (eventData) => {
  console.log('[AT_MESSAGES] 事件接收 :', eventData);
})

如何贡献

本地运行

npm run dev
npm link

cd exmaple

npm link @tencent-connect/bot-node-sdk

调试

npm run example

Keywords

bot-sdk

FAQs

Package last updated on 24 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts