Sha256: 233df311120d379931443431244af2f91682fac629c8369440e3b6bdf4a16d25

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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 ||= SlackRubyBot::App.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

1 entries across 1 versions & 1 rubygems

Version Path
slack-ruby-bot-0.5.0 lib/slack-ruby-bot/app.rb