【问题标题】:Make Hubot run preconfigured commands automatically让 Hubot 自动运行预配置的命令
【发布时间】:2015-04-25 21:39:39
【问题描述】:

我在 flowdock 上使用 Hubot,我正在尝试让 Hubot 自动发布用户命令的响应。

https://leanpub.com/automation-and-monitoring-with-hubot/read#leanpub-auto-periodic-task-execution 的帮助下,我设法让 Hubot 在特定时间说话,创建了一个 cron.coffee 脚本,所以这没有问题。

问题是我有另一个脚本 (trello.coffee),它使 Hubot 响应命令“显示卡”,我希望这个命令的结果在特定时间发布,而不需要我告诉 Hubot 这样做。

在不需要编写另一个脚本(即trello.auto.coffee)和整个robot.emit -> robot.on 过程的情况下,我该如何做到这一点?

【问题讨论】:

    标签: coffeescript cron hubot flowdock


    【解决方案1】:

    使用 http 监听器怎么样? This page 有一个 HTTP Listener 部分,并有以下代码示例:

    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'
    

    这行得通吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-16
      • 2017-09-21
      • 1970-01-01
      • 2018-09-21
      • 2021-04-10
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      相关资源
      最近更新 更多