Skip to content

Instantly share code, notes, and snippets.

@gf3
Created July 27, 2009 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gf3/156663 to your computer and use it in GitHub Desktop.
Save gf3/156663 to your computer and use it in GitHub Desktop.
Proposed syntax for IRC bot
// Proposed syntax for IRC bot
// ---------------------------
jerk(function() {
// `watch_for` takes a regular expression, and matches it against everything that is said
watch_for(/^api (\w+)\.(\w+)/, function(message) {
// Message object has properties: match_data, channel, user, text
// `say` replies in the channel that the message was heard in
say(message.user.nick + ": Something " + message.match_data[1]);
});
// `watch_for` can also match strings
watch_for("help", function(message) {
say("Help topics: ...");
});
}).connect(options);
// Options
var options = {
// Required
server: "127.0.0.1",
// Optional
port: 6667,
encoding: "ascii",
nick: "js-irc",
channels: ["#runlevel6"],
user: {
username: "js-irc",
hostname: "thetubes",
servername: "tube1",
realname: "Javascript Bot"
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment