@ctrl/irc
TypeScript icon, indicating that this package has built-in type declarations

3.1.1 • Public • Published

@ctrl/irc npm

A typed IRC client library for node

Based on irc-upd. Includes irc color decoding based on irc-colors.js

Install

npm install @ctrl/irc

Use

import { IrcClient } from '@ctrl/irc';
const client = new IrcClient('irc.yourserver.com', 'myNick', {
  channels: [],
  port: 7000,
  secure: true,
});
client.connect();

Join a channel

client.join('#yourchannel yourpass');

Leave a channel

client.part('#yourchannel');

Send a message

// To channel
client.say('#yourchannel', 'hello');
// To user
client.say('nonbeliever', 'sup');

With typescript 4.1 template strings feature events can be fully typed.

// (from, message) parameters are typed via template strings matching `message#${string}`
client.addListener('message#yourchannel', (from, message) => {
  console.log(from + ' => #yourchannel: ' + message);
});

Debugging - subscribe to the raw messages and see what events are being parsed and re-emitted

client.on('raw', message => {
  console.log(message);
});

Links

Readme

Keywords

Package Sidebar

Install

npm i @ctrl/irc

Weekly Downloads

11

Version

3.1.1

License

MIT

Unpacked Size

93.9 kB

Total Files

17

Last publish

Collaborators

  • scttcper