A fun little IRC bot library for node.js. Ridiculously simple to set-up and get going!
Seriously, it's stupidly simple.
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:
jerkjwatch_for 'soup'messagesay messageuser + ': soup is good food!'jwatch_for /^ are silly$/messagesay messageuser + ': ' + messagematch_data1 + ' are NOT SILLY. Don\'t joke!'connect options
Really. That's it.
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: Stringsource: Stringmatch_data: Arraysay: Function messagemsg: 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).
connect method returns an object with some handy methods that you can use outside of your
say: Function destination messageaction: Function destination actionforget: Function patternpart: Function channeljoin: Function channelquit: Function message
var superBot = jerk connect options// Later...superBotsay '#myChan' 'Soup noobs?'superBotjoin '#haters'superBotaction '#hates' 'hates all of you!'
I think everything there is pretty self-explanatory, no?
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.
A few bots using Jerk:
Wrote a bot with Jerk? Email me and I'll add it to the list!
"author" : "Gianni Chiappetta <firstname.lastname@example.org> ()""contributors" :"Isaac Z. Schlueter <email@example.com> ()""Arnaud Berthomier <firstname.lastname@example.org> ()""Suresh Harikrishnan <email@example.com> ()""Tomás Senart <firstname.lastname@example.org> "
Jerk is UNLICENSED.