Registry / messaging / cq-websocket

cq-websocket

JSON →
library2.1.1jsnpmunverified

A Node.js SDK for developing QQ chatbots via WebSocket, depending on CoolQ and the CQHTTP API plugin. Version 2.1.1 is the latest stable release. It provides automatic connection maintenance, fast response support in message listeners, and automatic retrieval of the bot's QQ number on connection. Differentiators include easy configuration and focus on chatbot development, but it is in beta and known to have issues with Node 10.x and pending CQHTTP API features. Release cadence appears irregular.

npm install cq-websocket
INSTALL
IMPORT
SIG · CQ-WEBSOCKET
C
cq-websocket
messagingjavascriptv2.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CQWebSocket
import CQWebSocket from 'cq-websocket'
const { CQWebSocket } = require('cq-websocket')
Default export, not named. For TypeScript, use default import.
CQWebSocket
import CQWebSocket from 'cq-websocket'
import { CQWebSocket } from 'cq-websocket'
Default export only. Do not destructure.
CQWebSocket
const CQWebSocket = require('cq-websocket').default
const CQWebSocket = require('cq-websocket')
CommonJS requires the .default property for default exports since esModuleInterop is not assumed.

Shows how to import, connect, listen for messages, and handle cleanup with CQWebSocket.

import CQWebSocket from 'cq-websocket'; const bot = new CQWebSocket(); // Start WebSocket connection bot.connect(); // Listen for messages bot.on('message', (event, context, ...args) => { console.log(`Received message: ${context.message}`); // Reply quickly context.send('Hello from bot!'); }); // Handle errors bot.on('error', (err) => console.error(err)); // Cleanly disconnect on exit process.on('SIGINT', () => { bot.disconnect(); process.exit(); });
Debug
Known issues
breakingNode.js 10.x causes RangeError on API calls due to Buffer write issue
fix
Use Node.js 8.x or downgrade to an older Node version. No fix available in the library.
affects: >=10.0.0
gotchaCQHTTP API plugin does not support Fragment sending since v1.2.6
fix
Avoid using Fragment functionality; it is disabled by design.
affects: >=1.2.6
gotchaThe library is in beta, may have bugs; tested only with CoolQ Air
fix
Use with caution and report issues.
affects: all
deprecatedPossible deprecation of CoolQ platform itself; CQHTTP API may become unsupported
fix
Consider alternative QQ bot platforms or SDKs.
affects: all
Errors
Common errors & fixes
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received -805456141
Node.js 10.x incompatibility with the websocket package.
fix
Downgrade to Node.js 8.x or use a patched websocket library.
TypeError: CQWebSocket is not a constructor
Incorrect import: using destructured named import instead of default import.
fix
Use `import CQWebSocket from 'cq-websocket'` (default import) or `const CQWebSocket = require('cq-websocket').default` in CommonJS.
Error: listen EADDRINUSE :::8080
Another process is using the default WebSocket port.
fix
Specify a different port in the constructor: `new CQWebSocket({ port: 8081 })`.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies
websocketrequiredWebSocket client for real-time communication
Agent activity
21 hits · last 30 days
node
19
Amazon
1
OpenAI (training)
1
Resources
cq-websocket — npm install cq-websocket · libregistry