Sha256: c982f900dd2d78b058a79c55dc00bc2fa16d8cac6091dbd88ea43508a69186e3

Contents?: true

Size: 701 Bytes

Versions: 12

Compression:

Stored size: 701 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

12 entries across 12 versions & 2 rubygems

Version Path
slack-ruby-client-bhe-0.5.5 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-bhe-0.5.4 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.5.4 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.5.3 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.5.2 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.5.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.5.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.4.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.3.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.3.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.2.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.2.0 examples/hi_real_time_and_web/hi.rb