-
Notifications
You must be signed in to change notification settings - Fork 0
Client
An IRC Client. Client extends EventEmitter2, so you can use the typical on or once functions with the following events.
All events have an event argument. The properties listed are properties of that object.
Event Properties: {nick, server, port}
When the client successfully connects to the server. (Note: This is not just when the connection is made, but after the 001 welcome reply is received.)
Event Properties: {reason}
When the client is disconnected from the server. This happens either by error or by explicitly calling the disconnect function. If the client is explicitly disconnected, then there will NOT be an error event emitted.
Event Properties: {server, port}
When the client is attempts to make a socket connection to the server.
Event Properties: {server, port, delay, triesLeft}
When the client decides to reconnect to the server after a delay. This event is triggered before the delay (so a connecting
event will occur in delay
milliseconds after this event).
Event Properties: {server, port}
When the client has established a socket connection to the server, but hasn't yet been accepted/welcomed by the IRC server.
Event Properties: {raw, tags, prefix, command, params}
When an error occurs. This will disconnect the client and also emit a disconnect event.
Event Properties: {oldNick, newNick, me}
When someone changes their nick and is visible in a channel the client is in. Can be the client itself. If it is the client, me
will be true.
Event Properties: {chan, nick, me}
When a user joins any channel the client is in. Can be the client itself. If it is the client, me
will be true.
Event Properties: {chan, nick, reason, me}
When a user parts any channel the client is in. Can be the client itself. If it is the client, me
will be true.
Event Properties: {chan, nick, kicker, reason, me}
When a user is kicked from a channel the client is in. Reason is optional. If it is the client, me
will be true.
Event Properties: {raw, tags, prefix, command, params}
When any raw message is received. parsedMsg will be the object that the irc-message module returns from parsing the message.
Event Properties: {motd}
When the server's motd is received.
Event Properties: {nick, reason}
When someone quits from the server. This will not trigger for the client itself.
Event Properties: {from, to, msg}
When someone sends an action in a channel the client is in.
Event Properties: {from, to, msg}
When someone sends a message to the client or a channel the client is in.
Event Properties: {from, to, msg}
When someone sends a notice to the client.
Event Properties: {from, chan}
When someone invites the client to a channel.
Event Properties: {chan, sender, mode}
When the mode is set on a channel. The mode
parameter contains the entire mode string that was set by the sender. This is useful if you don't care what the modes actually are, but want to display the event anyway (or if you want to parse it yourself).
Event Properties: {chan, sender, mode, param}
When the mode is set in a channel. The mode parameter will only be a single mode. Param is optional, depending on the mode letter. The sender can be a nick or the server. This is useful if you wish to handle new modes individually.
Event Properties: {chan, sender, mode, param}
When the mode is removed in a channel. The mode parameter will only be a single mode. Param is optional, depending on the mode letter. The sender can be a nick or the server. This is useful if you wish to handle new modes individually.
Event Properties: {user, sender, mode}
When the mode is set on a user. The mode
parameter contains the entire mode string that was set by the sender. This is useful if you don't care what the modes actually are, but want to display the event anyway (or if you want to parse it yourself).
Event Properties: {user, mode, sender}
When the mode is set on a user. The mode parameter will only be a single mode. The sender can be a nick or the server. This is useful if you wish to handle new modes individually.
Event Properties: {user, mode, sender}
When the mode is removed from a user. The mode parameter will only be a single mode. The sender can be a nick or the server. This is useful if you wish to handle new modes individually.
Event Properties: {seconds}
When the client times out, this event will be triggered right before disconnecting.
Event Properties: {chan}
When the client finishes receiving the list of names for a channel. Chan will be '*' if you sent the NAMES command without any channel parameter, as per the RFC. You may access the updated names by getting the channel object from getChannel(e.chan).
Event Properties: {chan, topic}
When the client receives the topic for a channel. If a RPL_NOTOPIC is received, then topic
will be empty.
Event Properties: {chan, hostmask, time}
When the client receives information on who set the channel topic and when. time
is a Date.
String
The server address to connect to
Integer
The port to connect to. Default: 6667
String
The nickname to connect with. Default: NodeIRCClient
String
The username to connect with. Default: NodeIRCClient
String
The real name to connect with. Default: NodeIRCClient
String
The server password to connect with. Default: none
Array
The channels to autoconnect to on connect. Default: []
Boolean
Whether this should output log messages to console or not. Default: false
Boolean
Whether this should output error messages to console or not. Default: true
Boolean
Whether this should try alternate nicks if the given one is taken, or give up and quit. Default: true
Boolean
Whether this should automatically rejoin channels it was kicked from. Default: false
Boolean
Whether this should automatically connect after being created or not. Default: true
Boolean
Whether this should automatically split outgoing messages. Default: true NOTE: This will split the messages conservatively. Message lengths will be around 400-ish.
Integer
How long to throttle between outgoing messages. Default: 1000
Boolean
Strips colors from incoming messages before processing. Default: true
Boolean
Strips styles from incoming messages before processing, like bold and underline. Default: true
Integer
Time in milliseconds to wait before trying to reconnect. Default: 5000
Boolean
Whether this should automatically attempt to reconnect on disconnecting from the server by error. If you explicitly call disconnect(), the client will not attempt to reconnect. This does NOT apply to the connect() retries. Default: true
Integer
The number of attempts to reconnect if autoReconnect is enabled. If this is -1, then the client will try infinitely many times. This does NOT apply to the connect() retries. Default: 3
Boolean/Object
Whether to use ssl to connect to the server. If ssl is an object, then it is used as the options for ssl connections (See tls.connect in 'tls' node module). Default: false
Boolean
Whether to accept self signed ssl certificates or not. Default: false
Boolean
Whether to accept expired certificates or not. Default: false
Integer
Number of milliseconds to wait before timing out. Default: 120000
Boolean
Whether to trigger the msg
, action
, or notice
events when client.msg()
, client.action()
, or client.notice()
are called. If autoSplitMessage
is enabled, it will trigger a separate event for every line. Default: false
Connects to the server. Returns a Promise that resolves with the nick on successful connect, and rejects with an Error on connection error.
Disconnects from the server. Returns a Promise that is resolved on successful disconnect.
Immediately disconnects from the server without waiting for the server to acknowledge the QUIT request.
Sends a raw message to the server. Automatically appends \r\n
. If delay
is false, the message will be sent immediately, skipping the message queue delay from the messageDelay
option.
Registers plugin
with this client. (It just calls plugin(client)). Returns the client for chaining.
NOTE: Typically, you'll want your plugin to handle events before any other listeners on the client. EX: the core channel plugin needs to update nicknames on the nick event so other listeners will have updated data by the time they are called. To accomplish this, you must use the internal EventEmitter in the Client:
client._.internalEmitter.on('nick', function(/*args...*/){/*code*/});
Another important thing to note is that you cannot use this
to refer to the Client when in a listener for internalEmitter
.
Returns true if this client is connected to and has been accepted by the server.
Returns true if a connection has been initiated by connect()
, but the server hasn't accepted us yet.
Getter/setter for the option verbose
Getter/setter for the option verboseError
Getter/setter for the option messageDelay
Getter/setter for the option autoSplitMessage
Getter/setter for the option autoRejoin
Getter/setter for the option triggerEventForOwnMessages
Checks if a string represents a channel, based on the CHANTYPES value from the server's iSupport 005 response. Typically this means it checks if the string starts with a '#'.
Returns the prefix the server has configured for the given mode character. For example, modeToPrefix('o')
will return @
in virtually all servers.
Sends an invite to nick
to join chan
.
Joins a channel. chan
can be a String or Array of channels. Returns a Promise that resolves when the channel (or all channels if you provided an Array) has been successfully joined.
Parts a channel. chan
can be a String or Array of channels. Returns a Promise that resolves when the channel (or all channels if you provided an Array) has been successfully joined.
Kicks a user from a channel.
Sends a message (PRIVMSG) to the target.
Sends an action (/me) to the target.
Sends a notice to the target.
Returns the client's current nick.
Changes the client's nick. Returns a Promise that resolves with {oldNick, newNick}
on successful nick change, and rejects with the server's error reply.
Returns an Array of modes for a channel.
Sets a given mode on a hostmask in a channel. modeStr
is a String of modes and arguments to set for that channel.
Sets mode +b on a hostmask in a channel.
Sets mode -b on a hostmask in a channel.
Sets mode +o on a user in a channel. user
can be an array of users.
Sets mode -o on a user in a channel. user
can be an array of users.
Sets mode +v on a user in a channel. user
can be an array of users.
Sets mode -v on a user in a channel. user
can be an array of users.
Sends a request to get the topic in chan
. Listen for the topic
event to get the answer.
Set the topic for chan
to topic
.