Sha256: 72bc33ccfc05cbebfdb3bd1909044fa85d5a33254da64716ec815ec238b266e4

Contents?: true

Size: 677 Bytes

Versions: 16

Compression:

Stored size: 677 Bytes

Contents

require 'slack-ruby-client'

Slack.configure do |config|
  config.token = ENV['SLACK_API_TOKEN']
  fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new

client.on :hello do
  puts "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
end

client.on :message do |data|
  puts data
  case data.text
  when 'bot hi' then
    client.web_client.chat_postMessage channel: data.channel, text: "Hi <@#{data.user}>!"
  when /^bot/ then
    client.web_client.chat_postMessage channel: data.channel, text: "Sorry <@#{data.user}>, what?"
  end
end

client.start!

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
slack-ruby-client-0.10.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.9.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.9.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.8.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.8.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.9 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.8 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.7 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.6 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.5 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.4 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.3 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.2 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.7.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.6.0 examples/hi_real_time_and_web/hi.rb