Sha256: fc9758757873857809b54a79a5f44a1547b363ea1fa6c9bf8dada661678547f8
Contents?: true
Size: 784 Bytes
Versions: 3
Compression:
Stored size: 784 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 client.on :close do |_data| puts 'Connection closed, exiting.' EM.stop end client.start!
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
slack-ruby-client-bhe-0.5.5 | examples/hi_real_time/hi.rb |
slack-ruby-client-bhe-0.5.4 | examples/hi_real_time/hi.rb |
slack-ruby-client-0.5.4 | examples/hi_real_time/hi.rb |