diff --git a/lib/CoreBot.js b/lib/CoreBot.js index a3f5ab9c7..382ea7756 100755 --- a/lib/CoreBot.js +++ b/lib/CoreBot.js @@ -452,7 +452,7 @@ function Botkit(configuration) { } else { return false; } - + } this.cloneMessage = function(message) { @@ -790,9 +790,17 @@ function Botkit(configuration) { // the pattern might be a string to match (including regular expression syntax) // or it might be a prebuilt regular expression - var test; + var test = null; if (typeof(tests[t]) == 'string') { - test = new RegExp(tests[t], 'i'); + try { + test = new RegExp(tests[t], 'i'); + } catch(err) { + botkit.log('Error in regular expression: ' + tests[t] + ': ' + err); + return false; + } + if (!test) { + return false; + } } else { test = tests[t]; }