简体   繁体   中英

Make Hubot run preconfigured commands automatically

I'm using Hubot on flowdock and I'm trying to make Hubot post automatically the respond of a user command.

With the help of https://leanpub.com/automation-and-monitoring-with-hubot/read#leanpub-auto-periodic-task-execution , I've managed to make Hubot talk at a specific time creating a cron.coffee script, so no issues with that.

The thing is that I have another script ( trello.coffee ) that makes Hubot respond to the command "show cards" and I want the result of this command to be posted in a specific time without the need of me telling Hubot to do this.

How exactly can I do this without the need to write another script (ie. trello.auto.coffee ) and the whole robot.emit -> robot.on procedure?

What about using the http listener? This page has a section for HTTP Listener and has this code example:

module.exports = (robot) ->
  robot.router.post '/hubot/chatsecrets/:room', (req, res) ->
    room   = req.params.room
    data   = if req.body.payload? then JSON.parse req.body.payload else req.body
    secret = data.secret

    robot.messageRoom room, "I have a secret: #{secret}"

    res.send 'OK'

Would that work?

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