12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Hubotでusing deprecated documentation syntax

Posted at

ping.coffeeをping.jsへ書き換えようとしたときに生じたエラー(?

##もとのping.coffee

# Description:
#   Utility commands surrounding Hubot uptime.
#
# Commands:
#   hubot ping - Reply with pong
#   hubot echo <text> - Reply back with <text>
#   hubot time - Reply with current time
#   hubot die - End hubot process

module.exports = (robot) ->
  robot.respond /PING$/i, (msg) ->
    msg.send "PONG!"

  robot.respond /ADAPTER$/i, (msg) ->
    msg.send robot.adapterName

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

  robot.respond /TIME$/i, (msg) ->
    msg.send "Server time is: #{new Date()}"

  robot.respond /DIE$/i, (msg) ->
    msg.send "Goodbye, cruel world."
    process.exit 0

ここから単純なコマンドでここだけ抜き出そうとしたら、

module.exports = (robot) ->
  robot.respond /PING$/i, (msg) ->
    msg.send "PONG!"

実行するとこんなメッセージが

[Tue Oct 14 2014 18:50:59 GMT+0900 (JST)] INFO /Users/ryousuke/Sites/offside/hubot/scripts/bbpull.js is using deprecated documentation syntax

##descriptionを入れる必要があるみたい

たぶんドキュメントに書いてるんだろうけど..

# Description:
#   Utility commands surrounding Hubot uptime.
#
# Commands:
#   hubot ping - Reply with pong
#   hubot echo <text> - Reply back with <text>
#   hubot time - Reply with current time
#   hubot die - End hubot process

module.exports = (robot) ->
  robot.respond /PING$/i, (msg) ->
    msg.send "PONG!"

###js変換するとこんな感じです。 commandsは無くても問題ないかも。

// Description:
//   Messing around with the today API.
// Commands:
//   hubot today  - Return today at random.

module.exports = function(robot) {
  return robot.respond(/BBB$/i, function(msg) {
    return msg.send("PONGbbb!");
  });
};

##まとめ
hubotはコメントアウトのメッセージまで読み込んでたんですね。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?