[英]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. 我在flowdock上使用Hubot,我试图让Hubot自动发布用户命令的响应。
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. 在https://leanpub.com/automation-and-monitoring-with-hubot/read#leanpub-auto-periodic-task-execution的帮助下,我成功地在特定的时间让Hubot谈话创建了一个cron。咖啡脚本,所以没有问题。
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. 问题是我有另一个脚本( trello.coffee )使Hubot响应命令“show cards”,我希望在特定时间发布此命令的结果,而不需要告诉Hubot这样做。
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? 如果不需要编写另一个脚本(即trello.auto.coffee )和整个robot.emit - > robot.on程序,我究竟能做到这一点?
What about using the http listener? 那么使用http监听器呢? This page has a section for HTTP Listener and has this code example:
此页面有一个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'
Would that work? 那会有用吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.