grammy 1.27.0 → 1.29.0

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
@@ -10,14 +10,14 @@
10
10
 
11
11
  <!-- deno-fmt-ignore-start -->
12
12
 
13
- [![Bot API](https://img.shields.io/badge/Bot%20API-7.7-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
13
+ [![Bot API](https://img.shields.io/badge/Bot%20API-7.9-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
14
14
  [![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy)
15
15
  [![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy)
16
16
  [![All Contributors](https://img.shields.io/github/all-contributors/grammyjs/grammy?style=flat&labelColor=000&color=3b82f6)](#contributors-)
17
17
 
18
18
  <!-- deno-fmt-ignore-end -->
19
19
 
20
- ## _[docs.](https://grammy.dev) [reference.](https://deno.land/x/grammy/mod.ts) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_news)_
20
+ ## _[docs.](https://grammy.dev) [reference.](https://grammy.dev/ref) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_news)_
21
21
 
22
22
  </div>
23
23
 
@@ -68,7 +68,7 @@ Congrats! You just wrote a Telegram bot :)
68
68
 
69
69
  ## Going Further
70
70
 
71
- grammY has an excellent [documentation](https://grammy.dev), and an [API Reference](https://doc.deno.land/https://deno.land/x/grammy/mod.ts). It even integrates with your code editor, e.g. [VS Code](https://code.visualstudio.com/). You can hover over any element of grammY to get a detailed description of what that thing does or means.
71
+ grammY has an excellent [documentation](https://grammy.dev), and an [API Reference](https://grammy.dev/ref). It even integrates with your code editor, e.g. [VS Code](https://code.visualstudio.com/). You can hover over any element of grammY to get a detailed description of what that thing does or means.
72
72
 
73
73
  If you are still stuck, just join the [Telegram chat](https://t.me/grammyjs) and ask for help. People are nice there and we appreciate your question, no matter what it is :)
74
74
 
@@ -81,7 +81,7 @@ Here are some more resources to support you:
81
81
  —main project website and documentation.
82
82
  Gets you started and explains all concepts.
83
83
 
84
- ### [grammY API reference](https://doc.deno.land/https://deno.land/x/grammy/mod.ts)
84
+ ### [grammY API reference](https://grammy.dev/ref)
85
85
 
86
86
  —reference of everything that grammY exports.
87
87
  Useful to look up descriptions about any element of grammY.
@@ -302,6 +302,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
302
302
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/SunsetTechuila"><img src="https://avatars.githubusercontent.com/u/115353812?v=4?s=100" width="100px;" alt="Grigory"/><br /><sub><b>Grigory</b></sub></a><br /><a href="#ideas-SunsetTechuila" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=SunsetTechuila" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=SunsetTechuila" title="Documentation">📖</a></td>
303
303
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/aleveha"><img src="https://avatars.githubusercontent.com/u/63300936?v=4?s=100" width="100px;" alt="aleveha"/><br /><sub><b>aleveha</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=aleveha" title="Code">💻</a></td>
304
304
  <td align="center" valign="top" width="11.11%"><a href="https://github.com/barinbritva"><img src="https://avatars.githubusercontent.com/u/4758362?v=4?s=100" width="100px;" alt="barinbritva"/><br /><sub><b>barinbritva</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Abarinbritva" title="Reviewed Pull Requests">👀</a></td>
305
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/flmel"><img src="https://avatars.githubusercontent.com/u/55487633?v=4?s=100" width="100px;" alt="Lyudmil Ivanov"/><br /><sub><b>Lyudmil Ivanov</b></sub></a><br /><a href="#example-flmel" title="Examples">💡</a></td>
306
+ <td align="center" valign="top" width="11.11%"><a href="https://consortiumkey.com/"><img src="https://avatars.githubusercontent.com/u/95214604?v=4?s=100" width="100px;" alt="lexomis"/><br /><sub><b>lexomis</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Alexomis" title="Reviewed Pull Requests">👀</a></td>
307
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/asologor"><img src="https://avatars.githubusercontent.com/u/97506048?v=4?s=100" width="100px;" alt="Andrew Sologor"/><br /><sub><b>Andrew Sologor</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aandrew-sol" title="Reviewed Pull Requests">👀</a></td>
308
+ </tr>
309
+ <tr>
310
+ <td align="center" valign="top" width="11.11%"><a href="https://github.com/rayz1065"><img src="https://avatars.githubusercontent.com/u/37779815?v=4?s=100" width="100px;" alt="rayz"/><br /><sub><b>rayz</b></sub></a><br /><a href="#question-rayz1065" title="Answering Questions">💬</a></td>
305
311
  </tr>
306
312
  </tbody>
307
313
  </table>
package/out/bot.d.ts CHANGED
@@ -199,7 +199,7 @@ export declare class Bot<C extends Context = Context, A extends Api = Api> exten
199
199
  * your bot will handle.
200
200
  *
201
201
  * If you're writing a library on top of grammY, check out the
202
- * [documentation](https://grammy.dev/plugins/runner.html) of the runner
202
+ * [documentation](https://grammy.dev/plugins/runner) of the runner
203
203
  * plugin for an example that uses this method.
204
204
  *
205
205
  * @param update An update from the Telegram Bot API
@@ -235,7 +235,7 @@ export declare class Bot<C extends Context = Context, A extends Api = Api> exten
235
235
  * will impact the responsiveness negatively, so it makes sense to use the
236
236
  * `@grammyjs/runner` package even if you receive much fewer messages. If
237
237
  * you worry about how much load your bot can handle, check out the grammY
238
- * [documentation](https://grammy.dev/advanced/scaling.html) about scaling
238
+ * [documentation](https://grammy.dev/advanced/scaling) about scaling
239
239
  * up.
240
240
  *
241
241
  * @param options Options to use for simple long polling
package/out/bot.js CHANGED
@@ -208,7 +208,7 @@ class Bot extends composer_js_1.Composer {
208
208
  * your bot will handle.
209
209
  *
210
210
  * If you're writing a library on top of grammY, check out the
211
- * [documentation](https://grammy.dev/plugins/runner.html) of the runner
211
+ * [documentation](https://grammy.dev/plugins/runner) of the runner
212
212
  * plugin for an example that uses this method.
213
213
  *
214
214
  * @param update An update from the Telegram Bot API
@@ -267,7 +267,7 @@ a known bot info object.");
267
267
  * will impact the responsiveness negatively, so it makes sense to use the
268
268
  * `@grammyjs/runner` package even if you receive much fewer messages. If
269
269
  * you worry about how much load your bot can handle, check out the grammY
270
- * [documentation](https://grammy.dev/advanced/scaling.html) about scaling
270
+ * [documentation](https://grammy.dev/advanced/scaling) about scaling
271
271
  * up.
272
272
  *
273
273
  * @param options Options to use for simple long polling
package/out/composer.d.ts CHANGED
@@ -65,7 +65,7 @@ export interface MiddlewareObj<C extends Context = Context> {
65
65
  * Middleware is an extremely powerful concept and this short explanation only
66
66
  * scratched the surface of what is possible with grammY. If you want to know
67
67
  * more advanced things about middleware, check out the
68
- * [documentation](https://grammy.dev/guide/middleware.html) on the website.
68
+ * [documentation](https://grammy.dev/guide/middleware) on the website.
69
69
  */
70
70
  export type Middleware<C extends Context = Context> = MiddlewareFn<C> | MiddlewareObj<C>;
71
71
  /**
@@ -96,7 +96,7 @@ export declare function run<C extends Context>(middleware: MiddlewareFn<C>, ctx:
96
96
  *
97
97
  * On the other hand, if you want to dig deeper into how grammY implements
98
98
  * middleware, check out the
99
- * [documentation](https://grammy.dev/advanced/middleware.html) on the website.
99
+ * [documentation](https://grammy.dev/advanced/middleware) on the website.
100
100
  */
101
101
  export declare class Composer<C extends Context> implements MiddlewareObj<C> {
102
102
  private handler;
@@ -121,7 +121,7 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
121
121
  *
122
122
  * This method returns a new instance of composer. The returned instance can
123
123
  * be further extended, and all changes will be regarded here. Confer the
124
- * [documentation](https://grammy.dev/advanced/middleware.html) on the
124
+ * [documentation](https://grammy.dev/advanced/middleware) on the
125
125
  * website if you want to know more about how the middleware system in
126
126
  * grammY works, especially when it comes to chaining the method calls
127
127
  * (`use( ... ).use( ... ).use( ... )`).
@@ -157,7 +157,7 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
157
157
  *
158
158
  * You can use autocomplete in VS Code to see all available filter queries.
159
159
  * Check out the
160
- * [documentation](https://grammy.dev/guide/filter-queries.html) on the
160
+ * [documentation](https://grammy.dev/guide/filter-queries) on the
161
161
  * website to learn more about filter queries in grammY.
162
162
  *
163
163
  * It is possible to pass multiple filter queries in an array, i.e.
@@ -320,7 +320,7 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
320
320
  * // Groups and supergroups only
321
321
  * bot.chatType(["group", "supergroup"], ctx => { ... });
322
322
  * ```
323
- * [Remember](https://grammy.dev/guide/context.html#shortcuts) also that you
323
+ * [Remember](https://grammy.dev/guide/context#shortcuts) also that you
324
324
  * can access the chat type via `ctx.chat.type`.
325
325
  *
326
326
  * @param chatType The chat type
@@ -663,7 +663,7 @@ export declare class Composer<C extends Context> implements MiddlewareObj<C> {
663
663
  * ```
664
664
  *
665
665
  * Check out the
666
- * [documentation](https://grammy.dev/guide/errors.html#error-boundaries) on
666
+ * [documentation](https://grammy.dev/guide/errors#error-boundaries) on
667
667
  * the website to learn more about error boundaries.
668
668
  *
669
669
  * @param errorHandler The error handler to use
package/out/composer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Composer = exports.run = exports.BotError = void 0;
3
+ exports.Composer = exports.BotError = void 0;
4
+ exports.run = run;
4
5
  const context_js_1 = require("./context.js");
5
6
  // === Middleware errors
6
7
  /**
@@ -75,7 +76,6 @@ const leaf = () => Promise.resolve();
75
76
  async function run(middleware, ctx) {
76
77
  await middleware(ctx, leaf);
77
78
  }
78
- exports.run = run;
79
79
  // === Composer
80
80
  /**
81
81
  * The composer is the heart of the middleware system in grammY. It is also the
@@ -88,7 +88,7 @@ exports.run = run;
88
88
  *
89
89
  * On the other hand, if you want to dig deeper into how grammY implements
90
90
  * middleware, check out the
91
- * [documentation](https://grammy.dev/advanced/middleware.html) on the website.
91
+ * [documentation](https://grammy.dev/advanced/middleware) on the website.
92
92
  */
93
93
  class Composer {
94
94
  /**
@@ -118,7 +118,7 @@ class Composer {
118
118
  *
119
119
  * This method returns a new instance of composer. The returned instance can
120
120
  * be further extended, and all changes will be regarded here. Confer the
121
- * [documentation](https://grammy.dev/advanced/middleware.html) on the
121
+ * [documentation](https://grammy.dev/advanced/middleware) on the
122
122
  * website if you want to know more about how the middleware system in
123
123
  * grammY works, especially when it comes to chaining the method calls
124
124
  * (`use( ... ).use( ... ).use( ... )`).
@@ -158,7 +158,7 @@ class Composer {
158
158
  *
159
159
  * You can use autocomplete in VS Code to see all available filter queries.
160
160
  * Check out the
161
- * [documentation](https://grammy.dev/guide/filter-queries.html) on the
161
+ * [documentation](https://grammy.dev/guide/filter-queries) on the
162
162
  * website to learn more about filter queries in grammY.
163
163
  *
164
164
  * It is possible to pass multiple filter queries in an array, i.e.
@@ -329,7 +329,7 @@ class Composer {
329
329
  * // Groups and supergroups only
330
330
  * bot.chatType(["group", "supergroup"], ctx => { ... });
331
331
  * ```
332
- * [Remember](https://grammy.dev/guide/context.html#shortcuts) also that you
332
+ * [Remember](https://grammy.dev/guide/context#shortcuts) also that you
333
333
  * can access the chat type via `ctx.chat.type`.
334
334
  *
335
335
  * @param chatType The chat type
@@ -676,7 +676,7 @@ class Composer {
676
676
  * ```
677
677
  *
678
678
  * Check out the
679
- * [documentation](https://grammy.dev/guide/errors.html#error-boundaries) on
679
+ * [documentation](https://grammy.dev/guide/errors#error-boundaries) on
680
680
  * the website to learn more about error boundaries.
681
681
  *
682
682
  * @param errorHandler The error handler to use
package/out/context.d.ts CHANGED
@@ -4,7 +4,7 @@ import { type Filter, type FilterCore, type FilterQuery } from "./filter.js";
4
4
  import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputPaidMedia, type InputPollOption, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type ReactionType, type ReactionTypeEmoji, type Update, type User, type UserFromGetMe } from "./types.js";
5
5
  export type MaybeArray<T> = T | T[];
6
6
  /** permits `string` but gives hints */
7
- export type StringWithCommandSuggestions = (string & Record<never, never>) | "start" | "help" | "settings" | "privacy";
7
+ export type StringWithCommandSuggestions = (string & Record<never, never>) | "start" | "help" | "settings" | "privacy" | "developer_info";
8
8
  type Other<M extends Methods<RawApi>, X extends string = never> = OtherApi<RawApi, M, X>;
9
9
  type SnakeToCamelCase<S extends string> = S extends `${infer L}_${infer R}` ? `${L}${Capitalize<SnakeToCamelCase<R>>}` : S;
10
10
  type AliasProps<U> = {
@@ -135,7 +135,7 @@ interface StaticHas {
135
135
  * methods to keep information about how a regular expression was matched.
136
136
  *
137
137
  * Read up about middleware on the
138
- * [website](https://grammy.dev/guide/context.html) if you want to know more
138
+ * [website](https://grammy.dev/guide/context) if you want to know more
139
139
  * about the powerful opportunities that lie in context objects, and about how
140
140
  * grammY implements them.
141
141
  */
@@ -308,15 +308,18 @@ export declare class Context implements RenamedUpdate {
308
308
  * customEmojiAdded: [],
309
309
  * customEmojiKept: [],
310
310
  * customEmojiRemoved: ['id0123'],
311
+ * paid: true,
312
+ * paidAdded: false,
313
+ * paidRemoved: false,
311
314
  * }
312
315
  * ```
313
316
  * In the above example, a tada reaction was added by the user, and a custom
314
317
  * emoji reaction with the custom emoji 'id0123' was removed in the same
315
- * update. The user had already reacted with a thumbs up reaction, which
316
- * they left unchanged. As a result, the current reaction by the user is
317
- * thumbs up and tada. Note that the current reaction (both emoji and custom
318
- * emoji in one list) can also be obtained from
319
- * `ctx.messageReaction.new_reaction`.
318
+ * update. The user had already reacted with a thumbs up reaction and a paid
319
+ * star reaction, which they left both unchanged. As a result, the current
320
+ * reaction by the user is thumbs up, tada, and a paid reaction. Note that
321
+ * the current reaction (all emoji reactions regardless of type in one list)
322
+ * can also be obtained from `ctx.messageReaction.new_reaction`.
320
323
  *
321
324
  * Remember that reaction updates only include information about the
322
325
  * reaction of a specific user. The respective message may have many more
@@ -341,6 +344,16 @@ export declare class Context implements RenamedUpdate {
341
344
  customEmojiKept: string[];
342
345
  /** Custom emoji removed from this user's reaction */
343
346
  customEmojiRemoved: string[];
347
+ /**
348
+ * `true` if a paid reaction is currently present in this user's
349
+ * reaction, and `false` otherwise
350
+ */
351
+ paid: boolean;
352
+ /**
353
+ * `true` if a paid reaction was newly added to this user's reaction,
354
+ * and `false` otherwise
355
+ */
356
+ paidAdded: boolean;
344
357
  };
345
358
  /**
346
359
  * `Context.has` is an object that contains a number of useful functions for
@@ -617,7 +630,7 @@ export declare class Context implements RenamedUpdate {
617
630
  location: import("@grammyjs/types/message.js").Location;
618
631
  })>;
619
632
  /**
620
- * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media to channel chats. On success, the sent Message is returned.
633
+ * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned.
621
634
  *
622
635
  * @param star_count The number of Telegram Stars that must be paid to buy access to the media
623
636
  * @param media An array describing the media to be sent; up to 10 items
@@ -687,9 +700,9 @@ export declare class Context implements RenamedUpdate {
687
700
  */
688
701
  replyWithChatAction(action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", other?: Other<"sendChatAction", "chat_id" | "action">, signal?: AbortSignal): Promise<true>;
689
702
  /**
690
- * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. In albums, bots must react to the first message. Returns True on success.
703
+ * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
691
704
  *
692
- * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
705
+ * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
693
706
  * @param other Optional remaining parameters, confer the official reference below
694
707
  * @param signal Optional `AbortSignal` to cancel the request
695
708
  *
@@ -716,7 +729,7 @@ export declare class Context implements RenamedUpdate {
716
729
  */
717
730
  getUserChatBoosts(chat_id: number | string, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").UserChatBoosts>;
718
731
  /**
719
- * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
732
+ * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
720
733
  * @param signal Optional `AbortSignal` to cancel the request
721
734
  *
722
735
  * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection
@@ -872,7 +885,7 @@ export declare class Context implements RenamedUpdate {
872
885
  */
873
886
  createChatInviteLink(other?: Other<"createChatInviteLink", "chat_id">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
874
887
  /**
875
- * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
888
+ * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
876
889
  *
877
890
  * @param invite_link The invite link to edit
878
891
  * @param other Optional remaining parameters, confer the official reference below
@@ -882,7 +895,28 @@ export declare class Context implements RenamedUpdate {
882
895
  */
883
896
  editChatInviteLink(invite_link: string, other?: Other<"editChatInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
884
897
  /**
885
- * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
898
+ * Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
899
+ *
900
+ * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
901
+ * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
902
+ * @param other Optional remaining parameters, confer the official reference below
903
+ * @param signal Optional `AbortSignal` to cancel the request
904
+ *
905
+ * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
906
+ */
907
+ createChatSubscriptionInviteLink(subscription_period: number, subscription_price: number, other?: Other<"createChatSubscriptionInviteLink", "chat_id" | "subscription_period" | "subscription_price">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
908
+ /**
909
+ * Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
910
+ *
911
+ * @param invite_link The invite link to edit
912
+ * @param other Optional remaining parameters, confer the official reference below
913
+ * @param signal Optional `AbortSignal` to cancel the request
914
+ *
915
+ * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
916
+ */
917
+ editChatSubscriptionInviteLink(invite_link: string, other?: Other<"editChatSubscriptionInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
918
+ /**
919
+ * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
886
920
  *
887
921
  * @param invite_link The invite link to revoke
888
922
  * @param signal Optional `AbortSignal` to cancel the request
@@ -1049,7 +1083,7 @@ export declare class Context implements RenamedUpdate {
1049
1083
  */
1050
1084
  createForumTopic(name: string, other?: Other<"createForumTopic", "chat_id" | "name">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ForumTopic>;
1051
1085
  /**
1052
- * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1086
+ * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1053
1087
  *
1054
1088
  * @param other Optional remaining parameters, confer the official reference below
1055
1089
  * @param signal Optional `AbortSignal` to cancel the request
@@ -1090,7 +1124,7 @@ export declare class Context implements RenamedUpdate {
1090
1124
  */
1091
1125
  unpinAllForumTopicMessages(signal?: AbortSignal): Promise<true>;
1092
1126
  /**
1093
- * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
1127
+ * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1094
1128
  *
1095
1129
  * @param name New topic name, 1-128 characters
1096
1130
  * @param signal Optional `AbortSignal` to cancel the request
package/out/context.js CHANGED
@@ -67,11 +67,18 @@ const checker = {
67
67
  const normalized = typeof reaction === "string"
68
68
  ? [{ type: "emoji", emoji: reaction }]
69
69
  : (Array.isArray(reaction) ? reaction : [reaction]).map((emoji) => typeof emoji === "string" ? { type: "emoji", emoji } : emoji);
70
+ const emoji = new Set(normalized.filter((r) => r.type === "emoji")
71
+ .map((r) => r.emoji));
72
+ const customEmoji = new Set(normalized.filter((r) => r.type === "custom_emoji")
73
+ .map((r) => r.custom_emoji_id));
74
+ const paid = normalized.some((r) => r.type === "paid");
70
75
  return (ctx) => {
71
76
  if (!hasMessageReaction(ctx))
72
77
  return false;
73
78
  const { old_reaction, new_reaction } = ctx.messageReaction;
79
+ // try to find a wanted reaction that is new and not old
74
80
  for (const reaction of new_reaction) {
81
+ // first check if the reaction existed previously
75
82
  let isOld = false;
76
83
  if (reaction.type === "emoji") {
77
84
  for (const old of old_reaction) {
@@ -93,34 +100,38 @@ const checker = {
93
100
  }
94
101
  }
95
102
  }
103
+ else if (reaction.type === "paid") {
104
+ for (const old of old_reaction) {
105
+ if (old.type !== "paid")
106
+ continue;
107
+ isOld = true;
108
+ break;
109
+ }
110
+ }
96
111
  else {
97
112
  // always regard unsupported emoji types as new
98
113
  }
99
- if (!isOld) {
100
- if (reaction.type === "emoji") {
101
- for (const wanted of normalized) {
102
- if (wanted.type !== "emoji")
103
- continue;
104
- if (wanted.emoji === reaction.emoji) {
105
- return true;
106
- }
107
- }
108
- }
109
- else if (reaction.type === "custom_emoji") {
110
- for (const wanted of normalized) {
111
- if (wanted.type !== "custom_emoji")
112
- continue;
113
- if (wanted.custom_emoji_id ===
114
- reaction.custom_emoji_id) {
115
- return true;
116
- }
117
- }
118
- }
119
- else {
120
- // always regard unsupported emoji types as new
114
+ // disregard reaction if it is not new
115
+ if (isOld)
116
+ continue;
117
+ // check if the new reaction is wanted and short-circuit
118
+ if (reaction.type === "emoji") {
119
+ if (emoji.has(reaction.emoji))
121
120
  return true;
122
- }
123
121
  }
122
+ else if (reaction.type === "custom_emoji") {
123
+ if (customEmoji.has(reaction.custom_emoji_id))
124
+ return true;
125
+ }
126
+ else if (reaction.type === "paid") {
127
+ if (paid)
128
+ return true;
129
+ }
130
+ else {
131
+ // always regard unsupported emoji types as new
132
+ return true;
133
+ }
134
+ // new reaction not wanted, check next one
124
135
  }
125
136
  return false;
126
137
  };
@@ -198,7 +209,7 @@ const checker = {
198
209
  * methods to keep information about how a regular expression was matched.
199
210
  *
200
211
  * Read up about middleware on the
201
- * [website](https://grammy.dev/guide/context.html) if you want to know more
212
+ * [website](https://grammy.dev/guide/context) if you want to know more
202
213
  * about the powerful opportunities that lie in context objects, and about how
203
214
  * grammY implements them.
204
215
  */
@@ -427,15 +438,18 @@ class Context {
427
438
  * customEmojiAdded: [],
428
439
  * customEmojiKept: [],
429
440
  * customEmojiRemoved: ['id0123'],
441
+ * paid: true,
442
+ * paidAdded: false,
443
+ * paidRemoved: false,
430
444
  * }
431
445
  * ```
432
446
  * In the above example, a tada reaction was added by the user, and a custom
433
447
  * emoji reaction with the custom emoji 'id0123' was removed in the same
434
- * update. The user had already reacted with a thumbs up reaction, which
435
- * they left unchanged. As a result, the current reaction by the user is
436
- * thumbs up and tada. Note that the current reaction (both emoji and custom
437
- * emoji in one list) can also be obtained from
438
- * `ctx.messageReaction.new_reaction`.
448
+ * update. The user had already reacted with a thumbs up reaction and a paid
449
+ * star reaction, which they left both unchanged. As a result, the current
450
+ * reaction by the user is thumbs up, tada, and a paid reaction. Note that
451
+ * the current reaction (all emoji reactions regardless of type in one list)
452
+ * can also be obtained from `ctx.messageReaction.new_reaction`.
439
453
  *
440
454
  * Remember that reaction updates only include information about the
441
455
  * reaction of a specific user. The respective message may have many more
@@ -452,6 +466,8 @@ class Context {
452
466
  const customEmojiAdded = [];
453
467
  const customEmojiKept = [];
454
468
  const customEmojiRemoved = [];
469
+ let paid = false;
470
+ let paidAdded = false;
455
471
  const r = this.messageReaction;
456
472
  if (r !== undefined) {
457
473
  const { old_reaction, new_reaction } = r;
@@ -463,6 +479,9 @@ class Context {
463
479
  else if (reaction.type === "custom_emoji") {
464
480
  customEmoji.push(reaction.custom_emoji_id);
465
481
  }
482
+ else if (reaction.type === "paid") {
483
+ paid = paidAdded = true;
484
+ }
466
485
  }
467
486
  // temporarily move all old emoji to the *Removed arrays
468
487
  for (const reaction of old_reaction) {
@@ -472,6 +491,9 @@ class Context {
472
491
  else if (reaction.type === "custom_emoji") {
473
492
  customEmojiRemoved.push(reaction.custom_emoji_id);
474
493
  }
494
+ else if (reaction.type === "paid") {
495
+ paidAdded = false;
496
+ }
475
497
  }
476
498
  // temporarily move all new emoji to the *Added arrays
477
499
  emojiAdded.push(...emoji);
@@ -518,6 +540,8 @@ class Context {
518
540
  customEmojiAdded,
519
541
  customEmojiKept,
520
542
  customEmojiRemoved,
543
+ paid,
544
+ paidAdded,
521
545
  };
522
546
  }
523
547
  /**
@@ -831,7 +855,7 @@ class Context {
831
855
  : this.api.stopMessageLiveLocation(orThrow(this.chatId, "stopMessageLiveLocation"), orThrow(this.msgId, "stopMessageLiveLocation"), other, signal);
832
856
  }
833
857
  /**
834
- * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media to channel chats. On success, the sent Message is returned.
858
+ * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned.
835
859
  *
836
860
  * @param star_count The number of Telegram Stars that must be paid to buy access to the media
837
861
  * @param media An array describing the media to be sent; up to 10 items
@@ -913,9 +937,9 @@ class Context {
913
937
  return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { business_connection_id: this.businessConnectionId, ...other }, signal);
914
938
  }
915
939
  /**
916
- * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. In albums, bots must react to the first message. Returns True on success.
940
+ * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
917
941
  *
918
- * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
942
+ * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
919
943
  * @param other Optional remaining parameters, confer the official reference below
920
944
  * @param signal Optional `AbortSignal` to cancel the request
921
945
  *
@@ -953,7 +977,7 @@ class Context {
953
977
  return this.api.getUserChatBoosts(chat_id, orThrow(this.from, "getUserChatBoosts").id, signal);
954
978
  }
955
979
  /**
956
- * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
980
+ * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
957
981
  * @param signal Optional `AbortSignal` to cancel the request
958
982
  *
959
983
  * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection
@@ -1150,7 +1174,7 @@ class Context {
1150
1174
  return this.api.createChatInviteLink(orThrow(this.chatId, "createChatInviteLink"), other, signal);
1151
1175
  }
1152
1176
  /**
1153
- * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
1177
+ * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
1154
1178
  *
1155
1179
  * @param invite_link The invite link to edit
1156
1180
  * @param other Optional remaining parameters, confer the official reference below
@@ -1162,7 +1186,32 @@ class Context {
1162
1186
  return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal);
1163
1187
  }
1164
1188
  /**
1165
- * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
1189
+ * Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
1190
+ *
1191
+ * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
1192
+ * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
1193
+ * @param other Optional remaining parameters, confer the official reference below
1194
+ * @param signal Optional `AbortSignal` to cancel the request
1195
+ *
1196
+ * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
1197
+ */
1198
+ createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) {
1199
+ return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal);
1200
+ }
1201
+ /**
1202
+ * Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
1203
+ *
1204
+ * @param invite_link The invite link to edit
1205
+ * @param other Optional remaining parameters, confer the official reference below
1206
+ * @param signal Optional `AbortSignal` to cancel the request
1207
+ *
1208
+ * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
1209
+ */
1210
+ editChatSubscriptionInviteLink(invite_link, other, signal) {
1211
+ return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal);
1212
+ }
1213
+ /**
1214
+ * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
1166
1215
  *
1167
1216
  * @param invite_link The invite link to revoke
1168
1217
  * @param signal Optional `AbortSignal` to cancel the request
@@ -1369,7 +1418,7 @@ class Context {
1369
1418
  return this.api.createForumTopic(orThrow(this.chatId, "createForumTopic"), name, other, signal);
1370
1419
  }
1371
1420
  /**
1372
- * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1421
+ * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
1373
1422
  *
1374
1423
  * @param other Optional remaining parameters, confer the official reference below
1375
1424
  * @param signal Optional `AbortSignal` to cancel the request
@@ -1430,7 +1479,7 @@ class Context {
1430
1479
  return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal);
1431
1480
  }
1432
1481
  /**
1433
- * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
1482
+ * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
1434
1483
  *
1435
1484
  * @param name New topic name, 1-128 characters
1436
1485
  * @param signal Optional `AbortSignal` to cancel the request
@@ -163,7 +163,7 @@ export declare const InlineQueryResultBuilder: {
163
163
  * @param options Remaining options
164
164
  */
165
165
  game(id: string, game_short_name: string, options?: InlineQueryResultOptions<InlineQueryResultGame, "game_short_name">): {
166
- reply_markup?: import("@grammyjs/types/markup.js").InlineKeyboardMarkup | undefined;
166
+ reply_markup?: import("@grammyjs/types/markup.js").InlineKeyboardMarkup;
167
167
  type: string;
168
168
  id: string;
169
169
  game_short_name: string;