yacqhttp
v2.0.0
Published
Yet another package for interacting with the CoolQ HTTP API
Downloads
15
Readme
English - 中文
yacqhttp
This is a lightweight Node.js package that allows you to interact with the CoolQ HTTP API. It can only act as the WebSocket server at the moment. Other methods of communication are not supported.
Features
- Full TypeScript support.
- Simple and easy to use.
- Load balancing between multiple CoolQ instances.
Installation
This package requires Node.js v10 or newer and CQHTTP API v4.5.0 or newer.
$ npm install yacqhttp
Usage example
const { Server } = require('yacqhttp');
const coolQ = new Server();
coolQ
.on('ready', client => console.log(`${client.id} is ready!`))
.on('message', (client, event) => client.send(event, 'Hi~'));
coolQ.listen('0.0.0.0', 8080);
With CommandRegistry
// Previous example here...
const { CommandRegistry } = require('yacqhttp');
const cmdReg = new CommandRegistry(coolQ);
cmdReg.add({
name: 'echoFirstWord',
process(convo, args) {
convo.reply(`Your first word is: ${args[0]}`);
},
});