Sha256: 637b5c56c557beaf0c12d9d948a6713c97e40babfe111700c357bc84a67160e3

Contents?: true

Size: 905 Bytes

Versions: 16

Compression:

Stored size: 905 Bytes

Contents

require 'slack-ruby-client'

raise 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS')

$stdout.sync = true
logger = Logger.new($stdout)
logger.level = Logger::DEBUG
threads = []

ENV['SLACK_API_TOKENS'].split.each do |token|
  logger.info "Starting #{token[0..12]} ..."

  client = Slack::RealTime::Client.new(token: token)

  client.on :hello do
    logger.info "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|
    logger.info 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

  threads << client.start_async
end

threads.each(&:join)

Version data entries

16 entries across 8 versions & 1 rubygems

Version Path
slack-ruby-client-0.14.4 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.14.4 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.14.3 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.14.3 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.14.2 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.14.2 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.14.1 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.14.1 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.14.0 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.14.0 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.13.1 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.13.1 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.13.0 examples/hi_real_time_async_eventmachine/hi.rb
slack-ruby-client-0.13.0 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.12.0 examples/hi_real_time_async_celluloid/hi.rb
slack-ruby-client-0.12.0 examples/hi_real_time_async_eventmachine/hi.rb