yoil is a simple, yet fairly flexible IRC library written in JavaScript. It is intended for web-based IRC communication, and therefore only provides a WebSocket transport.
- Adaptive requesting of IRCv3 capabilities: some IRCv3 caps require other caps to actually be useful (I'm looking at you echo-message). Therefore, yoil checks if a capabilities dependants are present before requesting.
- SASL mechanisms: Since PLAIN is so easy to implement, I decided to implement SCRAM-SHA-256 and SCRAM-SHA-512 support (oh, and SCRAM-SHA-1, but don't use that)
- Namespaced events: Events are provided in namespaces depending on where the event belongs. The most interesting thing this does, is provide a way to distinguish between private messages and channel messages, using user::privmsg and channel::privmsg respectively.
- And a lot more, like auto reconnecting, automatically changing your nick if its in use, and a few other features.
Feature | Support |
---|---|
CAP | ✔️ |
CAP 302 | ✔️ |
cap-notify | ✔️ |
account-notify | ✔️ |
account-tag | ✔️ |
away-notify | ✔️ |
batch | ✔️ |
chghost | ✔️ |
echo-message | ✔️ |
extended-join | ✔️ |
invite-notify | ✔️ |
message-tags | ✔️ |
monitor | ❌ |
msgid | ✔️ |
multi-prefix | ✔️ |
sasl v3.1 | ✔️ |
sasl v3.2 | ✔️ |
server-time | ✔️ |
sts | ❌ |
userhost-in-names | ✔️ |
webirc | ❌ |
Here is a simple example:
const irc = require('yoil');
const config = new irc.Config({
nickname: 'nickname',
username: 'username',
realname: 'realname',
port: 7002,
host: '127.0.0.1',
tls: true,
saslUsername: 'username',
saslPassword: 'password',
autoReconnect: true,
});
const client = new irc.Client(config);
client.connect();
client.on('server::registered', ({ server }) => {
console.log(`Connected to ${server}`);
});
client.on('sasl::account', ({ account, error }) => {
if (error) {
console.log('SASL unsuccessful');
} else {
console.log(`I successfully negotiated SASL and logged in as ${account}`);
}
});
client.on('server::erroneous-nickname', data => {
console.log(data);
});