irc bot with plugin support


an irc bot in node

var Ziggy = require('ziggy')
  , ziggy = Ziggy({
        server: 'irc.freenode.net'
      , nickname: 'Gushie'
      , channels: ['#quantumleap', '#sliderssucks']

Ta-da! You've got a bot online.

What's that? You want it to do something? Oh. Sorry. You can make a plugin for it!

module.exports = function(ziggysettings) {
  if(settings.respondToPm) {
    ziggy.on('pm', function(usertext) {
      ziggy.say(user.nick, 'Speak up, I can\'t hear you.')
  ziggy.on('message', function(userchanneltext) {
    var bits = text.split(' ')
      , command = bits.shift()
    if(command === '!reverse') {
      ziggy.say(channel, bits.reverse().join(' '))
    if(command === '!upper') {
      ziggy.say(channel, bits.join(' ').toUpperCase())
    if(command === '!lower') {
      ziggy.say(channel, bits.join(' ').toLowerCase())

Save something like that as, say, dumb-plugin.js and then modify your main code a bit.

var Ziggy = require('ziggy')
var dumbPlugin = require('dumb-plugin.js')
  , ziggy = Ziggy({
        server: 'irc.freenode.org'
      , nickname: 'Gushie'
      , plugins: [{
            name: 'dumb plugin'
          , setup: dumbPlugin
          , settings: {respondToPm: true}
      , channels: ['#quantumleap', '#sliderssucks']

Now we're talkin'. Pretty self-explanatory, but if you configure it as such, it will respond to all private messages with "Speak up, I can't hear you." It will also respond to in-channel "commands" like !reverse, !upper, and !lower with the replies associated.

Better yet, you can look at a fully-functioning example plugin here.

If you install ziggy globally (npm install -g ziggy), you will magically gain access to the ziggy command that works like this:

ziggy [options]

options are:

  • --server, -s <server> IRC server (default irc.freenode.net)
  • --port, -P <port> Server port (default 6667)
  • --password <password> Server password
  • --secure, -S Use secure connection
  • --plugin, -p <filemodule> Use ziggy plugin module
  • --nickname, -n <nick> Set nickname (default ziggy)
  • --channel, -c <channel> Connect to channel on startup
  • --user, -u <name:pass> Add users for Ziggy
  • --version, -v Print ziggy version
  • --help, -h Print help

Ziggy has a really naive sense of 'users' in so much as it will store a users object containing their nickname, bot-specific password, their authenticated status (defaults to true if no password is set), and their userLevel. The userLevel is pretty much an arbitrary number that can be used to control access in plugins. So, there really isn't any innate "level heirarchy", just use it in whatever way makes sense to you. Or don't use it at all. Whatever.

bot has connected to the server

when a message is sent in a channel

when a private message is received

when a person changes their nickname

when a Ziggy user authenticates his or herself.

when an action is sent in a channel

when a notice is received from server

when a notice is received. note: 'to' can be a nickname or a channel

when a mode is set

when a topic is set

when a person parts a channel

when ziggy parts a channel

when a user quits IRC

when a person is kicked

when a channel invitation is received

when a person joins a channel

when the bot joins a channel

where to can be a nickname or a channel

channels can be an array of channels or a string for a single channel

channels can be an array of channels or a string for a single channel

perform a whois for nick, all of the user information will be passed as the first argument to callback

disconnect bot from IRC with optional message

return list of channels

get info about channel

calls callback with user list

return user information

get bot level on channel

returns text formatted with color

change bot's name to newNick

set mode on channel where nick is optional

shortcut for mode(channel, '+o', nick)

shortcut for mode(channel, '-o', nick)

add users to the registered users list- accepts an object in the same format as users in the startup options.

send an irc action of text to channel

send a notice to a nick or channel

send a channel invitation to nick. channel does not have to exist, but if it does, only users in the channel are allowed to invite other users. If the channel mode +i is set, only channel operators may invite other users.

update user properties for users in object, same format as users in the startup.