@veluga/telegram
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -877,6 +877,7 @@ "use strict"; | ||
async request(apiMethod, params = {}) { | ||
let attempt = Number(params.__attempt__) || 0; | ||
let leftAttempts = params.__leftAttempts ??= this.config.maxFailuresInRow; | ||
const url = this.getApiEndpoint(apiMethod); | ||
const form = this.createFormDataFromParams(params); | ||
const timeout = apiMethod === "getUpdates" ? (this.LONGPOLL_TIMEOUT + 4) * 1e3 : 5e3; | ||
let status = void 0; | ||
try { | ||
@@ -891,3 +892,4 @@ const controller = new AbortController(); | ||
clearTimeout(timeoutId); | ||
const { status, statusText } = request; | ||
const { statusText } = request; | ||
status = request.status; | ||
const data = await request.json(); | ||
@@ -900,3 +902,4 @@ if (data?.ok) { | ||
console.error("error occurred:", /* @__PURE__ */ new Date(), error); | ||
if ((params.__attempt__ = ++attempt) <= this.config.maxFailuresInRow) { | ||
--leftAttempts; | ||
if (status !== 400 && leftAttempts > 0) { | ||
await delay(3e3); | ||
@@ -903,0 +906,0 @@ return this.request(apiMethod, params); |
{ | ||
"name": "@veluga/telegram", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Library for Telegram Bot API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
499404
8563