我有一个在 IRC 上运行的 Hubot 实例。在我的脚本目录中,我有几个咖啡脚本链接到外部 python 脚本。我的问题是我的数据应该在外部脚本中的其他数据之前打印出来,例如“处理请求。请稍候......”等,Hubot 等待整个脚本完全完成执行并立即转储 IRC 的输出.
如何修改我的咖啡脚本以在收到外部脚本时发送输出?
咖啡脚本示例:
# Commands:
# Hubot jira-add-comment <ticket> "comment" - Add given comment to a JIRA ticket
{spawn} = require 'child_process'
module.exports = (robot) ->
addComment = (msg,ticket,comment) ->
output = spawn "/path/to/externalscript.py", [ticket,comment]
output.stdout.on 'data', (data) ->
msg.send data.toString()
robot.respond /jira-add-comment (\w+-\d+) (.+)$/i, (msg) ->
addComment(msg,msg.match[1].trim(),msg.match[2])
谢谢!