slack-notifier で画像を投稿する

前提

  • slack-notifier を用いる
  • 画像ファイルを直接 POST することはできない
  • 画像ファイルの URI を POST する

結論

require 'slack-notifier'

notifier = Slack::Notifier.new 'WEBHOOKS_URI' do
  defaults channel: '#DEFAULT NO CHANNEL NAME'
end

attachment_image = {
  title: 'はてなのロゴ',
  image_url: 'http://www.hatena.ne.jp/images/portal/logo-portal-top2@2x.png',
}
notifier.ping 'はてなのロゴ画像です!', attachments: [attachment_image]

結果

f:id:gregminster:20181216125838p:plain

補足

2018/12/16 現在の内容です。

Powered by はてなブログ