Sha256: 5f734de203c2fa4ed06164dbdab8e567c31386156f53783132be6501c5e37ef3

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module SlackRubyBot
  class App < Server
    def initialize
      SlackRubyBot.configure do |config|
        config.token = ENV['SLACK_API_TOKEN'] || fail("Missing ENV['SLACK_API_TOKEN'].")
        config.aliases = ENV['SLACK_RUBY_BOT_ALIASES'].split(' ') if ENV['SLACK_RUBY_BOT_ALIASES']
      end
      Slack.configure do |config|
        config.token = SlackRubyBot.config.token
      end
    end

    def config
      SlackRubyBot.config
    end

    def self.instance
      @instance ||= new
    end

    private

    def auth!
      super
      SlackRubyBot.configure do |config|
        config.url = client.auth['url']
        config.team = client.auth['team']
        config.user = client.auth['user']
        config.team_id = client.auth['team_id']
        config.user_id = client.auth['user_id']
      end
    end

    def reset!
      super
      SlackRubyBot.configure do |config|
        config.url = nil
        config.team = nil
        config.user = nil
        config.team_id = nil
        config.user_id = nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-bot-0.5.3 lib/slack-ruby-bot/app.rb
slack-ruby-bot-0.5.2 lib/slack-ruby-bot/app.rb
slack-ruby-bot-0.5.1 lib/slack-ruby-bot/app.rb