-
Notifications
You must be signed in to change notification settings - Fork 62
/
typing.rb
30 lines (21 loc) · 795 Bytes
/
typing.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'dotenv/load'
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(:user_typing) do |data|
logger.info data
client.typing channel: data.channel
#client.message channel: data.channel, text: "What are you typing <@#{data.user}>?"
end
threads << client.start_async
end
threads.each(&:join)