Sha256: 04dc165d4eb7bda8303a74ffa0eaa8075ae959d5dec887c8e747722c54b9ebd7

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

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

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-client-0.7.2 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.7.1 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.7.0 examples/hi_real_time_async/hi.rb
slack-ruby-client-0.6.0 examples/hi_real_time_async/hi.rb