Class: SardonyxRing::App

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/sardonyx_ring/app.rb

Instance Method Summary collapse

Methods included from DSL

#action_handlers, #cron_handlers, #event_handlers, included, #message_handlers, #view_handlers

Constructor Details

#initialize(options = {}) ⇒ App

Returns a new instance of App.



7
8
9
10
11
12
# File 'lib/sardonyx_ring/app.rb', line 7

def initialize(options = {})
  @app_token = options[:app_token]
  @bot_token = options[:bot_token]
  @bot_auth = nil
  @logger = options[:logger] || Logger.new($stdout, level: :info)
end

Instance Method Details

#clientObject



14
15
16
# File 'lib/sardonyx_ring/app.rb', line 14

def client
  @client ||= Slack::Web::Client.new(token: @bot_token)
end

#socket_start!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sardonyx_ring/app.rb', line 18

def socket_start!
  fetch_bot_auth

  EM.run do
    start_cron

    socket_client = Services::SlackSocketClient.new(
      token: @app_token,
      logger: @logger
    )
    socket_client.on_message(&method(:handle_event))
    socket_client.connect!
  end
end