Sha256: 5e59ceaaf5adfbb7b73c33308c4083353df7fa86c4b5c7d9df16f7e6957d608e

Contents?: true

Size: 827 Bytes

Versions: 7

Compression:

Stored size: 827 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)
      client.owner = @team
    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
      client.owner = team
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.6.1 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.6.0 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.5.0 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.4.0 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.3.1 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.3.0 lib/slack-ruby-bot-server/server.rb
slack-ruby-bot-server-0.2.0 lib/slack-ruby-bot-server/server.rb