lib/telegram/bot/client.rb in telegram-bot-ruby-0.2.3 vs lib/telegram/bot/client.rb in telegram-bot-ruby-0.2.4

- old
+ new

@@ -1,25 +1,26 @@ module Telegram module Bot class Client - attr_reader :api, :offset + attr_reader :api, :offset, :timeout def self.run(*args, &block) new(*args).run(&block) end - def initialize(token) + def initialize(token, timeout = 20) @api = Api.new(token) @offset = 0 + @timeout = timeout end def run yield self end def listen loop do - response = api.getUpdates(offset: offset) + response = api.getUpdates(offset: offset, timeout: timeout) next unless response['ok'] response['result'].each do |data| update = Types::Update.new(data) @offset = update.update_id.next