After trying various things with confusing names, I have removed everything except one method, which delegates to a couple of internal ones:
// Simplest regexp match
bot.match(/\bice\s+cream\b/i, function(msg) { msg.reply("Yum, %s. I love ice cream!", msg.from.nick); });
// Regexp match with groups (example from ircjsbot Spotify plugin)
bot.match(/\bspotify(?:\s+(album|artist|track))?\s+((?:\D+)|(?:.+))(?:\s+([1-9]\d*))?$/i,
function(msg, type, query, index) {
// Search for <type>s matching <query>, returning the item at <index>.
});
// Match any message of a certain type
bot.match(irc.COMMAND.PRIVMSG, function(msg) {
console.log("Got a PRIVMSG:", msg.toString());
});
// Match message for which predicate returns `true`
function isFriday() {
return new Date().getDay() === 5;
}
bot.match(isFriday, function(msg) {
msg.reply("Friday!! Friday!!");
});
// Or a combination
bot.match(/\bfriday\b/i, isFriday, function(msg) {
msg.reply("TGIF");
});
I'm unsure about the name, and the corresponding method that removes handlers currently named ignore.
Other than that it’s pretty nice.
What do you think @gf3, fix the naming and settle on this?
After trying various things with confusing names, I have removed everything except one method, which delegates to a couple of internal ones:
I'm unsure about the name, and the corresponding method that removes handlers currently named
ignore
. Other than that it’s pretty nice.What do you think @gf3, fix the naming and settle on this?