简体   繁体   中英

How do I use send/topic from within a robot.router.post block in hubot

I've been hacking away with hubot for a few weeks now and loving it but have been stuck for a couple of days on the code snippet below. I have a listener that is receiving events via webhooks from our ticket system. That's working great! The problem I'm having is how do I then send some of this data to a room and update the topic?

Normally this is done via the msg.send or msg.topic callback that is sent with functions such as robot.respond but when using robot.router.post, I'm not clear on what object I should be referencing to send the message. Basically, how/where do I get msg defined within robot.router.post?

Apologies for newbness, I'm pretty new to all things javascript/coffeescript. Thanks!

module.exports = (robot) ->

  robot.router.post "/hubot/ticket_change", (req, res) ->
    ticket_info = req.body.issue.name + ": " + req.body.issue.summary
    robot.send ticket_info
    robot.topic ticket_info
room = <room id>
robot.messageRoom room, ticket_info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM