typescript-telegram-bot-api
Advanced tools
Comparing version 0.1.13 to 0.1.16
@@ -22,2 +22,3 @@ "use strict"; | ||
this.autoRetry = options.autoRetry ?? true; | ||
this.autoRetryLimit = options.autoRetryLimit || 0; | ||
this.polling = new pooling_1.Polling(this, []); | ||
@@ -108,3 +109,5 @@ } | ||
const error = response; | ||
if (this.autoRetry && error.parameters?.retry_after) { | ||
if (this.autoRetry && | ||
error.parameters?.retry_after && | ||
error.parameters?.retry_after < this.autoRetryLimit) { | ||
await wait(error.parameters.retry_after * 1000); | ||
@@ -1163,3 +1166,5 @@ return await this.callApi(method, options); | ||
...options, | ||
shipping_options: JSON.stringify(options.shipping_options), | ||
shipping_options: 'shipping_options' in options | ||
? JSON.stringify(options.shipping_options) | ||
: undefined, | ||
}); | ||
@@ -1166,0 +1171,0 @@ } |
@@ -35,19 +35,11 @@ "use strict"; | ||
while (!this.abortController.signal.aborted) { | ||
try { | ||
const updates = await this.telegramBot.getUpdates({ | ||
offset: this.offset, | ||
allowed_updates: this.allowedUpdates, | ||
timeout: 50, | ||
}, this.abortController); | ||
for (const update of updates) { | ||
this.emitUpdate(update); | ||
this.offset = update.update_id + 1; | ||
} | ||
const updates = await this.telegramBot.getUpdates({ | ||
offset: this.offset, | ||
allowed_updates: this.allowedUpdates, | ||
timeout: 50, | ||
}, this.abortController); | ||
for (const update of updates) { | ||
this.emitUpdate(update); | ||
this.offset = update.update_id + 1; | ||
} | ||
catch (error) { | ||
if (error instanceof Error && error.name === 'AbortError') { | ||
break; | ||
} | ||
throw error; | ||
} | ||
} | ||
@@ -54,0 +46,0 @@ } |
{ | ||
"type": "commonjs", | ||
"name": "typescript-telegram-bot-api", | ||
"version": "0.1.13", | ||
"version": "0.1.16", | ||
"description": "Telegram Bot API wrapper for Node.js written in TypeScript", | ||
@@ -39,2 +39,3 @@ "repository": "github:Borodin/typescript-telegram-bot-api", | ||
"eslint": "^8.57.0", | ||
"nock": "^13.5.4", | ||
"prettier": "^3.3.2", | ||
@@ -53,3 +54,8 @@ "ts-jest": "^29.1.4", | ||
"collectCoverage": true, | ||
"coverageReporters": ["json", "lcov", "text", "clover"], | ||
"coverageReporters": [ | ||
"json", | ||
"lcov", | ||
"text", | ||
"clover" | ||
], | ||
"coverageDirectory": "coverage" | ||
@@ -56,0 +62,0 @@ }, |
Sorry, the diff of this file is too big to display
243084
5767
12