grammy 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/bot.js CHANGED
@@ -301,7 +301,7 @@ you can circumvent this protection against memory leaks.`);
301
301
  }
302
302
  else
303
303
  debugErr(error);
304
- debugErr("Call to `getUpdates` failed, retrying in 3 seconds ...");
304
+ debugErr("Call to getUpdates failed, retrying in 3 seconds ...");
305
305
  await new Promise((r) => setTimeout(r, 3000));
306
306
  };
307
307
  while (this.pollingRunning) {
@@ -313,7 +313,10 @@ you can circumvent this protection against memory leaks.`);
313
313
  updates = await this.api.getUpdates({ offset, limit, timeout, allowed_updates }, this.pollingAbortController.signal);
314
314
  }
315
315
  catch (error) {
316
- await handleErr(error);
316
+ if (this.pollingRunning)
317
+ await handleErr(error);
318
+ else
319
+ debug("Pending getUpdates request cancelled");
317
320
  }
318
321
  } while (updates === undefined && this.pollingRunning);
319
322
  if (updates === undefined)
package/out/context.d.ts CHANGED
@@ -771,7 +771,7 @@ export declare class Context implements RenamedUpdate {
771
771
  *
772
772
  * **Official reference:** https://core.telegram.org/bots/api#sendinvoice
773
773
  */
774
- replyWithInvoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: readonly LabeledPrice[], other?: Other<"sendInvoice", "title" | "description" | "payload" | "provider_token" | "start_parameter" | "currency" | "prices">, signal?: AbortSignal): Promise<Message.InvoiceMessage>;
774
+ replyWithInvoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: readonly LabeledPrice[], other?: Other<"sendInvoice", "title" | "description" | "payload" | "provider_token" | "currency" | "prices">, signal?: AbortSignal): Promise<Message.InvoiceMessage>;
775
775
  /**
776
776
  * Context-aware alias for `api.answerShippingQuery`. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
777
777
  *
@@ -218,7 +218,13 @@ export declare function lazySession<S, C extends Context>(options?: SessionOptio
218
218
  */
219
219
  export declare class MemorySessionStorage<S> implements StorageAdapter<S> {
220
220
  private readonly timeToLive;
221
- private readonly storage;
221
+ /**
222
+ * Internally used `Map` instance that stores the session data
223
+ */
224
+ protected readonly storage: Map<string, {
225
+ session: S;
226
+ expires?: number | undefined;
227
+ }>;
222
228
  /**
223
229
  * Constructs a new memory session storage with the given time to live. Note
224
230
  * that this storage adapter will not store your data permanently.
@@ -227,6 +233,11 @@ export declare class MemorySessionStorage<S> implements StorageAdapter<S> {
227
233
  */
228
234
  constructor(timeToLive?: number);
229
235
  read(key: string): S | undefined;
236
+ /**
237
+ * Reads the values for all keys of the session storage, and returns them as
238
+ * an array.
239
+ */
240
+ readAll(): S[];
230
241
  write(key: string, value: S): void;
231
242
  private addExpiryDate;
232
243
  delete(key: string): void;
@@ -218,6 +218,9 @@ class MemorySessionStorage {
218
218
  writable: true,
219
219
  value: timeToLive
220
220
  });
221
+ /**
222
+ * Internally used `Map` instance that stores the session data
223
+ */
221
224
  Object.defineProperty(this, "storage", {
222
225
  enumerable: true,
223
226
  configurable: true,
@@ -235,6 +238,16 @@ class MemorySessionStorage {
235
238
  }
236
239
  return value.session;
237
240
  }
241
+ /**
242
+ * Reads the values for all keys of the session storage, and returns them as
243
+ * an array.
244
+ */
245
+ readAll() {
246
+ return Array
247
+ .from(this.storage.keys())
248
+ .map((key) => this.read(key))
249
+ .filter((value) => value !== undefined);
250
+ }
238
251
  write(key, value) {
239
252
  this.storage.set(key, this.addExpiryDate(value));
240
253
  }
package/out/core/api.d.ts CHANGED
@@ -958,7 +958,7 @@ export declare class Api<R extends RawApi = RawApi> {
958
958
  *
959
959
  * **Official reference:** https://core.telegram.org/bots/api#sendinvoice
960
960
  */
961
- sendInvoice(chat_id: number | string, title: string, description: string, payload: string, provider_token: string, currency: string, prices: readonly LabeledPrice[], other?: Other<R, "sendInvoice", "title" | "description" | "payload" | "provider_token" | "start_parameter" | "currency" | "prices">, signal?: AbortSignal): Promise<import("@grammyjs/types/message").Message.InvoiceMessage>;
961
+ sendInvoice(chat_id: number | string, title: string, description: string, payload: string, provider_token: string, currency: string, prices: readonly LabeledPrice[], other?: Other<R, "sendInvoice", "title" | "description" | "payload" | "provider_token" | "currency" | "prices">, signal?: AbortSignal): Promise<import("@grammyjs/types/message").Message.InvoiceMessage>;
962
962
  /**
963
963
  * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
964
964
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grammy",
3
3
  "description": "The Telegram Bot Framework.",
4
- "version": "1.5.2",
4
+ "version": "1.5.3",
5
5
  "author": "KnorpelSenf",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -23,7 +23,7 @@
23
23
  "contribs": "all-contributors"
24
24
  },
25
25
  "dependencies": {
26
- "@grammyjs/types": "^2.4.3",
26
+ "@grammyjs/types": "^2.4.5",
27
27
  "abort-controller": "^3.0.0",
28
28
  "debug": "^4.3.3",
29
29
  "node-fetch": "^2.6.5"