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

jerk

v1.1.23

Published

Stupidly simple IRC bots in Javascript.

Downloads

22

Readme

Jerk

A fun little IRC bot library for node.js. Ridiculously simple to set-up and get going!

OHMYGOD

Seriously, it's stupidly simple.

Your First Bot

Firstly, we'll need to grab Jerk. If you use npm it's as easy as:

npm install jerk

If you prefer straight-up git:

git clone git://github.com/gf3/Jerk.git

Hoo haa, now that we're locked and loaded, let's write a goddamn bot! We need to include Jerk:

var jerk = require( 'jerk' )

You'll need some options. Jerk takes the exact same options object as the IRC-js library. Let's just go ahead and supply some basic info:

var options =
  { server: 'irc.freenode.net'
  , nick: 'YourBot9001'
  , channels: [ '#your-channel' ]
  }

Hah, now you're going to cry once you see how easy this is:

jerk( function( j ) {

  j.watch_for( 'soup', function( message ) {
    message.say( message.user + ': soup is good food!' )
  })

  j.watch_for( /^(.+) are silly$/, function( message ) {
    message.say( message.user + ': ' + message.match_data[1] + ' are NOT SILLY. Don\'t joke!' )
  })

}).connect( options )

Really. That's it.

ADVANCED USER OF THE INTERNETS

The jerk object (j) has only one method: watch_for. Which takes two arguments, the first can be either a string or a regex to match messages against. The second argument is your hollaback function for when a match is found. The hollaback receives only one argument, the message object. It looks like this:

{ user:       String
, source:     String
, match_data: Array
, say:        Function( message )
, msg:        Function( message )
}

One thing I will tell you though, is the say method is smart enough to reply to the context that the message was received, so you don't need to pass it any extra info, just a reply :) However, the msg method can be used if you'd like to force sending a message directly to a user (aka a PM).

The connect method returns an object with some handy methods that you can use outside of your watch_fors:

{ say:    Function( destination, message )
, action: Function( destination, action )
, forget: Function( pattern )
, part:   Function( channel )
, join:   Function( channel )
, quit:   Function( message )
}

Example:

var superBot = jerk( ... ).connect( options )
// Later...
superBot.say( '#myChan', 'Soup noobs?' )
superBot.join( '#haters' )
superBot.action( '#hates', 'hates all of you!' )

I think everything there is pretty self-explanatory, no?

Running Your Bot

node yourBot9001.js

Run your bot on a remote server:

nohup node yourBot9001.js &

Although I recommend using something like forever to keep your bot running for a while.

Done.

A Better Example

Here's a more practical example, meet protobot. Protobot hangs out on Freenode#prototype all day – stop by and say hi!

A few bots using Jerk:

Wrote a bot with Jerk? Email me and I'll add it to the list!

Credit & Junk

{ "author" : "Gianni Chiappetta <[email protected]> (http://gf3.ca)"
, "contributors" :
  [ "Isaac Z. Schlueter <[email protected]> (http://blog.izs.me)"
  , "Arnaud Berthomier <[email protected]> (http://wtf.cyprio.net)"
  , "Suresh Harikrishnan <[email protected]> (http://www.activesphere.com)"
  , "Tomás Senart <[email protected]> http://about.me/tsenart"
  ]
}

Jerk is UNLICENSED.