Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Hubotでusing deprecated documentation syntax

More than 5 years have passed since last update.

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はコメントアウトのメッセージまで読み込んでたんですね。

n0bisuke
プロトタイピング専門スクール「プロトアウトスタジオ」で教えたりしてます。 プロフ -> https://dotstud.io/members/n0bisuke
https://protoout.studio
dotstudio
全ての人がモノづくりを楽しむ世界を目指して活動しています。 ( https://dotstud.io ) プロトタイピングスクールの運営をしています。
https://protoout.studio
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away