From 1183ee7bc70be4596eb819717626d79fa2f8e853 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 12 Jan 2018 20:58:51 -0800 Subject: [PATCH] Add a timeout to the update polling. --- src/telepathy/bot.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/telepathy/bot.cr b/src/telepathy/bot.cr index 141cb0e..fc49f2f 100644 --- a/src/telepathy/bot.cr +++ b/src/telepathy/bot.cr @@ -18,8 +18,9 @@ module Telepathy return Response(User).from_json(response.body).result end - def get_updates - update_data = {} of String => Int64 | String + def get_updates(timeout = 0) + update_data = {} of String => Int64 | Int32 | String + update_data["timeout"] = timeout @last_update_id.try { |id| update_data["offset"] = id } response = HTTP::Client.get(@request_base + "/getUpdates", headers: HTTP::Headers{"User-agent" => "Telepathy", "Content-type" => "application/json" },