Sha256: 4f177e9867c341cea3a7908a9099ad6cbdca46f5d77c07e989e129d9944eee41

Contents?: true

Size: 716 Bytes

Versions: 13

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true
require 'slack-ruby-client'

Slack.configure do |config|
  config.token = ENV['SLACK_API_TOKEN']
  raise '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'
    client.web_client.chat_postMessage channel: data.channel, text: "Hi <@#{data.user}>!"
  when /^bot/
    client.web_client.chat_postMessage channel: data.channel, text: "Sorry <@#{data.user}>, what?"
  end
end

client.start!

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
slack-ruby-client-2.4.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-2.3.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-2.2.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-2.1.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-2.0.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-1.1.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-1.0.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.17.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.16.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.15.1 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.15.0 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.14.6 examples/hi_real_time_and_web/hi.rb
slack-ruby-client-0.14.5 examples/hi_real_time_and_web/hi.rb