Sha256: 609a933a4aa8b9337f273eadf4c379f533fd69dcdff4f61b49cb20683e3bd74c
Contents?: true
Size: 906 Bytes
Versions: 7
Compression:
Stored size: 906 Bytes
Contents
require 'slack-ruby-client' require 'async' 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 /hi/ then client.message channel: data.channel, text: "Hi <@#{data.user}>!" else client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?" end end threads << client.start_async end threads.each(&:join)
Version data entries
7 entries across 7 versions & 1 rubygems