Class: SlackRubyBot::App

Inherits:
Server
  • Object
show all
Defined in:
lib/slack-ruby-bot/app.rb

Constant Summary

Constants inherited from Server

Server::TRAPPED_SIGNALS

Instance Attribute Summary

Attributes inherited from Server

#aliases, #token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Server

#initialize, #run, #start!, #start_async, #stop!

Methods included from Hooks::HookSupport

#add_hook_handlers, #flush_hook_blocks, included, #on

Methods included from Loggable

included

Constructor Details

This class inherits a constructor from SlackRubyBot::Server

Class Method Details

.configure!Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/slack-ruby-bot/app.rb', line 16

def self.configure!
  SlackRubyBot.configure do |config|
    config.token = ENV['SLACK_API_TOKEN'] if ENV.key?('SLACK_API_TOKEN')
    raise('Missing Slack API Token.') unless config.token.present?

    config.aliases = ENV['SLACK_RUBY_BOT_ALIASES'].split(' ') if ENV.key?('SLACK_RUBY_BOT_ALIASES')
  end
  Slack.configure do |config|
    config.token = SlackRubyBot.config.token
  end
end

.instanceObject



9
10
11
12
13
14
# File 'lib/slack-ruby-bot/app.rb', line 9

def self.instance
  @instance ||= begin
    configure!
    new(token: SlackRubyBot.config.token)
  end
end

Instance Method Details

#configObject



5
6
7
# File 'lib/slack-ruby-bot/app.rb', line 5

def config
  SlackRubyBot.config
end