message: Add new `heard` middleware endpoint for running things _after_ a trigger is detected
diff: @@ -38,6 +38,7 @@ function Botkit(configuration) {
  send: ware(),
  receive: ware(),
  spawn: ware(),
  + heard: ware(),
  };
  @@ -127,7 +128,9 @@ function Botkit(configuration) {
  var match, patterns = this.handler;
  for (var p = 0; p < patterns.length; p++) {
  if (patterns[p].pattern && botkit.hears_test([patterns[p].pattern], message)) {
  + botkit.middleware.heard.run(this.task.bot, message, function(err, bot, message) {
  patterns[p].callback(message, this);
  + });
  return;
  }
  }
  @@ -136,7 +139,9 @@ function Botkit(configuration) {
  // if a default exists, fire it!
  for (var p = 0; p < patterns.length; p++) {
  if (patterns[p].default) {
  + botkit.middleware.heard.run(this.task.bot, message, function(err, bot, message) {
  patterns[p].callback(message, this);
  + });
  return;
  }
  }
  @@ -942,8 +947,10 @@ function Botkit(configuration) {
  botkit.on(events[e], function(bot, message) {
  if (test_function && test_function(keywords, message)) {
  botkit.debug('I HEARD', keywords);
  + botkit.middleware.heard.run(bot, message, function(err, bot, message) {
  cb.apply(this, [bot, message]);
  botkit.trigger('heard_trigger', [bot, keywords, message]);
  + });
  return false;
  }
  });
  