class SlackRubyBot::App

Public Class Methods

configure!() click to toggle source
# 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
instance() click to toggle source
# File lib/slack-ruby-bot/app.rb, line 9
def self.instance
  @instance ||= begin
    configure!
    new(token: SlackRubyBot.config.token)
  end
end

Public Instance Methods

config() click to toggle source
# File lib/slack-ruby-bot/app.rb, line 5
def config
  SlackRubyBot.config
end

Private Instance Methods

hello(client, _data) click to toggle source
Calls superclass method
# File lib/slack-ruby-bot/app.rb, line 30
def hello(client, _data)
  if client.team && client.self
    SlackRubyBot.configure do |config|
      config.url = "https://#{client.team.domain}.slack.com"
      config.team = client.team.name
      config.team_id = client.team.id
      config.user = client.self.name
      config.user_id = client.self.id
      logger.info "Welcome #{config.user} to the #{config.team} team."
    end
  end
  super
end
reset!() click to toggle source
Calls superclass method
# File lib/slack-ruby-bot/app.rb, line 44
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