Sha256: 554f02a77dd74ec0b18f48ac502c0545c19f0965555d861035b84457db9787cd

Contents?: true

Size: 428 Bytes

Versions: 4

Compression:

Stored size: 428 Bytes

Contents

# frozen_string_literal: true

module Botkit
  class Runner
    attr_reader :bot, :polling

    def initialize(bot, polling: 1)
      @bot = bot
      @polling = polling
    end

    def call
      loop do
        next_tick
        break if bot.halt?
        sleep(polling)
      end
    end

    private def next_tick
      bot.call
    rescue StandardError => exception
      bot.report_exception(exception)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
botkit-0.0.4 lib/botkit/runner.rb
botkit-0.0.3 lib/botkit/runner.rb
botkit-0.0.2 lib/botkit/runner.rb
botkit-0.0.1 lib/botkit/runner.rb