Created
July 27, 2009 18:19
-
-
Save gf3/156663 to your computer and use it in GitHub Desktop.
Proposed syntax for IRC bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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