grammy 1.18.0 → 1.18.2

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/README.md CHANGED
@@ -277,6 +277,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
277
277
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/PonomareVlad"><img src="https://avatars.githubusercontent.com/u/2877584?v=4?s=100" width="100px;" alt="Vladislav Ponomarev"/><br /><sub><b>Vladislav Ponomarev</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=PonomareVlad" title="Tests">⚠️</a> <a href="https://github.com/grammyjs/grammY/commits?author=PonomareVlad" title="Code">💻</a> <a href="#platform-PonomareVlad" title="Packaging/porting to new platform">📦</a></td>
278
278
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/louietyj"><img src="https://avatars.githubusercontent.com/u/11096034?v=4?s=100" width="100px;" alt="Louie Tan"/><br /><sub><b>Louie Tan</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Alouietyj" title="Reviewed Pull Requests">👀</a></td>
279
279
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/lejovaar7"><img src="https://avatars.githubusercontent.com/u/26439842?v=4?s=100" width="100px;" alt="Leandro Vargas"/><br /><sub><b>Leandro Vargas</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Alejovaar7" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=lejovaar7" title="Code">💻</a></td>
280
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/shaunnope"><img src="https://avatars.githubusercontent.com/u/19631195?v=4?s=100" width="100px;" alt="Sean Yap"/><br /><sub><b>Sean Yap</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ashaunnope" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=shaunnope" title="Code">💻</a></td>
281
+ <td align="center" valign="top" width="11.11%"><a href="https://sergeysolovev.com"><img src="https://avatars.githubusercontent.com/u/5831301?v=4?s=100" width="100px;" alt="Sergey Solovev"/><br /><sub><b>Sergey Solovev</b></sub></a><br /><a href="#ideas-sergeysolovev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Asergeysolovev" title="Reviewed Pull Requests">👀</a></td>
282
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/HeySreelal"><img src="https://avatars.githubusercontent.com/u/94184909?v=4?s=100" width="100px;" alt="Sree (Taylor's Version)"/><br /><sub><b>Sree (Taylor's Version)</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AHeySreelal" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=HeySreelal" title="Code">💻</a></td>
280
283
  </tr>
281
284
  </tbody>
282
285
  </table>
package/out/bot.js CHANGED
@@ -262,10 +262,12 @@ a known bot info object.");
262
262
  async start(options) {
263
263
  var _a, _b, _c;
264
264
  // Perform setup
265
+ const setup = [];
265
266
  if (!this.isInited()) {
266
- await this.init((_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal);
267
+ setup.push(this.init((_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal));
267
268
  }
268
269
  if (this.pollingRunning) {
270
+ await Promise.all(setup);
269
271
  debug("Simple long polling already running!");
270
272
  return;
271
273
  }
@@ -273,12 +275,13 @@ a known bot info object.");
273
275
  this.pollingRunning = true;
274
276
  this.pollingAbortController = new shim_node_js_1.AbortController();
275
277
  }
276
- await withRetries(() => {
278
+ setup.push(withRetries(async () => {
277
279
  var _a;
278
- return this.api.deleteWebhook({
280
+ await this.api.deleteWebhook({
279
281
  drop_pending_updates: options === null || options === void 0 ? void 0 : options.drop_pending_updates,
280
282
  }, (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal);
281
- }, (_b = this.pollingAbortController) === null || _b === void 0 ? void 0 : _b.signal);
283
+ }, (_b = this.pollingAbortController) === null || _b === void 0 ? void 0 : _b.signal));
284
+ await Promise.all(setup);
282
285
  // All async ops of setup complete, run callback
283
286
  await ((_c = options === null || options === void 0 ? void 0 : options.onStart) === null || _c === void 0 ? void 0 : _c.call(options, this.botInfo));
284
287
  // Bot was stopped during `onStart`
package/out/context.js CHANGED
@@ -27,7 +27,7 @@ const checker = {
27
27
  if (cmd.startsWith("/")) {
28
28
  throw new Error(`Do not include '/' when registering command handlers (use '${cmd.substring(1)}' not '${cmd}')`);
29
29
  }
30
- const set = cmd.indexOf("@") === -1 ? noAtCommands : atCommands;
30
+ const set = cmd.includes("@") ? atCommands : noAtCommands;
31
31
  set.add(cmd);
32
32
  });
33
33
  return (ctx) => {
@@ -49,8 +49,9 @@ const checker = {
49
49
  const index = cmd.indexOf("@");
50
50
  if (index === -1)
51
51
  return false;
52
- const atTarget = cmd.substring(index + 1);
53
- if (atTarget !== ctx.me.username)
52
+ const atTarget = cmd.substring(index + 1).toLowerCase();
53
+ const username = ctx.me.username.toLowerCase();
54
+ if (atTarget !== username)
54
55
  return false;
55
56
  const atCommand = cmd.substring(0, index);
56
57
  if (noAtCommands.has(atCommand)) {
@@ -1,7 +1,43 @@
1
+ import { DEFAULT_UPDATE_TYPES } from "../bot.js";
2
+ declare const ALL_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_join_request", "chat_member"];
3
+ declare const ALL_CHAT_PERMISSIONS: {
4
+ readonly can_send_messages: true;
5
+ readonly can_send_audios: true;
6
+ readonly can_send_documents: true;
7
+ readonly can_send_photos: true;
8
+ readonly can_send_videos: true;
9
+ readonly can_send_video_notes: true;
10
+ readonly can_send_voice_notes: true;
11
+ readonly can_send_polls: true;
12
+ readonly can_send_other_messages: true;
13
+ readonly can_add_web_page_previews: true;
14
+ readonly can_change_info: true;
15
+ readonly can_invite_users: true;
16
+ readonly can_pin_messages: true;
17
+ readonly can_manage_topics: true;
18
+ };
1
19
  /**
2
- * Contains lists of constants which are useful when working with the Bot API.
20
+ * Types of the constants used in the Telegram Bot API. Currently holds all
21
+ * available update types as well as all chat permissions.
3
22
  */
4
- export declare const API_CONSTANTS: Readonly<{
23
+ export interface ApiConstants {
24
+ /**
25
+ * List of update types a bot receives by default. Useful if you want to
26
+ * receive all update types but `chat_member`.
27
+ *
28
+ * ```ts
29
+ * // Built-in polling:
30
+ * bot.start({ allowed_updates: DEFAULT_UPDATE_TYPES });
31
+ * // grammY runner:
32
+ * run(bot, { runner: { fetch: { allowed_updates: DEFAULT_UPDATE_TYPES } } });
33
+ * // Webhooks:
34
+ * await bot.api.setWebhook(url, { allowed_updates: DEFAULT_UPDATE_TYPES });
35
+ * ```
36
+ *
37
+ * See the [Bot API reference](https://core.telegram.org/bots/api#update)
38
+ * for more information.
39
+ */
40
+ DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES[number];
5
41
  /**
6
42
  * List of all available update types. Useful if you want to receive all
7
43
  * updates from the Bot API, rather than just those that are delivered by
@@ -18,8 +54,11 @@ export declare const API_CONSTANTS: Readonly<{
18
54
  * // Webhooks:
19
55
  * await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
20
56
  * ```
57
+ *
58
+ * See the [Bot API reference](https://core.telegram.org/bots/api#update)
59
+ * for more information.
21
60
  */
22
- readonly ALL_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "poll", "poll_answer", "my_chat_member", "chat_join_request", "chat_member"];
61
+ ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES[number];
23
62
  /**
24
63
  * An object containing all available chat permissions. Useful if you want
25
64
  * to lift restrictions from a user, as this action requires you to pass
@@ -34,21 +73,23 @@ export declare const API_CONSTANTS: Readonly<{
34
73
  * await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
35
74
  * await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
36
75
  * ```
76
+ *
77
+ * See the [Bot API reference](https://core.telegram.org/bots/api#update)
78
+ * for more information.
37
79
  */
38
- readonly ALL_CHAT_PERMISSIONS: {
39
- readonly can_send_messages: true;
40
- readonly can_send_audios: true;
41
- readonly can_send_documents: true;
42
- readonly can_send_photos: true;
43
- readonly can_send_videos: true;
44
- readonly can_send_video_notes: true;
45
- readonly can_send_voice_notes: true;
46
- readonly can_send_polls: true;
47
- readonly can_send_other_messages: true;
48
- readonly can_add_web_page_previews: true;
49
- readonly can_change_info: true;
50
- readonly can_invite_users: true;
51
- readonly can_pin_messages: true;
52
- readonly can_manage_topics: true;
53
- };
54
- }>;
80
+ ALL_CHAT_PERMISSIONS: keyof typeof ALL_CHAT_PERMISSIONS;
81
+ }
82
+ interface TypeOf {
83
+ DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES;
84
+ ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES;
85
+ ALL_CHAT_PERMISSIONS: typeof ALL_CHAT_PERMISSIONS;
86
+ }
87
+ type ValuesFor<T> = {
88
+ [K in keyof T]: K extends keyof TypeOf ? Readonly<TypeOf[K]> : never;
89
+ };
90
+ /**
91
+ * A container for constants used in the Telegram Bot API. Currently holds all
92
+ * available update types as well as all chat permissions.
93
+ */
94
+ export declare const API_CONSTANTS: ValuesFor<ApiConstants>;
95
+ export {};
@@ -20,41 +20,12 @@ const ALL_CHAT_PERMISSIONS = {
20
20
  can_manage_topics: true,
21
21
  };
22
22
  /**
23
- * Contains lists of constants which are useful when working with the Bot API.
23
+ * A container for constants used in the Telegram Bot API. Currently holds all
24
+ * available update types as well as all chat permissions.
24
25
  */
25
- exports.API_CONSTANTS = Object.freeze({
26
- /**
27
- * List of all available update types. Useful if you want to receive all
28
- * updates from the Bot API, rather than just those that are delivered by
29
- * default.
30
- *
31
- * The main use case for this is when you want to receive `chat_member`
32
- * updates, as they need to be enabled first. Use it like so:
33
- *
34
- * ```ts
35
- * // Built-in polling:
36
- * bot.start({ allowed_updates: ALL_UPDATE_TYPES });
37
- * // grammY runner:
38
- * run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } });
39
- * // Webhooks:
40
- * await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
41
- * ```
42
- */
26
+ exports.API_CONSTANTS = {
27
+ DEFAULT_UPDATE_TYPES: bot_js_1.DEFAULT_UPDATE_TYPES,
43
28
  ALL_UPDATE_TYPES,
44
- /**
45
- * An object containing all available chat permissions. Useful if you want
46
- * to lift restrictions from a user, as this action requires you to pass
47
- * `true` for all permissions. Use it like so:
48
- *
49
- * ```ts
50
- * // On `Bot`:
51
- * await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
52
- * // On `Api`:
53
- * await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
54
- * // On `Context`:
55
- * await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
56
- * await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
57
- * ```
58
- */
59
29
  ALL_CHAT_PERMISSIONS,
60
- });
30
+ };
31
+ Object.freeze(exports.API_CONSTANTS);
@@ -74,7 +74,7 @@ function strictMultiSession(options) {
74
74
  const propSessions = await Promise.all(props.map(async (prop) => {
75
75
  const { initial, storage, getSessionKey, custom } = defaults[prop];
76
76
  const s = new PropertySession(
77
- // @ts-ignore cannot express that the storage works for a concrete prop
77
+ // @ts-expect-error cannot express that the storage works for a concrete prop
78
78
  storage, ctx.session, prop, initial);
79
79
  const key = await getSessionKey(ctx);
80
80
  await s.init(key, { custom, lazy: false });
@@ -125,7 +125,7 @@ function lazySession(options = {}) {
125
125
  const { initial, storage, getSessionKey, custom } = fillDefaults(options);
126
126
  return async (ctx, next) => {
127
127
  const propSession = new PropertySession(
128
- // @ts-ignore suppress promise nature of values
128
+ // @ts-expect-error suppress promise nature of values
129
129
  storage, ctx, "session", initial);
130
130
  const key = await getSessionKey(ctx);
131
131
  await propSession.init(key, { custom, lazy: true });
package/out/filter.d.ts CHANGED
@@ -60,40 +60,28 @@ declare const UPDATE_KEYS: {
60
60
  readonly forum_topic_reopened: {};
61
61
  readonly general_forum_topic_hidden: {};
62
62
  readonly general_forum_topic_unhidden: {};
63
+ readonly forward_date: {};
64
+ readonly is_topic_message: {};
65
+ readonly is_automatic_forward: {};
66
+ readonly text: {};
67
+ readonly animation: {};
68
+ readonly audio: {};
69
+ readonly document: {};
70
+ readonly photo: {};
63
71
  readonly sticker: {
64
72
  readonly is_video: {};
65
73
  readonly is_animated: {};
66
74
  readonly premium_animation: {};
67
75
  };
68
76
  readonly story: {};
77
+ readonly video: {};
69
78
  readonly video_note: {};
70
79
  readonly voice: {};
71
80
  readonly contact: {};
72
81
  readonly dice: {};
82
+ readonly game: {};
73
83
  readonly poll: {};
74
84
  readonly venue: {};
75
- readonly new_chat_title: {};
76
- readonly new_chat_photo: {};
77
- readonly delete_chat_photo: {};
78
- readonly message_auto_delete_timer_changed: {};
79
- readonly pinned_message: {};
80
- readonly invoice: {};
81
- readonly proximity_alert_triggered: {};
82
- readonly video_chat_scheduled: {};
83
- readonly video_chat_started: {};
84
- readonly video_chat_ended: {};
85
- readonly video_chat_participants_invited: {};
86
- readonly web_app_data: {};
87
- readonly forward_date: {};
88
- readonly is_topic_message: {};
89
- readonly is_automatic_forward: {};
90
- readonly text: {};
91
- readonly animation: {};
92
- readonly audio: {};
93
- readonly document: {};
94
- readonly photo: {};
95
- readonly video: {};
96
- readonly game: {};
97
85
  readonly location: {};
98
86
  readonly entities: {
99
87
  readonly mention: {};
@@ -133,8 +121,20 @@ declare const UPDATE_KEYS: {
133
121
  readonly text_mention: {};
134
122
  readonly custom_emoji: {};
135
123
  };
136
- readonly has_media_spoiler: {};
137
124
  readonly caption: {};
125
+ readonly has_media_spoiler: {};
126
+ readonly new_chat_title: {};
127
+ readonly new_chat_photo: {};
128
+ readonly delete_chat_photo: {};
129
+ readonly message_auto_delete_timer_changed: {};
130
+ readonly pinned_message: {};
131
+ readonly invoice: {};
132
+ readonly proximity_alert_triggered: {};
133
+ readonly video_chat_scheduled: {};
134
+ readonly video_chat_started: {};
135
+ readonly video_chat_ended: {};
136
+ readonly video_chat_participants_invited: {};
137
+ readonly web_app_data: {};
138
138
  };
139
139
  readonly edited_message: {
140
140
  readonly new_chat_members: {
@@ -168,40 +168,28 @@ declare const UPDATE_KEYS: {
168
168
  readonly forum_topic_reopened: {};
169
169
  readonly general_forum_topic_hidden: {};
170
170
  readonly general_forum_topic_unhidden: {};
171
+ readonly forward_date: {};
172
+ readonly is_topic_message: {};
173
+ readonly is_automatic_forward: {};
174
+ readonly text: {};
175
+ readonly animation: {};
176
+ readonly audio: {};
177
+ readonly document: {};
178
+ readonly photo: {};
171
179
  readonly sticker: {
172
180
  readonly is_video: {};
173
181
  readonly is_animated: {};
174
182
  readonly premium_animation: {};
175
183
  };
176
184
  readonly story: {};
185
+ readonly video: {};
177
186
  readonly video_note: {};
178
187
  readonly voice: {};
179
188
  readonly contact: {};
180
189
  readonly dice: {};
190
+ readonly game: {};
181
191
  readonly poll: {};
182
192
  readonly venue: {};
183
- readonly new_chat_title: {};
184
- readonly new_chat_photo: {};
185
- readonly delete_chat_photo: {};
186
- readonly message_auto_delete_timer_changed: {};
187
- readonly pinned_message: {};
188
- readonly invoice: {};
189
- readonly proximity_alert_triggered: {};
190
- readonly video_chat_scheduled: {};
191
- readonly video_chat_started: {};
192
- readonly video_chat_ended: {};
193
- readonly video_chat_participants_invited: {};
194
- readonly web_app_data: {};
195
- readonly forward_date: {};
196
- readonly is_topic_message: {};
197
- readonly is_automatic_forward: {};
198
- readonly text: {};
199
- readonly animation: {};
200
- readonly audio: {};
201
- readonly document: {};
202
- readonly photo: {};
203
- readonly video: {};
204
- readonly game: {};
205
193
  readonly location: {};
206
194
  readonly entities: {
207
195
  readonly mention: {};
@@ -241,23 +229,8 @@ declare const UPDATE_KEYS: {
241
229
  readonly text_mention: {};
242
230
  readonly custom_emoji: {};
243
231
  };
244
- readonly has_media_spoiler: {};
245
232
  readonly caption: {};
246
- };
247
- readonly channel_post: {
248
- readonly channel_chat_created: {};
249
- readonly sticker: {
250
- readonly is_video: {};
251
- readonly is_animated: {};
252
- readonly premium_animation: {};
253
- };
254
- readonly story: {};
255
- readonly video_note: {};
256
- readonly voice: {};
257
- readonly contact: {};
258
- readonly dice: {};
259
- readonly poll: {};
260
- readonly venue: {};
233
+ readonly has_media_spoiler: {};
261
234
  readonly new_chat_title: {};
262
235
  readonly new_chat_photo: {};
263
236
  readonly delete_chat_photo: {};
@@ -270,6 +243,9 @@ declare const UPDATE_KEYS: {
270
243
  readonly video_chat_ended: {};
271
244
  readonly video_chat_participants_invited: {};
272
245
  readonly web_app_data: {};
246
+ };
247
+ readonly channel_post: {
248
+ readonly channel_chat_created: {};
273
249
  readonly forward_date: {};
274
250
  readonly is_topic_message: {};
275
251
  readonly is_automatic_forward: {};
@@ -278,8 +254,20 @@ declare const UPDATE_KEYS: {
278
254
  readonly audio: {};
279
255
  readonly document: {};
280
256
  readonly photo: {};
257
+ readonly sticker: {
258
+ readonly is_video: {};
259
+ readonly is_animated: {};
260
+ readonly premium_animation: {};
261
+ };
262
+ readonly story: {};
281
263
  readonly video: {};
264
+ readonly video_note: {};
265
+ readonly voice: {};
266
+ readonly contact: {};
267
+ readonly dice: {};
282
268
  readonly game: {};
269
+ readonly poll: {};
270
+ readonly venue: {};
283
271
  readonly location: {};
284
272
  readonly entities: {
285
273
  readonly mention: {};
@@ -319,23 +307,8 @@ declare const UPDATE_KEYS: {
319
307
  readonly text_mention: {};
320
308
  readonly custom_emoji: {};
321
309
  };
322
- readonly has_media_spoiler: {};
323
310
  readonly caption: {};
324
- };
325
- readonly edited_channel_post: {
326
- readonly channel_chat_created: {};
327
- readonly sticker: {
328
- readonly is_video: {};
329
- readonly is_animated: {};
330
- readonly premium_animation: {};
331
- };
332
- readonly story: {};
333
- readonly video_note: {};
334
- readonly voice: {};
335
- readonly contact: {};
336
- readonly dice: {};
337
- readonly poll: {};
338
- readonly venue: {};
311
+ readonly has_media_spoiler: {};
339
312
  readonly new_chat_title: {};
340
313
  readonly new_chat_photo: {};
341
314
  readonly delete_chat_photo: {};
@@ -348,6 +321,9 @@ declare const UPDATE_KEYS: {
348
321
  readonly video_chat_ended: {};
349
322
  readonly video_chat_participants_invited: {};
350
323
  readonly web_app_data: {};
324
+ };
325
+ readonly edited_channel_post: {
326
+ readonly channel_chat_created: {};
351
327
  readonly forward_date: {};
352
328
  readonly is_topic_message: {};
353
329
  readonly is_automatic_forward: {};
@@ -356,8 +332,20 @@ declare const UPDATE_KEYS: {
356
332
  readonly audio: {};
357
333
  readonly document: {};
358
334
  readonly photo: {};
335
+ readonly sticker: {
336
+ readonly is_video: {};
337
+ readonly is_animated: {};
338
+ readonly premium_animation: {};
339
+ };
340
+ readonly story: {};
359
341
  readonly video: {};
342
+ readonly video_note: {};
343
+ readonly voice: {};
344
+ readonly contact: {};
345
+ readonly dice: {};
360
346
  readonly game: {};
347
+ readonly poll: {};
348
+ readonly venue: {};
361
349
  readonly location: {};
362
350
  readonly entities: {
363
351
  readonly mention: {};
@@ -397,8 +385,20 @@ declare const UPDATE_KEYS: {
397
385
  readonly text_mention: {};
398
386
  readonly custom_emoji: {};
399
387
  };
400
- readonly has_media_spoiler: {};
401
388
  readonly caption: {};
389
+ readonly has_media_spoiler: {};
390
+ readonly new_chat_title: {};
391
+ readonly new_chat_photo: {};
392
+ readonly delete_chat_photo: {};
393
+ readonly message_auto_delete_timer_changed: {};
394
+ readonly pinned_message: {};
395
+ readonly invoice: {};
396
+ readonly proximity_alert_triggered: {};
397
+ readonly video_chat_scheduled: {};
398
+ readonly video_chat_started: {};
399
+ readonly video_chat_ended: {};
400
+ readonly video_chat_participants_invited: {};
401
+ readonly web_app_data: {};
402
402
  };
403
403
  readonly inline_query: {};
404
404
  readonly chosen_inline_result: {};
package/out/filter.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.preprocess = exports.parse = exports.matchFilter = void 0;
4
+ const filterQueryCache = new Map();
4
5
  // === Obtain O(1) filter function from query
5
6
  /**
6
7
  * > This is an advanced function of grammY.
@@ -26,8 +27,15 @@ exports.preprocess = exports.parse = exports.matchFilter = void 0;
26
27
  * @param filter A filter query or an array of filter queries
27
28
  */
28
29
  function matchFilter(filter) {
29
- const parsed = parse(filter);
30
- const predicate = compile(parsed);
30
+ var _a;
31
+ const queries = Array.isArray(filter) ? filter : [filter];
32
+ const key = queries.join(",");
33
+ const predicate = (_a = filterQueryCache.get(key)) !== null && _a !== void 0 ? _a : (() => {
34
+ const parsed = parse(queries);
35
+ const pred = compile(parsed);
36
+ filterQueryCache.set(key, pred);
37
+ return pred;
38
+ })();
31
39
  return (ctx) => predicate(ctx);
32
40
  }
33
41
  exports.matchFilter = matchFilter;
@@ -224,30 +232,30 @@ const STICKER_KEYS = {
224
232
  premium_animation: {},
225
233
  };
226
234
  // L2
227
- const EDITABLE_MESSAGE_KEYS = {
235
+ const COMMON_MESSAGE_KEYS = {
236
+ forward_date: {},
237
+ is_topic_message: {},
238
+ is_automatic_forward: {},
228
239
  text: {},
229
240
  animation: {},
230
241
  audio: {},
231
242
  document: {},
232
243
  photo: {},
233
- video: {},
234
- game: {},
235
- location: {},
236
- entities: ENTITY_KEYS,
237
- caption_entities: ENTITY_KEYS,
238
- has_media_spoiler: {},
239
- caption: {},
240
- };
241
- const COMMON_MESSAGE_KEYS = {
242
- ...EDITABLE_MESSAGE_KEYS,
243
244
  sticker: STICKER_KEYS,
244
245
  story: {},
246
+ video: {},
245
247
  video_note: {},
246
248
  voice: {},
247
249
  contact: {},
248
250
  dice: {},
251
+ game: {},
249
252
  poll: {},
250
253
  venue: {},
254
+ location: {},
255
+ entities: ENTITY_KEYS,
256
+ caption_entities: ENTITY_KEYS,
257
+ caption: {},
258
+ has_media_spoiler: {},
251
259
  new_chat_title: {},
252
260
  new_chat_photo: {},
253
261
  delete_chat_photo: {},
@@ -260,9 +268,6 @@ const COMMON_MESSAGE_KEYS = {
260
268
  video_chat_ended: {},
261
269
  video_chat_participants_invited: {},
262
270
  web_app_data: {},
263
- forward_date: {},
264
- is_topic_message: {},
265
- is_automatic_forward: {},
266
271
  };
267
272
  const MESSAGE_KEYS = {
268
273
  ...COMMON_MESSAGE_KEYS,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grammy",
3
3
  "description": "The Telegram Bot Framework.",
4
- "version": "1.18.0",
4
+ "version": "1.18.2",
5
5
  "author": "KnorpelSenf",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -14,21 +14,19 @@
14
14
  },
15
15
  "scripts": {
16
16
  "prepare": "npm run backport",
17
- "backport": "deno2node tsconfig.json",
18
- "contribs": "all-contributors"
17
+ "backport": "deno2node tsconfig.json"
19
18
  },
20
19
  "dependencies": {
21
- "@grammyjs/types": "3.2.0",
20
+ "@grammyjs/types": "3.2.2",
22
21
  "abort-controller": "^3.0.0",
23
22
  "debug": "^4.3.4",
24
- "node-fetch": "^2.6.11"
23
+ "node-fetch": "^2.7.0"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@types/debug": "^4.1.8",
28
27
  "@types/node": "^12.20.55",
29
28
  "@types/node-fetch": "2.6.2",
30
- "all-contributors-cli": "6.24.0",
31
- "deno2node": "^1.8.1"
29
+ "deno2node": "^1.9.0"
32
30
  },
33
31
  "files": [
34
32
  "out/"
package/out/web.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./mod";