Open noobbbbb opened 6 years ago
Cannot read property 'roomID' of undefined
means the whole object is undefined, not just the roomID
property.
This is a bug, thanks for reporting. The adapter should check if there's a user, before checking properties of the user. e.g. at https://github.com/RocketChat/hubot-rocketchat/blob/master/index.js#L146 - should be if (envelope.user && envelope.user.roomID)
this is probably something that came through from the coffee script conversion, because coffeescript has a nice existential operator that's missing in standard JS.
I will fix this in the adapter asap. But for now, you can include an empty user in your envelope and call the send from the adapter directly which should satisfy the condition...
module.exports = function(robot) {
robot.router.post('/hubot/hoge/:room', function(req, res) {
let room = req.params.room
data = req.body.payload
robot.adapter.send({ room, user: {} }, 'hoge Posted!')
res.send('OK')
})
}
Please try that and comment if it works or not.
Thank you for your reply. I corrected the script according to the proposal, and confirmed that it works normally!
Great. I'll just leave this open though until we've address the bug handling sendToRoom
.
I'm using Google's translation application...
I have failed to call "robot.messageRoom":
Error Message:
/hubot-rocketchat-boilerplate/node_modules/hubot-rocketchat/index.js:155:25
If this is done as below it will work normally
What are the reasons why 'roomID' can not be recognized? Please advise me.
regards.