channel api

class Channel(name, client, network)
Arguments:
  • name (string) – The channel name
  • client (object) – Client object.
  • network (string) – Network object.

Create a new channel object.

Channel.toString()
Returns string hostmask:
 Hostmask of the channel.
Channel.getName()
Returns string Name:
 Name of the channel.
Channel.getTopic()
Returns string Topic:
 Topic of the channel.
Channel.getNames()
Returns object names:
 Nicks in the channel: {'nick': ['~']}
Channel.getNetwork()
Returns string Network:
 Network of the channel.
Channel.userHasMode(user, mode)
Arguments:
  • user (object) – The user to check the mode of in the channel.
  • mode (string) – The mode to check for.
Returns boolean hasMode:
 

true if specified user has specified mode.

Channel.isUserInChannel(user)
Arguments:
  • user (object) – The user to check.
Returns boolean hasMode:
 

true if specified user is in this channel.

Channel.notice(msg)
Arguments:
  • msg (string) – Notice message to send to the user.
Channel.say(msg)
Arguments:
  • msg (string) – Message to send to the user.
Channel.reply(user, msg)
Arguments:
  • user (object) – User to reply to.
  • msg (string) – Message to send to the user.
Channel.kick(user, reason)
Arguments:
  • user (object) – User to kick from channel.
  • reason (string) – Reason for the kick.
Channel.ban(mask)
Arguments:
  • mask (string) – Hostmask to ban.
Channel.unban(mask)
Arguments:
  • mask (string) – Hostmask to unban.

events

invite

The invite event, fired when someone gets invited by someone.

Event attributes:

  • channel - Channel you got invited to.
  • user - User who sent the invite.
  • target - Invited user.

Example:

client.on('invite', function (event) {
    console.log(event.target.getNick() + " got invited to "
        + event.channel.getName() + " by " + event.user.getNick());
});
topic

The topic event, fired when the topic gets changed. (or is originally sent)

Event attributes:

  • topic - Current topic.
  • user - User who changed the topic.
  • time - Time of topic change.
  • changed - true if topic was changed in this event.
  • channel - Affected channel.
  • network - Affected network.

Example:

client.on('topic', function (event) {
    console.log(event.channel.getName() + ":", event.topic);
});
join

The join event, fired when someone joins a channel.

Event attributes:

  • user - User who joined.
  • channel - Channel that was joined.

Example:

client.on('join', function (event) {
    console.log(event.user.getNick() + " joined " + event.channel.getName());
});
names

The names event, fired when getting users in the channel.

Event attributes:

  • channel - Affected channel.
  • names - List of users in the channel.

Example:

client.on('names', function (event) {
    console.log(event.channel.getName() + ":", event.names);
});
mode

The mode event, fired when a mode gets changed.

Event attributes:

  • mode - Current mode.
  • channel - Affected channel.
  • by - User who changed the mode.
  • argument - Mode argument.
  • adding - boolean

Example:

client.on('mode', function (event) {
    console.log(event.channel.getName() + ":", event.mode);
});
kick

The kick event, fired when a user gets kicked.

Event attributes:

  • channel - Affected channel.
  • user - Affected user.
  • by - User who changed the kick.
  • reason - Reason for the kick.

Example:

client.on('kick', function (event) {
    console.log(event.channel.getName() + ":", event.user.getNick(), "was kicked.");
});
part

The part event, fired when a user parts a channel (channels).

Event attributes:

  • user - Affected user.
  • channels - Affected channels (channelList).
  • message - Part message.

Example:

client.on('part', function (event) {
    console.log(event.user.getNick(), "parted channels", event.channels);
});

functions

getChannelList(network)
Param string network:
 The network to execute the command on.
Return array channelList:
 List of channels.

Get a list of channels.

Example:

var channels = client.getChannelList(event.network); // usage in an event listener
var channels = client.getChannelList("freenode"); // send to specific network
var channels = client.getChannelList(); // get object of networks and channels
getChannel(name, network)
Param string name:
 The name of the channel you want to get.
Param string network:
 The network to execute the command on.

Gets a channel by name.

Example:

var channel = client.getChannel("#caffeinery", event.network); // usage in an event listener
var channel = client.getChannel("#caffeinery", "freenode"); // send to specific network
isChannel(channel)
Param object channel:
 The channel object you want to check.

Checks if the passed object is a valid channel object.

Example:

var channel = client.getChannel("#caffeinery", event.network); // usage in an event listener
console.log(client.isChannel(channel)); // prints `true`
invite(name, channel, network, fn)
Param string name:
 The name of the user you want to invite.
Param string/object channel:
 The channel you want to invite him to.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Invites a user to a channel.

Example:

client.invite("omnidan", "#caffeinery", event.network); // usage in an event listener
client.invite("omnidan", "#caffeinery", "freenode"); // send to specific network
topic(channel, topic, network, fn)
Param string/object channel:
 The channel you want to set the topic in.
Param string topic:
 The topic you want to set.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Sets the topic of a channel.

Example:

client.topic("#caffeinery", "welcome to caffeinery!", event.network); // usage in an event listener
client.topic("#caffeinery", "welcome to caffeinery!", "freenode"); // send to specific network
join(channels, keys, network, fn)
Param string/object/array channels:
 The channel(s) you want to join.
Param string/array keys:
 The key(s) for the channel(s) you want to join.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Joins channels.

Example:

client.join("#caffeinery", event.network); // usage in an event listener
client.join("#caffeinery", "freenode"); // send to specific network
client.join(["#caffeinery", "#omnidan"], event.network); // join multiple channels

Example (Join password protected channels):

client.join("#caffeinery", event.network); // usage in an event listener
client.join("#caffeinery", "freenode"); // send to specific network
client.join(["#caffeinery", "#omnidan"], event.network); // join multiple channels
part(channels, msg, network, fn)
Param string/object/array channels:
 The channels you want to kick from.
Param string msg:
 The part message.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Parts channels.

Example:

client.part("#caffeinery", "byeee", event.network); // usage in an event listener
client.part("#caffeinery", "byeee", "freenode"); // send to specific network
client.part(["#caffeinery", "#omnidan"], "byeee", event.network); // part multiple channels
kick(channels, nicks, msg, network, fn)
Param array/object/string channels:
 The channel(s) you want to kick from.
Param array/string nicks:
 The nick(s) you want to kick.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Kick user from a channel.

Example:

client.kick("#caffeinery", "omnidan", "bye!", event.network); // kick user from specific channel
client.kick(event.channel, "omnidan", "bye!", event.network); // kick user from current channel
client.kick(["#caffeinery", "#omnidan"], "omnidan", "bye!", event.network); // kick user from multiple channels
client.kick("#caffeinery", ["omnidan", "np_coffea"], "bye!", event.network); // kick multiple users from channel
names(channels, network, fn)
Param string/object/array channels:
 The channel you want to get the nicknames from.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Gets users from a channel.

Example:

client.names("#caffeinery", event.network, function (names) {
    console.log(names);
}); // usage in an event listener

client.names("#caffeinery", "freenode, function (names) {
    console.log(names);
}); // send to specific network

client.names(["#caffeinery", "#omnidan"], event.network, function (names) {
    console.log(names);
}); // get names from multiple channels
mode(target, flags, network, fn)
Param string target:
 Target for the mode change, can be a user or channel.
Param string flags:
 Flags of the mode change.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Sets modes.

Note

You’ll probably want to use the umode and chanmode functions instead of this function.

Example:

client.mode("omnidan", "+p", event.network); // set mode on specific user
client.mode(client.me, "+p", event.network); // set mode on current client
client.mode("#caffeinery", "+v omnidan", event.network); // voice a user in a specific channel
client.mode(event.channel, "+v omnidan", event.network); // voice a user in the current channel
umode(flags, network, fn)
Param string flags:
 Flags of the mode change.
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Sets modes on the current client.

Example:

client.umode("+p", event.network); // set mode on current client
chanmode(channel, mode, target, network, fn)
Param string channel:
 Channel to change modes on.
Param string mode:
 Consists of +/- and a mode character, e.g. +v, -o
Param array/object/string target:
 Target for the mode change, can be (a) user(s) or channel(s).
Param string network:
 The network to execute the command on.
Param function fn:
 The callback function to be called when the call has been finished.

Sets modes on a channel.

Note

There are helper functions that work like client.chanmode, but without having to specify the mode: voice, devoice, op, deop, hop, dehop

Example:

client.chanmode("#caffeinery", "+v", "omnidan", event.network); // voice a user in a specific channel
client.chanmode(event.channel, "+v", "omnidan", event.network); // voice a user in the current channel
client.chanmode(event.channel, "+v", ["omnidan", "np_coffea"], event.network); // voice multiple users in the current channel

// or using helper functions...
client.voice("#caffeinery", "omnidan", event.network); // voice a user in a specific channel
client.voice(event.channel, "omnidan", event.network); // voice a user in the current channel
client.voice(event.channel, ["omnidan", "np_coffea"], event.network); // voice multiple users in the current channel