Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Javascript IRC bot library.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 UNLICENSE
Octocat-spinner-32 package.json
README.md

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're gonna have to clone us some Jerk. So let's do that:

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('./path/to/Jerk/lib/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 )
}

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 :)

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 )
, 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 &

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

Written by Gianni Chiappettagf3.ca

Jerk is UNLICENSED.

Something went wrong with that request. Please try again.