Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #293 from kevinsuh/master
Browse files Browse the repository at this point in the history
Update Corebot to handle undefined test_function
  • Loading branch information
Ben Brown authored Aug 13, 2016
2 parents 857fc15 + cfaa4a5 commit 2fa26f0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/CoreBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function Botkit(configuration) {
} else {
// handle might be a mapping of keyword to callback.
// lets see if the message matches any of the keywords
var patterns = this.handler;
var match, patterns = this.handler;
for (var p = 0; p < patterns.length; p++) {
if (patterns[p].pattern && botkit.hears_test([patterns[p].pattern], message)) {
patterns[p].callback(message, this);
Expand Down Expand Up @@ -706,8 +706,7 @@ function Botkit(configuration) {
test = tests[t];
}

var match = message.text.match(test);
if (message.text.match(test)) {
if (match = message.text.match(test)) {
message.match = match;
return true;
}
Expand Down Expand Up @@ -748,7 +747,7 @@ function Botkit(configuration) {
for (var e = 0; e < events.length; e++) {
(function(keywords, test_function) {
botkit.on(events[e], function(bot, message) {
if (test_function(keywords, message)) {
if (test_function && test_function(keywords, message)) {
botkit.debug('I HEARD', keywords);
cb.apply(this, [bot, message]);
return false;
Expand Down

0 comments on commit 2fa26f0

Please sign in to comment.