Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
will committed Apr 25, 2018
0 parents commit cafe930
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.env
9 changes: 9 additions & 0 deletions Gemfile
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem 'slack-ruby-client'

gem 'celluloid-io', require: ['celluloid/current', 'celluloid/io']

gem 'dotenv'
69 changes: 69 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,69 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (5.2.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
celluloid (0.17.3)
celluloid-essentials
celluloid-extras
celluloid-fsm
celluloid-pool
celluloid-supervision
timers (>= 4.1.1)
celluloid-essentials (0.20.5)
timers (>= 4.1.1)
celluloid-extras (0.20.5)
timers (>= 4.1.1)
celluloid-fsm (0.20.5)
timers (>= 4.1.1)
celluloid-io (0.17.3)
celluloid (>= 0.17.2)
nio4r (>= 1.1)
timers (>= 4.1.1)
celluloid-pool (0.20.5)
timers (>= 4.1.1)
celluloid-supervision (0.20.6)
timers (>= 4.1.1)
concurrent-ruby (1.0.5)
dotenv (2.4.0)
faraday (0.15.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
gli (2.17.1)
hashie (3.5.7)
hitimes (1.2.6)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
multipart-post (2.0.0)
nio4r (2.3.0)
slack-ruby-client (0.11.1)
activesupport
faraday (>= 0.9)
faraday_middleware
gli
hashie
websocket-driver
thread_safe (0.3.6)
timers (4.1.2)
hitimes
tzinfo (1.2.5)
thread_safe (~> 0.1)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)

PLATFORMS
ruby

DEPENDENCIES
celluloid-io
dotenv
slack-ruby-client

BUNDLED WITH
1.16.1
1 change: 1 addition & 0 deletions Procfile
@@ -0,0 +1 @@
worker: bundle exec ruby typing.rb
30 changes: 30 additions & 0 deletions typing.rb
@@ -0,0 +1,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

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

client.start_async
end

loop do
Thread.pass
end

1 comment on commit cafe930

@KonstantinCodes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cafe :D

Please sign in to comment.