1

有没有办法返回 Hubot 听到/响应的原始消息?

试图访问message@message但在调用时似乎出错了。

寻找类似的东西:

robot.respond /test/, (msg) ->
  msg.send msg.the_message_that_the_user_typed_in

在此示例中,它将回显用户输入的整个文本。

实际上,我会玩弄文本并删除一些东西,但我想要原始文本的精确副本来乱搞。

4

1 回答 1

4

Try using catchAll:

robot.catchAll (msg) ->
  msg.send msg.message.text

However it will match a message that no other matchers matched. If you want to catch absolutely everything, you'll have to do this:

robot.respond /(.*)/, (msg) ->
  msg.send msg.match[1]

Update:

Question was how to get the original message, not how to catch all messages. Answer:

robot.respond /test/, (msg) ->
  msg.send msg.message.text
于 2014-03-23T03:39:43.147 回答