response.send理解? (hubot脚本)

时间:2017-10-14 04:52:28

标签: javascript node.js coffeescript hubot

我最近安装了hubot并正在测试它。

现在我看到了......我不明白:

鉴于此代码(hubot-maps的一部分 - maps.coffee file

robot.respond /(?:(satellite|terrain|hybrid)[- ])?map( me)? (.+)/i, (msg) ->
mapType  = msg.match[1] or "roadmap"
location = encodeURIComponent(msg.match[3])
mapUrl   = "http://maps.google.com/maps/api/staticmap?markers=" +
            location +
            "&size=400x400&maptype=" +
            mapType +
            "&sensor=false" +
            "&format=png" # So campfire knows it's an image
url      = "http://maps.google.com/maps?q=" +
           location +
          "&hl=en&sll=37.0625,-95.677068&sspn=73.579623,100.371094&vpsrc=0&hnear=" +
          location +
          "&t=m&z=11"

msg.send mapUrl
msg.send url

为什么我会得到这样的回复

enter image description here

我先获得url然后mapUrl

我希望首先获得mapUrl,然后url

1 个答案:

答案 0 :(得分:2)

this hubot PR开始,看起来Hubot异步运行您的knit_child('child.file', quiet=TRUE),因此无法保证订单。

  

作为副作用,侦听器现在异步执行。行为   message.done周围应该保持不变(进程直到message.done   是真的)。​​

如果您希望在msg.send之前mapUrl,则可以查看source code中的发送功能,该功能接受有序字符串列表。

url