user api

class User(nick, client, network)
Arguments:
  • nick (string) – The users nickname
  • client (object) – Client object.
  • network (string) – Network object.

Create a new user object.

User.toString()
Returns string hostmask:
 Hostmask of the user.
User.getNick()
Returns string Nick:
 Nick of the user.
User.getNetwork()
Returns string Network:
 Network of the user.
User.getUsername()
Returns string Username:
 Username of the user.
User.getRealname()
Returns string Realname:
 Realname of the user.
User.getHostname()
Returns string Hostname:
 Hostname of the user.
User.getAccountName()
Returns string AccountName:
 AccountName of the user.
User.getChannels()
Returns object Channels:
 Channels of the user. {'#channel': ['~']}
User.getServer()
Returns string Server:
 Server the user is connected to.
User.getServerInfo()
Returns string ServerInfo:
 ServerInfo of the Server the user is connected to.
User.getAway()
Returns boolean Away:
 Away status of the user.
User.getAccount()
Returns string Account:
 Account of the user.
User.isRegistered()
Returns boolean registered:
 Registration status of the user.
User.isUsingSecureConnection()
Returns boolean secureConnection:
 SSL status of the user (on/off).
User.getIdle()
Returns int Idle:
 Idletime of the user.
User.getSignonTime()
Returns string SignonTime:
 SignonTime of the user.
User.isOper()
Returns boolean oper:
 Oper status of the user.
User.notice(msg)
Arguments:
  • msg (string) – Notice message to send to the user.
User.say(msg)
Arguments:
  • msg (string) – Message to send to the user.
User.whois(fn)
Arguments:
  • fn (function) – The callback function to be called when the call has been finished.

events

nick

The nick event, fired when someone changes nickname.

Event attributes:

  • user - User who changed nick.
  • oldNick - Their old nickname.

Example:

client.on('nick', function (event) {
    console.log(event.oldNick + " is now " + event.user.getNick());
});
whois

The whois event, fired when the whois response is received from the server.

Event attributes:

  • whoismap - {user: whois_data}.

Example:

client.on('whois', function (err, event) {
    if (err) console.err("Couldn't whois:", err);
    console.log(event);
});

functions

getUser(nick, network)
Param string nick:
 The user you want to get by nickname.
Param string network:
 The network to execute the command on.

Get a user object by nickname.

Example:

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

Checks if the passed object is a valid user object.

Example:

var user = client.getUser("#caffeinery", event.network); // usage in an event listener
console.log(client.isUser(user)); // prints `true`
isMe(user)
Param object user:
 The user object you want to check.

Checks if the passed object is the same user object as the client.

Example:

if (client.isMe(event.user)) {
    console.log("message was from me");
} else {
    console.log("message was from somebody else");
}
whois(target, network, fn)
Param object target:
 The channel or user object to send this message 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.

Send a whois request to the server.

Example:

client.whois("omnidan", event.network, function (event) {
    console.log(event.whois);
}); // usage in an event listener

client.whois("omnidan", "freenode", function (event) {
    console.log(event.whois);
}); // send to specific network
identify(username, password, network, fn)
Param string username:
 The username to identify with.
Param string password:
 The password to identify with.
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.

Identifies the user with nickserv.

Example:

client.on('motd', function (event) {
    client.identify("omnidan", "p@$$w0rd", event.network); // log in with nickserv
});

You can specify this data in the config too like this:

{
  nickserv: {
    username: 'test',
    password: 'l33tp455w0rD'
  }
}
nick(nick, network, fn)
Param string nick:
 The nickname you want to use now.
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.

Change your nickname to the specified nick.

Example:

client.on('motd', function (event) {
    client.nick("omnidan", event.network); // log in with nickserv
});

You can specify this data in the config too like this:

{
  nick: 'omnidan'
}