LoginSignup
2
1

More than 5 years have passed since last update.

hubotでgithubのプルリクのコメントがslackに流れた時のコメントを拾う

Posted at

hubotでbotの発言を拾う

この辺でgithubのプルリクのコメントが拾えるー。やったー!と思っていたら多少修正が必要であった。

参考にさせていただいた、

こちらの書き方にそった形で拾えるように修正するには、以下のようになおせばOK。

module.exports = (robot) ->
  robot.catchAll (msg) ->
    r = new RegExp "(.*)(どーなつ|ドーナツ)(.*)", "i"
    if msg.message.rawMessage.attachments?
      matches = msg.message.rawMessage.attachments[0].text.match(r)
    else
      matches = msg.message.text.match(r)

    if matches == null or matches.length == 0
      return
    msg.send "どーんといこう!"

基本はconsole.logでいろいろ値を見ていったり、

この辺を見てイメージを掴んだ。

これで、slackの発言も拾えるし、githubのプルリクのコメントも拾えるようになったので、
僕がやりたかったプルリクのコメントを拾って、レビュー担当さんを呼び出す事も出来るようになったわけだ。

めでたしめでたし。

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