Sha256: 77421afed96986ad53b0738716df9c44414b5e1be9550ec8b80a365d375d440c

Contents?: true

Size: 725 Bytes

Versions: 7

Compression:

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

  client.typing channel: data['channel']

  case data['text']
  when 'bot hi' then
    client.message channel: data['channel'], text: "Hi <@#{data['user']}>!"
  when /^bot/ then
    client.message channel: data['channel'], text: "Sorry <@#{data['user']}>, what?"
  end
end

EM.run do
  client.start_async
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
slack-ruby-client-bhe-0.5.5 examples/hi_real_time_async/hi.rb
slack-ruby-client-bhe-0.5.4 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.5.4 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.5.3 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.5.2 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.5.1 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.5.0 examples/hi_real_time_async/hi.rb