kara
Version:
A third generation EX-400 android
22 lines (16 loc) • 481 B
JavaScript
var HelloWorld = module.exports = function HelloWorld(bot) {
function hook(msg) {
if (/^hello\b/.test(msg.body)) { onHello(msg) }
}
function onHello(msg) {
bot.reply(msg, "world");
}
this.enable = function enable() {
bot.on("msg:direct", hook);
};
this.disable = function disable() {
if (this.disabled === true) { throw new Error("Cannot disable a disabled plugin") }
this.disabled = true;
bot.removeListener("msg:direct", hook);
};
};