hubot-command-mapper
Version:
Helps with mapping tools and commands to Hubot.
17 lines (16 loc) • 555 B
JavaScript
import { CommandResolver } from "../entities/CommandResolver.mjs";
export function addDiagnosticsMiddleware(robot, callback) {
if (!robot)
throw "Argument 'robot' is empty.";
if (!callback)
throw "Argument 'callback' is empty.";
robot.receiveMiddleware(async (context) => {
const resolver = new CommandResolver(robot);
const action = resolver.resolve(context.response);
if (action) {
const debug = action.getDebugInfo();
callback(debug);
}
return true;
});
}