2016-01-31   ruby   slack 

RubyでSlackにメッセージ送る方法(slack-poster使う)

Refer

How To

$ gem install slack-poster
$ open https://TEAM-NAME.slack.com/services/new/incoming-webhook
$ vi hello.rb
$ cat hello.rb
require 'slack_poster'
WEBHOOK_URL = 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'
poster = Slack::Poster.new(WEBHOOK_URL)
poster.send_message('Hello world!')
$ ruby hello.rb

Option

require 'slack_poster'
WEBHOOK_URL = 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX'
poster = Slack::Poster.new(WEBHOOK_URL)
poster.username = 'The Ghost'
poster.icon_emoji = ':ghost:'
puts poster.send_message('Hello there!')

メモ

 2016-01-31   ruby   slack