LoginSignup
0
1

More than 5 years have passed since last update.

hubotでscriptを書いてみる

Last updated at Posted at 2015-11-23

はじめに

hubotでscriptを書くときのお約束とかの私の私による私のための覚書

respondとhearの違い

  • respondは呼びかけに反応
module.exports = (robot) ->
  robot.respond /いぇいいぇい/i, (res) ->
    res.send "いぇいいぇい"

って時は

Kiriko: @hubot いぇいいぇい
Hubot: いぇいいぇい
Kiriko: いぇいいぇい

ッて感じで、呼びかけないと返答がない

  • hearは発言の内容に反応
module.exports = (robot) ->
  robot.hear /いぇいいぇい/i, (res) ->
    res.send "いぇいいぇい"

って時は

Kiriko: @hubot いぇいいぇい
Hubot: いぇいいぇい
Kiriko: いぇいいぇい
Hubot: いぇいいぇい

ッて感じで、呼びかけても呼びかけてなくても反応が帰ってくる
hearを使うと他の人との会話の中に該当の言葉が入ってたら割り込んでくる感じかな

replyとsendの違い

module.exports = (robot) ->
  robot.respond /いぇいいぇい/i, (res) ->
    res.reply "いぇいいぇい"

って時は

Kiriko: @hubot いぇいいぇい
Hubot: @Kiriko いぇいいぇい

ッて感じで、メンションをつけて返してくれる

  • hearは発言の内容に反応
module.exports = (robot) ->
  robot.respond /いぇいいぇい/i, (res) ->
    res.send "いぇいいぇい"

って時は

Kiriko: @hubot いぇいいぇい
Hubot: いぇいいぇい

ッて感じで、ただ発言するだけ
respondの時にsendで書いてると悲しくなりますね

今日はここまで随時更新してゆきます

0
1
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
0
1