Sha256: e5b7fdcc475c349a565883d713d1c122ee931b80769d7ec0cf48ba261d0b5104

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

require_relative 'ext/slack-ruby-bot/client'

module SlackRubyBotServer
  class Server < SlackRubyBot::Server
    attr_accessor :team

    def initialize(attrs = {})
      attrs = attrs.dup
      @team = attrs.delete(:team)
      raise 'Missing team' unless @team

      attrs[:token] = @team.token
      super(attrs)
      open!
    end

    def restart!(wait = 1)
      # when an integration is disabled, a live socket is closed, which causes the default behavior of the client to restart
      # it would keep retrying without checking for account_inactive or such, we want to restart via service which will disable an inactive team
      logger.info "#{team.name}: socket closed, restarting ..."
      SlackRubyBotServer::Service.instance.restart! team, self, wait
      open!
    end

    private

    def open!
      client.owner = team
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.12.0 lib/slack-ruby-bot-server/server.rb