Sha256: 3353b83690423a3bedd96d41bae653de145757e54494bf5e500d8f6c143ee5e6
Contents?: true
Size: 885 Bytes
Versions: 26
Compression:
Stored size: 885 Bytes
Contents
require 'slack-ruby-client' fail 'Missing ENV[SLACK_API_TOKENS]!' unless ENV.key?('SLACK_API_TOKENS') $stdout.sync = true logger = Logger.new($stdout) logger.level = Logger::DEBUG 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 client.start_async end loop do Thread.pass end
Version data entries
26 entries across 13 versions & 1 rubygems