A NodeJS and browser friendly JavaScript library used to interact with a hackchat server.
- node.js 14.15 or higher
- npm 6 or higher
npm i hackchat-engine
const { Client } = require('hackchat-engine');
const hcClient = new Client();
const testName = 'testBot';
const testPass = 'testBot';
const testChannel = 'programming';
hcClient.on('connected', () => console.log('Connected!'));
hcClient.on('session', (payload) => {
console.log(payload);
hcClient.join(testName, testPass, testChannel);
});
hcClient.on('channelJoined', (payload) => {
console.log(payload);
hcClient.say(testChannel, 'Bep boop i r bot');
});
hcClient.on('message', (payload) => {
console.log(payload);
hcClient.say(testChannel, 'No u');
});
** Need to update this, still **
By default, this engine will connect to 'wss://hack.chat/chat-ws'. To change this, add a ws.gateway
property to the options
object, for example:
const hcClient = new Client({
ws: {
gateway: 'ws://1.1.1.1:6060/',
}
});