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

Update Corebot to handle undefined test_function #293

Merged
merged 2 commits into from
Aug 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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