npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ziggy

v2.4.0

Published

irc bot with plugin support

Downloads

5,789

Readme

ziggy

Build Status

an irc bot in node

usage

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

ziggy.start()

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!

example plugin

module.exports = function(ziggy, settings) {
  if(settings.respondToPm) {
    ziggy.on('pm', function(user, text) {
      ziggy.say(user.nick, 'Speak up, I can\'t hear you.')
    })
  }

  ziggy.on('message', function(user, channel, text) {
    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']
    })

ziggy.start()

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.

as a command line tool

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

users

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.

events

ready

bot has connected to the server

message (user, channel, text)

when a message is sent in a channel

pm (user, text)

when a private message is received

nick (oldNick, user, channels)

when a person changes their nickname

authed (user)

when a Ziggy user authenticates his or herself.

action (user, channel, text)

when an action is sent in a channel

server (text)

when a notice is received from server

notice (user, to, text)

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

mode (channel, setBy, mode, argument)

when a mode is set

topic (channel, topic, nick)

when a topic is set

part (user, channel, reason)

when a person parts a channel

ziggypart (channel)

when ziggy parts a channel

quit (user, reason, channels)

when a user quits IRC

kick (kicked, kickedBy, channel, reason)

when a person is kicked

invite (channel, user)

when a channel invitation is received

join (channel, user)

when a person joins a channel

ziggyjoin (channel)

when the bot joins a channel

API

say(to, text)

where to can be a nickname or a channel

part(channels, callback)

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

join(channels, callback)

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

whois(nick, callback)

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

disconnect(message, callback)

disconnect bot from IRC with optional message

channels

return list of channels

channel(channel)

get info about channel

users(callback)

calls callback with user list

user(nick)

return user information

level(channel)

get bot level on channel

colorize(text, color)

returns text formatted with color

nick(newNick)

change bot's name to newNick

mode(channel, mode, nick)

set mode on channel where nick is optional

op(channel, nick)

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

deop(channel, nick)

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

register(userObject)

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

action(channel, text)

send an irc action of text to channel

notice(target, text)

send a notice to a nick or channel

invite(nick, 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(userObject)

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

license

MIT