slate-irc-sasl
SASL Authentication Plugin for slate-irc general purpose IRC client:
( slate-irc core: https://github.com/slate/slate-irc )
- plugin system
- simple api
- arbitrary input stream
- DEBUG support for easy debugging
Installation
// install core
$ npm install slate-irc
// install sasl plugin
$ npm install slate-irc-sasl
Example
var irc = ;var sasl = ;var tls = ;var fs = ; // setup options here. var self = host: "chat.freenode.net" port: "6697" nick: '' user: '' pass: '' key: '' cert: ''; var stream = tls
Core API
Events
data
(msg) parsed IRC messagemessage
(event) on PRIVMSGnotice
(event) on NOTICEinvite
(event) on INVITEnames
(event) on RPL_NAMREPLYtopic
(event) on TOPICaway
(event) on RPL_AWAYquit
(event) on QUITjoin
(event) on JOINpart
(event) on PARTkick
(event) on KICKmode
(event) on MODEmotd
(event) on RPL_ENDOFMOTDnick
(event) on NICKwelcome
(nick) on RPL_WELCOMEwhois
(event) on RPL_ENDOFWHOISerrors
(event) on ERR*_pong
(event) on PONG
Client
Given a stream from net
or tls
or another network source, construct an IRC client.
var client = ;
.pass(pass)
Used at the beginning of connection to specify a 'connection password' for servers requiring a auth.
.nick(nick)
Specify an string
irc nick for the user.
.user(username, realname)
Used at the beginning of connection to specify the username and realname of a new user.
.invite(name, channel)
Send an invite to name
, for a channel
.
.send(target, msg)
Send a msg
to the target
user or channel.
.action(target, msg)
Send an ACTION msg
to the target
user or channel.
Example output: * erming slaps tj around a bit with a large trout
.notice(target, msg)
Send a NOTICE msg
to the target
user or channel.
.ctcp(target, msg)
Send a CTCP notice to the target
user.
.join(channel, key)
Send a JOIN
command for the user to join channel
with optional key
.
.part(channel, msg)
Send a PART
command for the user to part channel
with optional msg
.
.names(channel, callback)
List names of users in channel
, calling callback
with (error, names)
.
.away(message)
Set the user's away message to message
.
.topic(channel, topic)
Get channel topic or set the topic to topic
.
.kick(channels, nicks, msg)
Kick nick(s) from channel(s) with optional msg
.
.oper(name, password)
Used to obtain operator privileges. The combination of name
and password
are required to gain Operator privileges. Upon success, a 'mode'
event will be emitted.
.mode(target, flags, params)
Used to set a user's mode or channel's mode for a user.
.mode('cmilhench', '-o');
- // cmilhench 'deopping' himself.
.mode('#channel', '+o', 'name');
- // give 'chanop' privileges to name on channel #channel.
.quit(msg)
Disconnect from the server with optional msg
.
.whois(target, mask, callback)
Used to query information about particular user.
Writing Plugins
Plugins are simply functions that accept the IRC client as an argument. With this you can define methods, listen on events and interact with the client. For example here's a logger plugin that outputs to stdout:
{ return { ircstream; }}
Then .use()
it like so:
var client = ;client;
Returning a function like logger()
instead of logger
is optional,
however it's useful to use a closure when passing options, and to keep
the interface consistent with plugins that do accept options, for example:
{ return { ircstream; }} client;
Here's a slightly more complex example of a PONG plugin responding to PING messages:
{ return { irc; }}
License
MIT