我正在尝试从hubot控制台调试和玩hubot。
Hubot 脚本对在 hubot 控制台中写入的消息做出反应。
所以如果我有这样的脚本:
module.exports = (robot) ->
robot.respond /hi/, (msg) ->
msg.send "hi guy"
在我的hubot控制台中,我写了“hubot hi”,然后hubot会像这样回复:
$hubot> hubot hi
$hubot> hi guy
我的问题是如何对事件 ( robot.on
)做同样的事情。
就像我有这样的代码:
module.exports = (robot) ->
robot.on "github-repo-event", (event) ->
console.log "grrrr, I'm triggered"
那么我如何从hubot控制台触发这个事件?
有没有这样的......?
$hubot> hubot trigger-event:github-repo-event
我发现我能做的最简单的事情就是添加一个脚本来发出我想要的事件。
所以添加这样的东西:
# debug-script.coffee
module.exports = (robot) ->
robot.respond /debug-github-repo-event/, (msg) ->
robot.emit 'github-repo-event', eventData
然后从控制台你可以实现这个
$hubot> hubot debug-github-repo-event
$hubot> grrrr, I'm triggered
我不喜欢这个,但它有效。
我不想创建一个向 shell 适配器添加事件的适配器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句