@mtkruto/node 0.0.935 → 0.0.937

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.
Files changed (43) hide show
  1. package/esm/client/3_client.js +5 -5
  2. package/esm/constants.d.ts +1 -1
  3. package/esm/constants.js +1 -1
  4. package/esm/types/0_chat_administrator_rights.d.ts +13 -0
  5. package/esm/types/0_chat_photo.d.ts +6 -0
  6. package/esm/types/0_force_reply.d.ts +4 -0
  7. package/esm/types/0_keyboard_button_poll_type.d.ts +2 -0
  8. package/esm/types/0_login_url.d.ts +5 -0
  9. package/esm/types/0_message_entity.d.ts +7 -0
  10. package/esm/types/0_reply_keyboard_remove.d.ts +3 -0
  11. package/esm/types/0_thumbnail.d.ts +5 -0
  12. package/esm/types/0_web_app_info.d.ts +2 -0
  13. package/esm/types/1_chat.d.ts +32 -0
  14. package/esm/types/1_inline_keyboard_button.d.ts +9 -0
  15. package/esm/types/1_keyboard_button.d.ts +21 -0
  16. package/esm/types/1_photo.d.ts +5 -0
  17. package/esm/types/1_user.d.ts +15 -0
  18. package/esm/types/2_inline_keyboard_markup.d.ts +2 -0
  19. package/esm/types/2_reply_keyboard_markup.d.ts +7 -0
  20. package/esm/types/3_message.d.ts +36 -4
  21. package/esm/types/3_message.js +58 -32
  22. package/package.json +1 -1
  23. package/script/client/3_client.js +5 -5
  24. package/script/constants.d.ts +1 -1
  25. package/script/constants.js +1 -1
  26. package/script/types/0_chat_administrator_rights.d.ts +13 -0
  27. package/script/types/0_chat_photo.d.ts +6 -0
  28. package/script/types/0_force_reply.d.ts +4 -0
  29. package/script/types/0_keyboard_button_poll_type.d.ts +2 -0
  30. package/script/types/0_login_url.d.ts +5 -0
  31. package/script/types/0_message_entity.d.ts +7 -0
  32. package/script/types/0_reply_keyboard_remove.d.ts +3 -0
  33. package/script/types/0_thumbnail.d.ts +5 -0
  34. package/script/types/0_web_app_info.d.ts +2 -0
  35. package/script/types/1_chat.d.ts +32 -0
  36. package/script/types/1_inline_keyboard_button.d.ts +9 -0
  37. package/script/types/1_keyboard_button.d.ts +21 -0
  38. package/script/types/1_photo.d.ts +5 -0
  39. package/script/types/1_user.d.ts +15 -0
  40. package/script/types/2_inline_keyboard_markup.d.ts +2 -0
  41. package/script/types/2_reply_keyboard_markup.d.ts +7 -0
  42. package/script/types/3_message.d.ts +36 -4
  43. package/script/types/3_message.js +58 -32
@@ -22,7 +22,59 @@ import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js"
22
22
  import { constructContact } from "./0_contact.js";
23
23
  import { constructGame } from "./2_game.js";
24
24
  const d = debug("types/Message");
25
+ async function getSender(message_, getEntity) {
26
+ if (message_.fromId instanceof types.PeerUser) {
27
+ const entity = await getEntity(message_.fromId);
28
+ if (entity) {
29
+ return { from: constructUser(entity) };
30
+ }
31
+ else {
32
+ UNREACHABLE();
33
+ }
34
+ }
35
+ else if (message_.fromId instanceof types.PeerChannel) {
36
+ const entity = await getEntity(message_.fromId);
37
+ if (entity) {
38
+ return { senderChat: constructChat(entity) };
39
+ }
40
+ else {
41
+ UNREACHABLE();
42
+ }
43
+ }
44
+ }
45
+ async function getReply(message_, chat, getMessage) {
46
+ if (getMessage && message_.replyTo instanceof types.MessageReplyHeader) {
47
+ let isTopicMessage = false;
48
+ if (message_.replyTo.forumTopic) {
49
+ isTopicMessage = true;
50
+ }
51
+ const replyToMessage = await getMessage(chat.id, message_.replyTo.replyToMsgId);
52
+ if (replyToMessage) {
53
+ return { replyToMessage, threadId: message_.replyTo.replyToTopId, isTopicMessage };
54
+ }
55
+ else {
56
+ d("couldn't get replied message");
57
+ }
58
+ }
59
+ else {
60
+ return {};
61
+ }
62
+ }
63
+ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
64
+ const message = {
65
+ id: message_.id,
66
+ chat: chat,
67
+ date: new Date(message_.date * 1000),
68
+ isTopicMessage: false,
69
+ };
70
+ Object.assign(message, await getReply(message_, chat, getMessage));
71
+ Object.assign(message, await getSender(message_, getEntity));
72
+ return message;
73
+ }
25
74
  export async function constructMessage(message_, getEntity, getMessage, getStickerSetName) {
75
+ if (!(message_ instanceof types.Message) && !(message_ instanceof types.MessageService)) {
76
+ UNREACHABLE();
77
+ }
26
78
  let chat_ = null;
27
79
  if (message_.peerId instanceof types.PeerUser) {
28
80
  const entity = await getEntity(message_.peerId);
@@ -54,37 +106,25 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
54
106
  else {
55
107
  UNREACHABLE();
56
108
  }
109
+ if (message_ instanceof types.MessageService) {
110
+ return await constructServiceMessage(message_, chat_, getEntity, getMessage);
111
+ }
57
112
  const message = {
58
113
  id: message_.id,
59
114
  chat: chat_,
115
+ date: new Date(message_.date * 1000),
60
116
  views: message_.views,
61
117
  isTopicMessage: false,
62
118
  hasProtectedContent: message_.noforwards || false,
63
119
  };
120
+ Object.assign(message, await getReply(message_, chat_, getMessage));
121
+ Object.assign(message, await getSender(message_, getEntity));
64
122
  if (message_.media instanceof types.MessageMediaPhoto || message_.media instanceof types.MessageMediaDocument) {
65
123
  message.hasMediaSpoiler = message_.media.spoiler || false;
66
124
  }
67
125
  if (message_.groupedId != undefined) {
68
126
  message.mediaGroupId = String(message_.groupedId);
69
127
  }
70
- if (message_.fromId instanceof types.PeerUser) {
71
- const entity = await getEntity(message_.fromId);
72
- if (entity) {
73
- message.from = constructUser(entity);
74
- }
75
- else {
76
- UNREACHABLE();
77
- }
78
- }
79
- else if (message_.fromId instanceof types.PeerChannel) {
80
- const entity = await getEntity(message_.fromId);
81
- if (entity) {
82
- message.senderChat = constructChat(entity);
83
- }
84
- else {
85
- UNREACHABLE();
86
- }
87
- }
88
128
  if (message_.message) {
89
129
  if (message_.media == undefined) {
90
130
  message.text = message_.message;
@@ -101,7 +141,6 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
101
141
  message.captionEntities = message_.entities.map(constructMessageEntity).filter((v) => v);
102
142
  }
103
143
  }
104
- message.date = new Date(message_.date * 1000);
105
144
  if (message_.editDate != undefined) {
106
145
  message.editDate = new Date(message_.editDate * 1000);
107
146
  }
@@ -122,19 +161,6 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
122
161
  UNREACHABLE();
123
162
  }
124
163
  }
125
- if (getMessage && message_.replyTo instanceof types.MessageReplyHeader) {
126
- if (message_.replyTo.forumTopic) {
127
- message.isTopicMessage = true;
128
- }
129
- const replyToMessage = await getMessage(message.chat.id, message_.replyTo.replyToMsgId);
130
- if (replyToMessage) {
131
- message.replyToMessage = replyToMessage;
132
- message.threadId = message_.replyTo.replyToTopId;
133
- }
134
- else {
135
- d("couldn't get replied message");
136
- }
137
- }
138
164
  if (message_.viaBotId != undefined) {
139
165
  const viaBot = await getEntity(new types.PeerUser({ userId: message_.viaBotId }));
140
166
  if (viaBot) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.935",
5
+ "version": "0.0.937",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -661,7 +661,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
661
661
  (update instanceof types.UpdateDeleteChannelMessages) ||
662
662
  (update instanceof types.UpdateEditChannelMessage) ||
663
663
  (update instanceof types.UpdateChannelWebPage))) {
664
- const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message[_1_tl_object_js_1.as](types.Message).peerId[_1_tl_object_js_1.as](types.PeerChannel).channelId : update.channelId;
664
+ const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peerId[_1_tl_object_js_1.as](types.PeerChannel).channelId : update.channelId;
665
665
  let localPts = await this.storage.getChannelPts(channelId);
666
666
  if (!localPts) {
667
667
  localPts = update.pts - update.ptsCount;
@@ -709,7 +709,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
709
709
  (update instanceof types.UpdateDeleteChannelMessages) ||
710
710
  (update instanceof types.UpdateEditChannelMessage) ||
711
711
  (update instanceof types.UpdateChannelWebPage)) {
712
- const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message[_1_tl_object_js_1.as](types.Message).peerId[_1_tl_object_js_1.as](types.PeerChannel).channelId : update.channelId;
712
+ const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peerId[_1_tl_object_js_1.as](types.PeerChannel).channelId : update.channelId;
713
713
  await this.recoverChannelUpdateGap(channelId, "applyUpdate");
714
714
  }
715
715
  else if ((update instanceof types.UpdateNewMessage) ||
@@ -1109,10 +1109,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1109
1109
  if (result instanceof types.Updates) {
1110
1110
  for (const update of result.updates) {
1111
1111
  if (update instanceof types.UpdateNewMessage) {
1112
- return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1112
+ return (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1113
1113
  }
1114
1114
  else if (update instanceof types.UpdateNewChannelMessage) {
1115
- return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1115
+ return (0, _3_message_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1116
1116
  }
1117
1117
  }
1118
1118
  }
@@ -1140,7 +1140,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1140
1140
  }
1141
1141
  const messages = new Array();
1142
1142
  for (const message_ of messages_.messages) {
1143
- messages.push(await (0, _3_message_js_1.constructMessage)(message_[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), null, this[exports.getStickerSetName].bind(this)));
1143
+ messages.push(await (0, _3_message_js_1.constructMessage)(message_, this[exports.getEntity].bind(this), null, this[exports.getStickerSetName].bind(this)));
1144
1144
  }
1145
1145
  return messages;
1146
1146
  }
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
4
4
  export declare const VECTOR_CONSTRUCTOR = 481674261;
5
5
  export declare const DEFAULT_INITIAL_DC: DC;
6
6
  export declare const LAYER = 158;
7
- export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.935";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.937";
8
8
  export declare const DEFAULT_DEVICE_MODEL: string;
9
9
  export declare const DEFAULT_LANG_CODE: string;
10
10
  export declare const DEFAULT_LANG_PACK = "";
@@ -88,7 +88,7 @@ exports.publicKeys = new Map([
88
88
  exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
89
89
  exports.DEFAULT_INITIAL_DC = "2-test";
90
90
  exports.LAYER = 158;
91
- exports.DEFAULT_APP_VERSION = "MTKruto 0.0.935";
91
+ exports.DEFAULT_APP_VERSION = "MTKruto 0.0.937";
92
92
  // @ts-ignore: lib
93
93
  exports.DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
94
94
  exports.DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -1,16 +1,29 @@
1
1
  import * as types from "../tl/2_types.js";
2
+ /** Represents the rights of an administrator in a chat. */
2
3
  export interface ChatAdministratorRights {
4
+ /** True, if the user's presence in the chat is hidden */
3
5
  isAnonymous: boolean;
6
+ /** True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege */
4
7
  canManageChat: boolean;
8
+ /** True, if the administrator can delete messages of other users */
5
9
  canDeleteMessages: boolean;
10
+ /** True, if the administrator can manage video chats */
6
11
  canManageVideoChats: boolean;
12
+ /** True, if the administrator can restrict, ban or unban chat members */
7
13
  canRestrictMembers: boolean;
14
+ /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */
8
15
  canPromoteMembers: boolean;
16
+ /** True, if the user is allowed to change the chat title, photo and other settings */
9
17
  canChangeInfo: boolean;
18
+ /** True, if the user is allowed to invite new users to the chat */
10
19
  canInviteUsers: boolean;
20
+ /** Optional. True, if the administrator can post in the channel; channels only */
11
21
  canPostMessages?: boolean;
22
+ /** Optional. True, if the administrator can edit messages of other users and can pin messages; channels only */
12
23
  canEditMessages?: boolean;
24
+ /** Optional. True, if the user is allowed to pin messages; groups and supergroups only */
13
25
  canPinMessages?: boolean;
26
+ /** Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only */
14
27
  canManageTopics?: boolean;
15
28
  }
16
29
  export declare function constructChatAdministratorRights(rights_: types.ChatAdminRights): ChatAdministratorRights;
@@ -1,10 +1,15 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  export declare namespace ChatPhoto {
3
3
  interface Base {
4
+ /** File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */
4
5
  smallFileId: string;
6
+ /** Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
5
7
  smallFileUniqueId: string;
8
+ /** File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */
6
9
  bigFileId: string;
10
+ /** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
7
11
  bigFileUniqueId: string;
12
+ /** True, if an [animated profile picture](https://core.telegram.org/api/files#animated-profile-pictures) is available for the user */
8
13
  hasVideo: boolean;
9
14
  }
10
15
  interface User extends Base {
@@ -12,6 +17,7 @@ export declare namespace ChatPhoto {
12
17
  }
13
18
  type Chat = Base;
14
19
  }
20
+ /** This object represents a chat photo. */
15
21
  export type ChatPhoto = ChatPhoto.User | ChatPhoto.Chat;
16
22
  export declare function constructChatPhoto(photo: types.ChatPhoto, chatId: number, chatAccessHash: bigint): ChatPhoto.Chat;
17
23
  export declare function constructChatPhoto(photo: types.UserProfilePhoto, chatId: number, chatAccessHash: bigint): ChatPhoto.User;
@@ -1,7 +1,11 @@
1
1
  import * as types from "../tl/2_types.js";
2
+ /** Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. */
2
3
  export interface ForceReply {
4
+ /** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */
3
5
  forceReply: true;
6
+ /** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */
4
7
  inputFieldPlaceholder?: string;
8
+ /** Optional. Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. */
5
9
  selective?: boolean;
6
10
  }
7
11
  export declare function constructForceReply(replyMarkup_: types.ReplyKeyboardForceReply): ForceReply;
@@ -1,3 +1,5 @@
1
+ /** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */
1
2
  export interface KeyboardButtonPollType {
3
+ /** Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. */
2
4
  type?: string;
3
5
  }
@@ -1,6 +1,11 @@
1
+ /** 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](https://core.telegram.org/widgets/login) when the user is coming from Telegram. */
1
2
  export interface LoginUrl {
3
+ /** An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in [Receiving authorization data](https://core.telegram.org/widgets/login#receiving-authorization-data). */
2
4
  url: string;
5
+ /** Optional. New text of the button in forwarded messages. */
3
6
  forwardText?: string;
7
+ /** Optional. Username of a bot, which will be used for user authorization. See [Setting up a bot](https://core.telegram.org/widgets/login#setting-up-a-bot) for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See [Linking your domain to the bot](https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot) for more details. */
4
8
  botUsername?: string;
9
+ /** Optional. Pass True to request the permission for your bot to send messages to the user. */
5
10
  requestWriteAccess?: boolean;
6
11
  }
@@ -22,7 +22,9 @@ export declare enum MessageEntityType {
22
22
  }
23
23
  export declare namespace MessageEntity {
24
24
  interface Base {
25
+ /** Offset in [UTF-16 code units](https://core.telegram.org/api/entities#entity-length) to the start of the entity */
25
26
  offset: number;
27
+ /** Length of the entity in [UTF-16 code units](https://core.telegram.org/api/entities#entity-length) */
26
28
  length: number;
27
29
  }
28
30
  interface Mention extends Base {
@@ -48,6 +50,7 @@ export declare namespace MessageEntity {
48
50
  }
49
51
  interface Pre extends Base {
50
52
  type: MessageEntityType.Pre;
53
+ /** Optional. For “pre” only, the programming language of the entity text */
51
54
  language: string;
52
55
  }
53
56
  interface Code extends Base {
@@ -55,10 +58,12 @@ export declare namespace MessageEntity {
55
58
  }
56
59
  interface TextURL extends Base {
57
60
  type: MessageEntityType.TextURL;
61
+ /** Optional. For “text_link” only, URL that will be opened after user taps on the text */
58
62
  url: string;
59
63
  }
60
64
  interface MentionName extends Base {
61
65
  type: MessageEntityType.MentionName;
66
+ /** Optional. For “text_mention” only, the ID of the mentioned user */
62
67
  userId: number;
63
68
  }
64
69
  interface Cashtag extends Base {
@@ -84,9 +89,11 @@ export declare namespace MessageEntity {
84
89
  }
85
90
  interface CustomEmoji extends Base {
86
91
  type: MessageEntityType.CustomEmoji;
92
+ /** Optional. For “custom_emoji” only, unique identifier of the custom emoji */
87
93
  customEmojiId: string;
88
94
  }
89
95
  }
96
+ /** This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. */
90
97
  export type MessageEntity = MessageEntity.Mention | MessageEntity.Hashtag | MessageEntity.BotCommand | MessageEntity.URL | MessageEntity.EmailAddress | MessageEntity.Bold | MessageEntity.Italic | MessageEntity.Code | MessageEntity.Pre | MessageEntity.TextURL | MessageEntity.MentionName | MessageEntity.Cashtag | MessageEntity.Phone | MessageEntity.Underline | MessageEntity.Strike | MessageEntity.Blockquote | MessageEntity.BankCard | MessageEntity.Spoiler | MessageEntity.CustomEmoji;
91
98
  export declare function constructMessageEntity(obj: types.TypeMessageEntity): MessageEntity | null;
92
99
  export declare function messageEntityToTlObject(entity: MessageEntity): types.MessageEntityMention | types.MessageEntityHashtag | types.MessageEntityBotCommand | types.MessageEntityURL | types.MessageEntityEmail | types.MessageEntityBold | types.MessageEntityItalic | types.MessageEntityCode | types.MessageEntityPre | types.MessageEntityTextURL | types.MessageEntityMentionName | types.MessageEntityPhone | types.MessageEntityCashtag | types.MessageEntityUnderline | types.MessageEntityStrike | types.MessageEntityBlockquote | types.MessageEntityBankCard | types.MessageEntitySpoiler | types.MessageEntityCustomEmoji;
@@ -1,6 +1,9 @@
1
1
  import * as types from "../tl/2_types.js";
2
+ /** Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button. */
2
3
  export interface ReplyKeyboardRemove {
4
+ /** Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use _one_time_keyboard_ in `ReplyKeyboardMarkup`) */
3
5
  removeKeyboard: true;
6
+ /** Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the `Message` object; 2) if the bot's message is a reply (has _reply_to_message_id_), sender of the original message. */
4
7
  selective?: boolean;
5
8
  }
6
9
  export declare function constructReplyKeyboardRemove(replyMarkup_: types.ReplyKeyboardHide): ReplyKeyboardRemove;
@@ -1,9 +1,14 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  export interface Thumbnail {
3
+ /** Identifier for this file, which can be used to download or reuse the file */
3
4
  fileId: string;
5
+ /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
4
6
  fileUniqueId: string;
7
+ /** Photo width */
5
8
  width: number;
9
+ /** Photo height */
6
10
  height: number;
11
+ /** Optional. File size in bytes */
7
12
  fileSize: number;
8
13
  }
9
14
  export declare function constructThumbnail(size: types.PhotoSize, file: types.Document | types.Photo): Thumbnail;
@@ -1,4 +1,6 @@
1
+ /** Describes a [Web App](https://core.telegram.org/bots/webapps). */
1
2
  export interface WebAppInfo {
3
+ /** An HTTPS URL of a Web App to be opened with additional data as specified in [Initializing Web Apps](https://core.telegram.org/bots/webapps#initializing-web-apps) */
2
4
  url: string;
3
5
  }
4
6
  export declare function constructWebAppInfo(url: string): WebAppInfo;
@@ -8,54 +8,86 @@ export declare enum ChatType {
8
8
  }
9
9
  export declare namespace Chat {
10
10
  interface Base {
11
+ /** Type of chat, can be either “private”, “group”, “supergroup” or “channel” */
11
12
  type: ChatType;
13
+ /** Unique identifier for this 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 signed 64-bit integer or double-precision float type are safe for storing this identifier. */
12
14
  id: number;
13
15
  idColor: string;
16
+ /** Optional. Chat photo. */
14
17
  photo?: ChatPhoto;
15
18
  }
16
19
  interface Private extends Base {
17
20
  type: ChatType.Private;
21
+ /** True, if this user is a bot */
18
22
  isBot?: boolean;
23
+ /** Optional. First name of the other party in a private chat */
19
24
  firstName: string;
25
+ /** Optional. Last name of the other party in a private chat */
20
26
  lastName?: string;
27
+ /** Optional. Username, for private chats, supergroups and channels if available */
21
28
  username?: string;
29
+ /** Optional. Additional usernames */
22
30
  also?: string[];
31
+ /** Optional. Chat photo. */
23
32
  photo?: ChatPhoto.User;
33
+ /** True, if the user is a scam user */
24
34
  isScam: boolean;
35
+ /** True, if this user was reported by many users as a fake or scam user: be careful when interacting with them. */
25
36
  isFake: boolean;
37
+ /** True, if the user is an official support user */
26
38
  isSupport: boolean;
39
+ /** True, if the user is verified */
27
40
  isVerified: boolean;
41
+ /** True, if the access to the user must be restricted for the reason specified in `restriction_reason` */
28
42
  isRestricted?: boolean;
43
+ /** Optional. Contains the reason why access to the user must be restricted. */
29
44
  restrictionReason?: types.RestrictionReason[];
30
45
  }
31
46
  interface Group extends Base {
32
47
  type: ChatType.Group;
48
+ /** Optional. Title, for supergroups, channels and group chats */
33
49
  title: string;
50
+ /** Optional. Chat photo. */
34
51
  photo?: ChatPhoto.Chat;
52
+ /** True, if the user is creator of the chat */
35
53
  isCreator: boolean;
36
54
  }
37
55
  interface ChannelBase extends Base {
56
+ /** Optional. Title, for supergroups, channels and group chats */
38
57
  title: string;
58
+ /** Optional. Username, for private chats, supergroups and channels if available */
39
59
  username?: string;
60
+ /** Optional. Additional usernames */
40
61
  also?: string[];
62
+ /** Optional. Chat photo. */
41
63
  photo?: ChatPhoto.Chat;
64
+ /** True, if the user is a scam user */
42
65
  isScam: boolean;
66
+ /** True, if this user was reported by many users as a fake or scam user: be careful when interacting with them. */
43
67
  isFake: boolean;
68
+ /** True, if the user is verified */
44
69
  isVerified: boolean;
70
+ /** True, if the access to the user must be restricted for the reason specified in `restriction_reason` */
45
71
  isRestricted: boolean;
72
+ /** Optional. Contains the reason why access to the user must be restricted. */
46
73
  restrictionReason?: types.RestrictionReason[];
47
74
  }
48
75
  interface Channel extends ChannelBase {
49
76
  type: ChatType.Channel;
77
+ /** Optional. Title, for supergroups, channels and group chats */
50
78
  title: string;
79
+ /** Optional. Username, for private chats, supergroups and channels if available */
51
80
  username?: string;
81
+ /** Optional. Additional usernames */
52
82
  also?: string[];
53
83
  }
54
84
  interface Supergroup extends ChannelBase {
55
85
  type: ChatType.Supergroup;
86
+ /** Optional. True, if the supergroup chat is a forum (has [topics](https://telegram.org/blog/topics-in-groups-collectible-usernames#topics-in-groups) enabled) */
56
87
  isForum: boolean;
57
88
  }
58
89
  }
90
+ /** This object represents a chat. */
59
91
  export type Chat = Chat.Private | Chat.Group | Chat.Supergroup | Chat.Channel;
60
92
  export declare function constructChat(chat: types.User): Chat.Private;
61
93
  export declare function constructChat(chat: types.Chat): Chat.Group;
@@ -4,33 +4,42 @@ import { WebAppInfo } from "./0_web_app_info.js";
4
4
  import { LoginUrl } from "./0_login_url.js";
5
5
  export declare namespace InlineKeyboardButton {
6
6
  interface Base {
7
+ /** Label text on the button */
7
8
  text: string;
8
9
  }
9
10
  interface URL extends Base {
11
+ /** Optional. HTTP or tg:// URL to be opened when the button is pressed. Links `tg://user?id=<user_id>` can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. */
10
12
  url: string;
11
13
  }
12
14
  interface Callback extends Base {
15
+ /** Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes */
13
16
  callbackData: string;
14
17
  }
15
18
  interface WebApp extends Base {
19
+ /** Optional. Description of the [Web App](https://core.telegram.org/bots/webapps) that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. */
16
20
  webApp: WebAppInfo;
17
21
  }
18
22
  interface Login extends Base {
23
+ /** Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the [Telegram Login Widget](https://core.telegram.org/widgets/login). */
19
24
  loginUrl: LoginUrl;
20
25
  }
21
26
  interface SwitchInline extends Base {
27
+ /** Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. */
22
28
  switchInlineQuery: string;
23
29
  }
24
30
  interface SwitchInlineCurrent extends Base {
31
+ /** Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. */
25
32
  switchInlineQueryCurrentChat: string;
26
33
  }
27
34
  interface Game extends Base {
28
35
  callbackGame: Record<never, never>;
29
36
  }
30
37
  interface Pay extends Base {
38
+ /** Optional. Specify True, to send a [Pay button](https://core.telegram.org/bots/api#payments). */
31
39
  pay: boolean;
32
40
  }
33
41
  }
42
+ /** This object represents one button of an inline keyboard. You **must** use exactly one of the optional fields. */
34
43
  export type InlineKeyboardButton = InlineKeyboardButton.URL | InlineKeyboardButton.Callback | InlineKeyboardButton.WebApp | InlineKeyboardButton.Login | InlineKeyboardButton.SwitchInline | InlineKeyboardButton.SwitchInlineCurrent | InlineKeyboardButton.Game | InlineKeyboardButton.Pay;
35
44
  export declare function constructInlineKeyboardButton(button_: types.TypeKeyboardButton): InlineKeyboardButton;
36
45
  export declare function inlineKeyboardButtonToTlObject(button: InlineKeyboardButton, usernameResolver: (username: string) => MaybePromise<types.InputUser>): Promise<types.KeyboardButtonURL | types.KeyboardButtonCallback | types.KeyboardButtonSwitchInline | types.KeyboardButtonBuy | types.InputKeyboardButtonURLAuth | types.KeyboardButtonWebView>;
@@ -4,40 +4,61 @@ import { KeyboardButtonPollType } from "./0_keyboard_button_poll_type.js";
4
4
  import { WebAppInfo } from "./0_web_app_info.js";
5
5
  export declare namespace KeyboardButton {
6
6
  interface Text {
7
+ /** Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed */
7
8
  text: string;
8
9
  }
10
+ /** This object defines the criteria used to request a suitable user. The identifier of the selected user will be shared with the bot when the corresponding button is pressed. [More about requesting users](https://core.telegram.org/bots/features#chat-and-user-selection) */
9
11
  interface RequestUser extends Text {
12
+ /** Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a “user_shared” service message. Available in private chats only. */
10
13
  requestUser: {
14
+ /** Signed 32-bit identifier of the request, which will be received back in the [UserShared](https://core.telegram.org/bots/api#usershared) object. Must be unique within the message */
11
15
  requestId: number;
16
+ /** Optional. Pass True to request a bot, pass False to request a regular user. If not specified, no additional restrictions are applied. */
12
17
  userIsBot?: boolean;
18
+ /** Optional. Pass True to request a premium user, pass False to request a non-premium user. If not specified, no additional restrictions are applied. */
13
19
  userIsPremium?: boolean;
14
20
  };
15
21
  }
22
+ /** This object defines the criteria used to request a suitable chat. The identifier of the selected chat will be shared with the bot when the corresponding button is pressed. [More about requesting chats](https://core.telegram.org/bots/features#chat-and-user-selection) */
16
23
  interface RequestChat extends Text {
24
+ /** Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only. */
17
25
  requestChat: {
26
+ /** Signed 32-bit identifier of the request, which will be received back in the [ChatShared](https://core.telegram.org/bots/api#chatshared) object. Must be unique within the message */
18
27
  requestId: number;
28
+ /** Pass True to request a channel chat, pass False to request a group or a supergroup chat. */
19
29
  chatIsChannel: boolean;
30
+ /** Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied. */
20
31
  chatIsForum?: boolean;
32
+ /** Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied. */
21
33
  chatHasUsername?: boolean;
34
+ /** Optional. Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied. */
22
35
  chatIsCreated?: boolean;
36
+ /** Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of _bot_administrator_rights_. If not specified, no additional restrictions are applied. */
23
37
  userAdministratorRights?: ChatAdministratorRights;
38
+ /** Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of _user_administrator_rights_. If not specified, no additional restrictions are applied. */
24
39
  botAdministratorRights?: ChatAdministratorRights;
40
+ /** Optional. Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied. */
25
41
  botIsMember?: boolean;
26
42
  };
27
43
  }
28
44
  interface RequestContact extends Text {
45
+ /** Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */
29
46
  requestContact: true;
30
47
  }
31
48
  interface RequestLocation extends Text {
49
+ /** Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only. */
32
50
  requestLocation: true;
33
51
  }
34
52
  interface RequestPoll extends Text {
53
+ /** Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only. */
35
54
  requestPoll: KeyboardButtonPollType;
36
55
  }
37
56
  interface WebApp extends Text {
57
+ /** Optional. If specified, the described [Web App](https://core.telegram.org/bots/webapps) will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only. */
38
58
  webApp: WebAppInfo;
39
59
  }
40
60
  }
61
+ /** This object represents one button of the reply keyboard. For simple text buttons, _String_ can be used instead of this object to specify the button text. The optional fields _web_app_, _request_user_, _request_chat_, _request_contact_, _request_location_, and _request_poll_ are mutually exclusive. */
41
62
  export type KeyboardButton = KeyboardButton.Text | KeyboardButton.RequestUser | KeyboardButton.RequestChat | KeyboardButton.RequestContact | KeyboardButton.RequestLocation | KeyboardButton.RequestPoll | KeyboardButton.WebApp;
42
63
  export declare function constructKeyboardButton(button_: types.TypeKeyboardButton): KeyboardButton;
43
64
  export declare function keyboardButtonToTlObject(button: KeyboardButton): types.KeyboardButtonRequestPhone | types.KeyboardButtonRequestGeoLocation | types.KeyboardButtonRequestPoll | types.KeyboardButtonWebView | types.KeyboardButtonRequestPeer;
@@ -1,10 +1,15 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  import { Thumbnail } from "./0_thumbnail.js";
3
3
  export interface Photo {
4
+ /** Identifier for this file, which can be used to download or reuse the file */
4
5
  fileId: string;
6
+ /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
5
7
  fileUniqueId: string;
8
+ /** Photo width */
6
9
  width: number;
10
+ /** Photo height */
7
11
  height: number;
12
+ /** Optional. File size in bytes */
8
13
  fileSize: number;
9
14
  thumbnails: Thumbnail[];
10
15
  }
@@ -1,20 +1,35 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  import { ChatPhoto } from "./0_chat_photo.js";
3
+ /** This object represents a Telegram user or bot. */
3
4
  export interface User {
5
+ /** Unique identifier for this user or bot. 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. */
4
6
  id: number;
5
7
  idColor: string;
8
+ /** True, if this user is a bot */
6
9
  isBot: boolean;
10
+ /** User's or bot's first name */
7
11
  firstName: string;
12
+ /** Optional. User's or bot's last name */
8
13
  lastName?: string;
14
+ /** Optional. User's or bot's username */
9
15
  username?: string;
16
+ /** Optional. Additional usernames */
10
17
  also?: string[];
18
+ /** Optional. Chat photo */
11
19
  photo?: ChatPhoto.User;
20
+ /** Optional. [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the user's language */
12
21
  languageCode?: string;
22
+ /** True, if the user is a scam user */
13
23
  isScam: boolean;
24
+ /** True, if this user was reported by many users as a fake or scam user: be careful when interacting with them. */
14
25
  isFake: boolean;
26
+ /** Optional. True, if this user is a Telegram Premium user */
15
27
  isPremium: boolean;
28
+ /** True, if the user is verified */
16
29
  isVerified: boolean;
30
+ /** True, if the user is an official support user */
17
31
  isSupport: boolean;
32
+ /** Optional. True, if this user added the bot to the attachment menu */
18
33
  addedToAttachmentMenu: boolean;
19
34
  }
20
35
  export declare function constructUser(user_: types.User): User;
@@ -1,6 +1,8 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  import { InlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./1_inline_keyboard_button.js";
3
+ /** This object represents an [inline keyboard](https://core.telegram.org/bots/features#inline-keyboards) that appears right next to the message it belongs to. */
3
4
  export interface InlineKeyboardMarkup {
5
+ /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */
4
6
  inlineKeyboard: InlineKeyboardButton[][];
5
7
  }
6
8
  export declare function constructInlineKeyboardMarkup(keyboard_: types.ReplyInlineMarkup): InlineKeyboardMarkup;