github jeromeludmann/deno-irc v0.8.0

latest releases: v0.16.0, v0.15.0, v0.14.1...
2 years ago

More Granular Raw Events

The client can now subscribe to more granular raw events.

For instance, instead of doing:

client.on("raw", (msg) => {
  if (msg.command === "join") {
    // ...
  }
});

client.on("raw", (msg) => {
  if (msg.command === "rpl_topic") {
    // ...
  }
});

it is now possible to just write:

client.on("raw:join", (msg) => {
  // ...
});

client.on("raw:rpl_topic", (msg) => {
  // ...
});

The previous raw event name keeps the same behavior:

client.on("raw", (msg) => {
  // all the raw events
});

But internally, it now translate into all the available raw events:

client.on([
  "raw:admin", "raw:cap", "raw:connect", // ...
  "raw:rpl_welcome", "raw:rpl_yourhost", "raw:rpl_created", // ...
  "raw:err_unknownerror", "raw:err_nosuchnick", "raw:err_nosuchnick", // ...
], (msg) => {
  // all the raw events
});

Multi Events Subscribing

Event emitter allow to listen more than one event.

Example from plugins/nicklist:

client.on(["part", "kick", "quit", "kill"], (msg) => {
  const { source, params } = msg; // msg is PartEvent | KickEvent | QuitEvent | KillEvent

  const nick = "nick" in params ? params.nick : source?.name;
  const channel = "channel" in params ? params.channel : undefined;

  if (nick !== undefined) {
    removeNick(nick, channel);
  }
});

Allowing to listen to several events at a time can be handy in some specific cases.

Supported Server Feature Events

Events related to supported server features are now emitted:

  • isupport:chanmodes and isupport:prefix (used by plugins/chanmodes to handle channel modes aspects)
  • isupport:chantypes (used by plugins/chantypes to provide some helpers like client.utils.isChannel)
  • isupport:usermodes

They are mainly used to offer a way to be aware of the server features and allow client to update its own behavior.

Client Helpers

client.utils contains some convenient methods based on supported server features.

Following have been added:

  • client.utils.isChannel (previously imported from core/strings)
  • client.utils.isCtcp (previously imported from plugins/ctcp)
  • client.utils.createCtcp (previously imported from plugins/ctcp)

Don't miss a new deno-irc release

NewReleases is sending notifications on new releases.