Last active
April 22, 2016 21:19
-
-
Save devStepsize/003f491c650f5c0e5012b9eabc1a6805 to your computer and use it in GitHub Desktop.
Botkit hear middleware to change the way bots hear triggers
This file contains hidden or 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
// From https://github.com/howdyai/botkit#hear-middleware | |
// this example does a simple string match instead of using regular expressions | |
function custom_hear_middleware(patterns, message) { | |
for (var p = 0; p < patterns.length; p++) { | |
if (patterns[p] == message.text) { | |
return true; | |
} | |
} | |
return false; | |
} | |
controller.hears(['hello'],'direct_message',custom_hear_middleware,function(bot, message) { | |
bot.reply(message, 'I heard the EXACT string match for "hello"'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment