Not getting script respond from hubby
PacMacCock opened this issue · comments
So I making a post request to hubot-adapter I don't know why it is not trigger any scripts. I don't actually have a chat client. There's no user, id, room.
let Adapter, Robot, TextMessage, User, TextListener;
try {
({Robot,Adapter,TextMessage,User, TextListener} = require('hubot'));
} catch (error) {
const prequire = require('parent-require');
({Robot,Adapter,TextMessage,User, TextListener} = prequire('hubot'));
}
class Sample extends Adapter {
constructor() {
super(...arguments);
this.robot.logger.info("Constructor");
}
send(envelope, ...strings) {
return this.robot.logger.info("Send");
}
reply(envelope, ...strings) {
return this.robot.logger.info("Reply");
}
run() {
this.robot.router.post('/app', (req, res) => {
const data = req.body.test;
const message = new TextMessage({}, data, 'MSG-001');
this.robot.receive(message);
return res.json({message: message});
});
this.emit('test', this.test);
this.robot.logger.info("Run");
this.emit("connected");
const user1 = new User(1001, {name: 'Sample User', room: "shell"});
const message = new TextMessage(user1, 'test', 'MSG-001');
//console.log(message);
return this.robot.receive(message);
}
}
exports.use = robot => new Sample(robot);
All I want is to trigger the script below from a post request.
module.exports = (robot) => {
robot.hear(/test/i, (res) => {
console.log('testing');
res.send("testing from script");
});
}
closing this as stale