@grammyjs/types 3.0.3 → 3.1.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
@@ -90,6 +90,7 @@ The actual type definitions themselves are never different.
90
90
  4. No `More info on Sending Files »`.
91
91
  File handling is abstracted away by the underlying library.
92
92
  Also, without the links, it's useless anyway.
93
+ The same is true for the links to more info about requesting chats and users.
93
94
  5. No images.
94
95
  Documentation strings containing an image are adjusted to make sense without the images, too.
95
96
 
package/inline.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Chat, User } from "./manage.js";
2
- import type { InlineKeyboardMarkup } from "./markup.js";
2
+ import type { InlineKeyboardMarkup, WebAppInfo } from "./markup.js";
3
3
  import type { Location, MessageEntity, ParseMode } from "./message.js";
4
4
  import type { LabeledPrice } from "./payment.js";
5
5
  /** This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. */
@@ -668,3 +668,14 @@ export interface ChosenInlineResult {
668
668
  /** The query that was used to obtain the result */
669
669
  query: string;
670
670
  }
671
+ /** This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.
672
+
673
+ Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. */
674
+ export interface InlineQueryResultsButton {
675
+ /** Label text on the button */
676
+ text: string;
677
+ /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. */
678
+ web_app?: WebAppInfo;
679
+ /** Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed. */
680
+ start_parameter?: string;
681
+ }
package/manage.d.ts CHANGED
@@ -360,6 +360,8 @@ export interface ChatMemberUpdated {
360
360
  new_chat_member: ChatMember;
361
361
  /** Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */
362
362
  invite_link?: ChatInviteLink;
363
+ /** True, if the user joined the chat via a chat folder invite link */
364
+ via_chat_folder_invite_link?: boolean;
363
365
  }
364
366
  /** Represents a join request sent to a chat. */
365
367
  export interface ChatJoinRequest {
package/markup.d.ts CHANGED
@@ -38,6 +38,10 @@ export declare namespace InlineKeyboardButton {
38
38
  This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options. */
39
39
  switch_inline_query_current_chat: string;
40
40
  }
41
+ export interface SwitchInlineChosenChatButton extends AbstractInlineKeyboardButton {
42
+ /** If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field */
43
+ switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat;
44
+ }
41
45
  export interface GameButton extends AbstractInlineKeyboardButton {
42
46
  /** Description of the game that will be launched when the user presses the button.
43
47
 
@@ -53,7 +57,7 @@ export declare namespace InlineKeyboardButton {
53
57
  export {};
54
58
  }
55
59
  /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields. */
56
- export type InlineKeyboardButton = InlineKeyboardButton.CallbackButton | InlineKeyboardButton.GameButton | InlineKeyboardButton.LoginButton | InlineKeyboardButton.PayButton | InlineKeyboardButton.SwitchInlineButton | InlineKeyboardButton.SwitchInlineCurrentChatButton | InlineKeyboardButton.UrlButton | InlineKeyboardButton.WebAppButton;
60
+ export type InlineKeyboardButton = InlineKeyboardButton.CallbackButton | InlineKeyboardButton.GameButton | InlineKeyboardButton.LoginButton | InlineKeyboardButton.PayButton | InlineKeyboardButton.SwitchInlineButton | InlineKeyboardButton.SwitchInlineCurrentChatButton | InlineKeyboardButton.SwitchInlineChosenChatButton | InlineKeyboardButton.UrlButton | InlineKeyboardButton.WebAppButton;
57
61
  /** This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in.
58
62
  Telegram apps support these buttons as of version 5.7. */
59
63
  export interface LoginUrl {
@@ -68,6 +72,19 @@ export interface LoginUrl {
68
72
  /** Pass True to request the permission for your bot to send messages to the user. */
69
73
  request_write_access?: boolean;
70
74
  }
75
+ /** This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */
76
+ export interface SwitchInlineQueryChosenChat {
77
+ /** The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */
78
+ query?: string;
79
+ /** True, if private chats with users can be chosen */
80
+ allow_user_chats?: boolean;
81
+ /** True, if private chats with bots can be chosen */
82
+ allow_bot_chats?: boolean;
83
+ /** True, if group and supergroup chats can be chosen */
84
+ allow_group_chats?: boolean;
85
+ /** True, if channel chats can be chosen */
86
+ allow_channel_chats?: boolean;
87
+ }
71
88
  /** A placeholder, currently holds no information. Use BotFather to set up your game. */
72
89
  export interface CallbackGame {
73
90
  }
package/message.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { InlineKeyboardMarkup } from "./markup.js";
2
1
  import type { Chat, File, User } from "./manage.js";
2
+ import type { InlineKeyboardMarkup } from "./markup.js";
3
3
  import type { PassportData } from "./passport.js";
4
4
  import type { Invoice, SuccessfulPayment } from "./payment.js";
5
5
  type MsgWith<P extends keyof Message> = Record<P, NonNullable<Message[P]>>;
@@ -243,6 +243,7 @@ __underline__
243
243
  *bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold*
244
244
  [inline URL](http://www.example.com/)
245
245
  [inline mention of a user](tg://user?id=123456789)
246
+ ![👍](tg://emoji?id=5368324170671202286)
246
247
  `inline fixed-width code`
247
248
  `​`​`
248
249
  pre-formatted fixed-width code block
@@ -256,6 +257,8 @@ Please note:
256
257
  - Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '\' character, in which case it is treated as an ordinary character and not a part of the markup. This implies that '\' character usually must be escaped with a preceding '\' character.
257
258
  - Inside `pre` and `code` entities, all '`' and '\' characters must be escaped with a preceding '\' character.
258
259
  - Inside `(...)` part of inline link definition, all ')' and '\' must be escaped with a preceding '\' character.
260
+ - A valid emoji must be provided as an alternative value for the custom emoji. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker.
261
+ - Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.
259
262
  - In all other places characters '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' must be escaped with the preceding character '\'.
260
263
  - In case of ambiguity between `italic` and `underline` entities `__` is always greadily treated from left to right as beginning or end of `underline` entity, so instead of `___italic underline___` use `___italic underline_\r__`, where `\r` is a character with code 13, which will be ignored.
261
264
 
@@ -271,6 +274,7 @@ To use this mode, pass *HTML* in the *parse_mode* field. The following tags are
271
274
  <b>bold <i>italic bold <s>italic bold strikethrough <span class="tg-spoiler">italic bold strikethrough spoiler</span></s> <u>underline italic bold</u></i> bold</b>
272
275
  <a href="http://www.example.com/">inline URL</a>
273
276
  <a href="tg://user?id=123456789">inline mention of a user</a>
277
+ <tg-emoji emoji-id="5368324170671202286">👍</tg-emoji>
274
278
  <code>inline fixed-width code</code>
275
279
  <pre>pre-formatted fixed-width code block</pre>
276
280
  <pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>
@@ -283,6 +287,8 @@ Please note:
283
287
  - The API currently supports only the following named HTML entities: `&lt;`, `&gt;`, `&amp;` and `&quot;`.
284
288
  - Use nested `pre` and `code` tags, to define programming language for pre entity.
285
289
  - Programming language can't be specified for standalone `code` tags.
290
+ - A valid emoji must be used as the content of the tg-emoji tag. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker.
291
+ - Custom emoji entities can only be used by bots that purchased additional usernames on Fragment.
286
292
 
287
293
  #### Markdown style
288
294
  This is a legacy mode, retained for backward compatibility. To use this mode, pass *Markdown* in the *parse_mode* field. Use the following syntax in your message:
@@ -615,8 +621,10 @@ export interface ChatShared {
615
621
  /** Identifier of the shared chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. */
616
622
  chat_id: number;
617
623
  }
618
- /** This object represents a service message about a user allowing a bot added to the attachment menu to write messages. Currently holds no information. */
624
+ /** This object represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link. */
619
625
  export interface WriteAccessAllowed {
626
+ /** Name of the Web App which was launched from a link */
627
+ web_app_name?: string;
620
628
  }
621
629
  /** This object represents a service message about a video chat scheduled in the chat. */
622
630
  export interface VideoChatScheduled {
package/methods.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { InlineQueryResult } from "./inline.js";
1
+ import type { InlineQueryResult, InlineQueryResultsButton } from "./inline.js";
2
2
  import type { BotCommand, ChatAdministratorRights, ChatFromGetChat, ChatInviteLink, ChatMember, ChatMemberAdministrator, ChatMemberOwner, ChatPermissions, File, ForumTopic, UserFromGetMe, UserProfilePhotos, WebhookInfo } from "./manage.js";
3
3
  import type { ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "./markup.js";
4
4
  import type { GameHighScore, MaskPosition, Message, MessageEntity, MessageId, ParseMode, Poll, SentWebAppMessage, Sticker, StickerSet } from "./message.js";
5
5
  import type { PassportElementError } from "./passport.js";
6
6
  import type { LabeledPrice, ShippingOption } from "./payment.js";
7
- import type { BotCommandScope, BotDescription, BotShortDescription, MenuButton } from "./settings.js";
7
+ import type { BotCommandScope, BotDescription, BotName, BotShortDescription, MenuButton } from "./settings.js";
8
8
  import type { Update } from "./update.js";
9
9
  /** Extracts the parameters of a given method name */
10
10
  type Params<F, M extends keyof ApiMethods<F>> = Parameters<ApiMethods<F>[M]>;
@@ -20,7 +20,7 @@ export type ApiMethods<F> = {
20
20
  1. This method will not work if an outgoing webhook is set up.
21
21
  2. In order to avoid getting duplicate updates, recalculate offset after each server response. */
22
22
  getUpdates(args?: {
23
- /** Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten. */
23
+ /** Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten. */
24
24
  offset?: number;
25
25
  /** Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. */
26
26
  limit?: number;
@@ -920,6 +920,18 @@ export type ApiMethods<F> = {
920
920
  /** The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. */
921
921
  cache_time?: number;
922
922
  }): true;
923
+ /** Use this method to change the bot's name. Returns True on success. */
924
+ setMyName(args: {
925
+ /** New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language. */
926
+ name?: string;
927
+ /** A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name. */
928
+ language_code?: string;
929
+ }): true;
930
+ /** Use this method to get the current bot name for the given user language. Returns BotName on success. */
931
+ getMyName(args: {
932
+ /** A two-letter ISO 639-1 language code or an empty string */
933
+ language_code?: string;
934
+ }): BotName;
923
935
  /** Use this method to change the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success. */
924
936
  setMyCommands(args: {
925
937
  /** A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. */
@@ -943,18 +955,6 @@ export type ApiMethods<F> = {
943
955
  /** A two-letter ISO 639-1 language code or an empty string */
944
956
  language_code?: string;
945
957
  }): BotCommand[];
946
- /** Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. */
947
- setChatMenuButton(args: {
948
- /** Unique identifier for the target private chat. If not specified, default bot's menu button will be changed */
949
- chat_id?: number;
950
- /** An object for the bot's new menu button. Defaults to MenuButtonDefault */
951
- menu_button?: MenuButton;
952
- }): true;
953
- /** Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. */
954
- getChatMenuButton(args: {
955
- /** Unique identifier for the target private chat. If not specified, default bot's menu button will be returned */
956
- chat_id?: number;
957
- }): MenuButton;
958
958
  /** Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. */
959
959
  setMyDescription(args: {
960
960
  /** New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. */
@@ -979,6 +979,18 @@ export type ApiMethods<F> = {
979
979
  /** A two-letter ISO 639-1 language code or an empty string */
980
980
  language_code?: string;
981
981
  }): BotShortDescription;
982
+ /** Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. */
983
+ setChatMenuButton(args: {
984
+ /** Unique identifier for the target private chat. If not specified, default bot's menu button will be changed */
985
+ chat_id?: number;
986
+ /** An object for the bot's new menu button. Defaults to MenuButtonDefault */
987
+ menu_button?: MenuButton;
988
+ }): true;
989
+ /** Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. */
990
+ getChatMenuButton(args: {
991
+ /** Unique identifier for the target private chat. If not specified, default bot's menu button will be returned */
992
+ chat_id?: number;
993
+ }): MenuButton;
982
994
  /** Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success. */
983
995
  setMyDefaultAdministratorRights(args: {
984
996
  /** An object describing new default administrator rights. If not specified, the default administrator rights will be cleared. */
@@ -1218,10 +1230,8 @@ export type ApiMethods<F> = {
1218
1230
  is_personal?: boolean;
1219
1231
  /** Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. */
1220
1232
  next_offset?: string;
1221
- /** If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter */
1222
- switch_pm_text?: string;
1223
- /** Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. */
1224
- switch_pm_parameter?: string;
1233
+ /** An object describing a button to be shown above inline query results */
1234
+ button?: InlineQueryResultsButton;
1225
1235
  }): true;
1226
1236
  /** Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. */
1227
1237
  answerWebAppQuery(args: {
package/mod.d.ts CHANGED
@@ -2,9 +2,9 @@ export * from "./api.js";
2
2
  export * from "./inline.js";
3
3
  export * from "./manage.js";
4
4
  export * from "./markup.js";
5
- export * from "./settings.js";
6
5
  export * from "./message.js";
6
+ export * from "./methods.js";
7
7
  export * from "./passport.js";
8
8
  export * from "./payment.js";
9
- export * from "./methods.js";
9
+ export * from "./settings.js";
10
10
  export * from "./update.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grammyjs/types",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "Telegram Bot API type declarations for grammY",
5
5
  "main": "mod.js",
6
6
  "repository": {
package/settings.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import type { WebAppInfo } from "./markup.js";
2
+ /** This object represents the bot's name. */
3
+ export interface BotName {
4
+ /** The bot's name */
5
+ name: string;
6
+ }
2
7
  /** This object represents the bot's description. */
3
8
  export interface BotDescription {
4
9
  /** The bot's description */
package/update.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { CallbackQuery } from "./markup.js";
2
1
  import type { ChosenInlineResult, InlineQuery } from "./inline.js";
3
2
  import type { Chat, ChatJoinRequest, ChatMemberUpdated, User } from "./manage.js";
3
+ import type { CallbackQuery } from "./markup.js";
4
4
  import type { Message, Poll, PollAnswer } from "./message.js";
5
5
  import type { PreCheckoutQuery, ShippingQuery } from "./payment.js";
6
6
  /** Internal namespace used to make some message types more accurate */