@mtkruto/node 0.1.157 → 0.1.160
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/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +2 -2
- package/esm/client/1_composer.d.ts +2 -2
- package/esm/client/1_composer.js +4 -4
- package/esm/client/1_file_manager.js +53 -56
- package/esm/client/2_message_manager.js +8 -11
- package/esm/client/4_client.d.ts +2 -2
- package/esm/client/4_client.js +4 -4
- package/esm/tl/2_types.d.ts +596 -1
- package/esm/tl/2_types.js +1824 -319
- package/esm/tl/3_functions.d.ts +374 -2
- package/esm/tl/3_functions.js +943 -31
- package/esm/types/0__file_id.d.ts +79 -54
- package/esm/types/0__file_id.js +259 -277
- package/esm/types/0_chat_photo.js +15 -21
- package/esm/types/0_giveaway_parameters.d.ts +5 -0
- package/esm/types/0_login_url.d.ts +4 -0
- package/esm/types/0_message_reference.d.ts +2 -0
- package/esm/types/0_price_tag.d.ts +2 -0
- package/esm/types/0_thumbnail.js +16 -14
- package/esm/types/1_giveaway.d.ts +2 -0
- package/esm/types/1_inline_query_result_button.d.ts +3 -0
- package/esm/types/1_photo.js +20 -14
- package/esm/types/1_poll.d.ts +13 -0
- package/esm/types/1_reaction_count.d.ts +2 -0
- package/esm/types/1_reply_quote.d.ts +3 -0
- package/esm/types/1_user.d.ts +13 -13
- package/esm/types/2_chosen_inline_result.d.ts +5 -0
- package/esm/types/2_game.d.ts +6 -0
- package/esm/types/2_game.js +11 -7
- package/esm/types/2_inactive_chat.d.ts +3 -0
- package/esm/types/2_inline_query.d.ts +6 -0
- package/esm/types/2_message_interactions.d.ts +5 -0
- package/esm/types/2_message_reaction_count.d.ts +4 -0
- package/esm/types/2_message_reactions.d.ts +7 -0
- package/esm/types/2_story_content.js +4 -7
- package/esm/types/4_inline_query_result.js +5 -5
- package/esm/types/4_message.js +21 -17
- package/esm/types/5_callback_query.d.ts +7 -0
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.js +26 -24
- package/package.json +1 -1
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +2 -2
- package/script/client/1_composer.d.ts +2 -2
- package/script/client/1_composer.js +4 -4
- package/script/client/1_file_manager.js +52 -55
- package/script/client/2_message_manager.js +6 -9
- package/script/client/4_client.d.ts +2 -2
- package/script/client/4_client.js +4 -4
- package/script/tl/2_types.d.ts +596 -1
- package/script/tl/2_types.js +1904 -345
- package/script/tl/3_functions.d.ts +374 -2
- package/script/tl/3_functions.js +977 -41
- package/script/types/0__file_id.d.ts +79 -54
- package/script/types/0__file_id.js +263 -280
- package/script/types/0_chat_photo.js +14 -20
- package/script/types/0_giveaway_parameters.d.ts +5 -0
- package/script/types/0_login_url.d.ts +4 -0
- package/script/types/0_message_reference.d.ts +2 -0
- package/script/types/0_price_tag.d.ts +2 -0
- package/script/types/0_thumbnail.js +15 -13
- package/script/types/1_giveaway.d.ts +2 -0
- package/script/types/1_inline_query_result_button.d.ts +3 -0
- package/script/types/1_photo.js +19 -13
- package/script/types/1_poll.d.ts +13 -0
- package/script/types/1_reaction_count.d.ts +2 -0
- package/script/types/1_reply_quote.d.ts +3 -0
- package/script/types/1_user.d.ts +13 -13
- package/script/types/2_chosen_inline_result.d.ts +5 -0
- package/script/types/2_game.d.ts +6 -0
- package/script/types/2_game.js +10 -6
- package/script/types/2_inactive_chat.d.ts +3 -0
- package/script/types/2_inline_query.d.ts +6 -0
- package/script/types/2_message_interactions.d.ts +5 -0
- package/script/types/2_message_reaction_count.d.ts +4 -0
- package/script/types/2_message_reactions.d.ts +7 -0
- package/script/types/2_story_content.js +3 -6
- package/script/types/4_inline_query_result.js +4 -4
- package/script/types/4_message.js +20 -16
- package/script/types/5_callback_query.d.ts +7 -0
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.js +26 -24
package/esm/types/0__file_id.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode, UNREACHABLE } from "../1_utilities.js";
|
|
2
2
|
import { TLReader, TLWriter } from "../2_tl.js";
|
|
3
|
+
const NEXT_VERSION = 53;
|
|
4
|
+
const PERSISTENT_ID_VERSION = 4;
|
|
5
|
+
const WEB_LOCATION_FLAG = 1 << 24;
|
|
6
|
+
const FILE_REFERENCE_FLAG = 1 << 25;
|
|
3
7
|
export var FileType;
|
|
4
8
|
(function (FileType) {
|
|
5
9
|
FileType[FileType["Thumbnail"] = 0] = "Thumbnail";
|
|
6
|
-
FileType[FileType["
|
|
10
|
+
FileType[FileType["ProfilePhoto"] = 1] = "ProfilePhoto";
|
|
7
11
|
FileType[FileType["Photo"] = 2] = "Photo";
|
|
8
|
-
FileType[FileType["
|
|
12
|
+
FileType[FileType["VoiceNote"] = 3] = "VoiceNote";
|
|
9
13
|
FileType[FileType["Video"] = 4] = "Video";
|
|
10
14
|
FileType[FileType["Document"] = 5] = "Document";
|
|
11
15
|
FileType[FileType["Encrypted"] = 6] = "Encrypted";
|
|
@@ -16,305 +20,283 @@ export var FileType;
|
|
|
16
20
|
FileType[FileType["EncryptedThumbnail"] = 11] = "EncryptedThumbnail";
|
|
17
21
|
FileType[FileType["Wallpaper"] = 12] = "Wallpaper";
|
|
18
22
|
FileType[FileType["VideoNote"] = 13] = "VideoNote";
|
|
19
|
-
FileType[FileType["
|
|
20
|
-
FileType[FileType["
|
|
23
|
+
FileType[FileType["SecureDecrypted"] = 14] = "SecureDecrypted";
|
|
24
|
+
FileType[FileType["SecureEncrypted"] = 15] = "SecureEncrypted";
|
|
21
25
|
FileType[FileType["Background"] = 16] = "Background";
|
|
22
26
|
FileType[FileType["DocumentAsFile"] = 17] = "DocumentAsFile";
|
|
27
|
+
FileType[FileType["Ringtone"] = 18] = "Ringtone";
|
|
28
|
+
FileType[FileType["CallLog"] = 19] = "CallLog";
|
|
29
|
+
FileType[FileType["PhotoStory"] = 20] = "PhotoStory";
|
|
30
|
+
FileType[FileType["VideoStory"] = 21] = "VideoStory";
|
|
31
|
+
FileType[FileType["Size"] = 22] = "Size";
|
|
32
|
+
FileType[FileType["None"] = 23] = "None";
|
|
23
33
|
})(FileType || (FileType = {}));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true,
|
|
59
|
-
writable: true,
|
|
60
|
-
value: void 0
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(this, "minor", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: void 0
|
|
67
|
-
});
|
|
68
|
-
if (major == null) {
|
|
69
|
-
this.major = FileID.MAJOR;
|
|
34
|
+
var FileTypeClass;
|
|
35
|
+
(function (FileTypeClass) {
|
|
36
|
+
FileTypeClass[FileTypeClass["Photo"] = 0] = "Photo";
|
|
37
|
+
FileTypeClass[FileTypeClass["Document"] = 1] = "Document";
|
|
38
|
+
FileTypeClass[FileTypeClass["Secure"] = 2] = "Secure";
|
|
39
|
+
FileTypeClass[FileTypeClass["Encrypted"] = 3] = "Encrypted";
|
|
40
|
+
FileTypeClass[FileTypeClass["Temp"] = 4] = "Temp";
|
|
41
|
+
})(FileTypeClass || (FileTypeClass = {}));
|
|
42
|
+
export var PhotoSourceType;
|
|
43
|
+
(function (PhotoSourceType) {
|
|
44
|
+
PhotoSourceType[PhotoSourceType["Legacy"] = 0] = "Legacy";
|
|
45
|
+
PhotoSourceType[PhotoSourceType["Thumbnail"] = 1] = "Thumbnail";
|
|
46
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoSmall"] = 2] = "ChatPhotoSmall";
|
|
47
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoBig"] = 3] = "ChatPhotoBig";
|
|
48
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnail"] = 4] = "StickerSetThumbnail";
|
|
49
|
+
PhotoSourceType[PhotoSourceType["FullLegacy"] = 5] = "FullLegacy";
|
|
50
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoSmallLegacy"] = 6] = "ChatPhotoSmallLegacy";
|
|
51
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoBigLegacy"] = 7] = "ChatPhotoBigLegacy";
|
|
52
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnailLegacy"] = 8] = "StickerSetThumbnailLegacy";
|
|
53
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnailVersion"] = 9] = "StickerSetThumbnailVersion";
|
|
54
|
+
})(PhotoSourceType || (PhotoSourceType = {}));
|
|
55
|
+
function deserializePhotoSource(reader) {
|
|
56
|
+
const type = reader.readInt32();
|
|
57
|
+
switch (type) {
|
|
58
|
+
case PhotoSourceType.Legacy:
|
|
59
|
+
return { type, secret: reader.readInt64() };
|
|
60
|
+
case PhotoSourceType.Thumbnail:
|
|
61
|
+
return { type, fileType: reader.readInt32(), thumbnailType: reader.readInt32() };
|
|
62
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
63
|
+
case PhotoSourceType.ChatPhotoBig: {
|
|
64
|
+
const chatId = reader.readInt64();
|
|
65
|
+
const chatAccessHash = reader.readInt64();
|
|
66
|
+
return { type, chatId, chatAccessHash };
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
case PhotoSourceType.StickerSetThumbnail: {
|
|
69
|
+
const stickerSetId = reader.readInt64();
|
|
70
|
+
const stickerSetAccessHash = reader.readInt64();
|
|
71
|
+
return { type, stickerSetId, stickerSetAccessHash };
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
this.minor = FileID.MINOR;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.minor = minor;
|
|
79
|
-
}
|
|
80
|
-
this.params.thumbnailSize ??= "";
|
|
81
|
-
}
|
|
82
|
-
static decode(fileId) {
|
|
83
|
-
const decoded = rleDecode(base64DecodeUrlSafe(fileId));
|
|
84
|
-
const major = decoded[decoded.length - 1];
|
|
85
|
-
let minor;
|
|
86
|
-
let buffer;
|
|
87
|
-
if (major < 4) {
|
|
88
|
-
minor = 0;
|
|
89
|
-
buffer = decoded.subarray(0, -1);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
minor = decoded[decoded.length - 2];
|
|
93
|
-
buffer = decoded.subarray(0, -2);
|
|
94
|
-
}
|
|
95
|
-
const reader = new TLReader(buffer);
|
|
96
|
-
let fileType = reader.readInt32();
|
|
97
|
-
const dcId = reader.readInt32();
|
|
98
|
-
const hasWebLocation = Boolean(fileType & WEB_LOCATION_FLAG);
|
|
99
|
-
const hasFileReference = Boolean(fileType & FILE_REFERENCE_FLAG);
|
|
100
|
-
fileType &= ~WEB_LOCATION_FLAG;
|
|
101
|
-
fileType &= ~FILE_REFERENCE_FLAG;
|
|
102
|
-
if (hasWebLocation) {
|
|
103
|
-
const url = reader.readString();
|
|
104
|
-
const accessHash = reader.readInt64();
|
|
105
|
-
return new FileID(major, minor, fileType, dcId, { url, accessHash });
|
|
106
|
-
}
|
|
107
|
-
let fileReference = new Uint8Array();
|
|
108
|
-
if (hasFileReference) {
|
|
109
|
-
fileReference = reader.readBytes();
|
|
110
|
-
}
|
|
111
|
-
const mediaId = reader.readInt64();
|
|
112
|
-
const accessHash = reader.readInt64();
|
|
113
|
-
if (PHOTO_TYPES.includes(fileType)) {
|
|
73
|
+
case PhotoSourceType.FullLegacy: {
|
|
114
74
|
const volumeId = reader.readInt64();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
switch (thumbnailSource) {
|
|
120
|
-
case ThumbnailSource.Legacy: {
|
|
121
|
-
const secret = reader.readInt64();
|
|
122
|
-
const localId = reader.readInt32();
|
|
123
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, secret, localId });
|
|
124
|
-
}
|
|
125
|
-
case ThumbnailSource.Thumbnail: {
|
|
126
|
-
const thumbnailFileType = reader.readInt32();
|
|
127
|
-
const thumbnailSize = String.fromCharCode(reader.readInt32());
|
|
128
|
-
const localId = reader.readInt32();
|
|
129
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, thumbnailFileType, thumbnailSize, localId });
|
|
130
|
-
}
|
|
131
|
-
case ThumbnailSource.ChatPhotoSmall:
|
|
132
|
-
case ThumbnailSource.ChatPhotoBig: {
|
|
133
|
-
const chatId = Number(reader.readInt64());
|
|
134
|
-
const chatAccessHash = reader.readInt64();
|
|
135
|
-
const localId = reader.readInt32();
|
|
136
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, chatId: Number(chatId), chatAccessHash, localId });
|
|
137
|
-
}
|
|
138
|
-
case ThumbnailSource.StickerSetThumbnail: {
|
|
139
|
-
const stickerSetId = reader.readInt64();
|
|
140
|
-
const stickerSetAccessHash = reader.readInt64();
|
|
141
|
-
const localId = reader.readInt32();
|
|
142
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, stickerSetId, stickerSetAccessHash, localId });
|
|
143
|
-
}
|
|
144
|
-
default:
|
|
145
|
-
UNREACHABLE();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else if (DOCUMENT_TYPES.includes(fileType)) {
|
|
149
|
-
return new FileID(minor, major, fileType, dcId, { fileReference, mediaId, accessHash });
|
|
75
|
+
const localId = reader.readInt32();
|
|
76
|
+
const secret = reader.readInt64();
|
|
77
|
+
return { type, volumeId, localId, secret };
|
|
150
78
|
}
|
|
151
|
-
|
|
152
|
-
|
|
79
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
80
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
81
|
+
case PhotoSourceType.StickerSetThumbnailLegacy: {
|
|
82
|
+
const volumeId = reader.readInt64();
|
|
83
|
+
const localId = reader.readInt32();
|
|
84
|
+
return { type, volumeId, localId };
|
|
153
85
|
}
|
|
86
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
87
|
+
return { type, version: reader.readInt32() };
|
|
154
88
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
writer.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
writer.
|
|
173
|
-
|
|
174
|
-
|
|
89
|
+
}
|
|
90
|
+
function serializePhotoSource(photoSource, writer) {
|
|
91
|
+
writer.writeInt32(photoSource.type);
|
|
92
|
+
switch (photoSource.type) {
|
|
93
|
+
case PhotoSourceType.Legacy:
|
|
94
|
+
writer.writeInt64(photoSource.secret);
|
|
95
|
+
break;
|
|
96
|
+
case PhotoSourceType.Thumbnail:
|
|
97
|
+
writer.writeInt32(photoSource.fileType);
|
|
98
|
+
writer.writeInt32(photoSource.thumbnailType);
|
|
99
|
+
break;
|
|
100
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
101
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
102
|
+
writer.writeInt64(photoSource.chatId);
|
|
103
|
+
writer.writeInt64(photoSource.chatAccessHash);
|
|
104
|
+
break;
|
|
105
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
106
|
+
writer.writeInt64(photoSource.stickerSetId);
|
|
107
|
+
writer.writeInt64(photoSource.stickerSetAccessHash);
|
|
108
|
+
break;
|
|
109
|
+
case PhotoSourceType.FullLegacy:
|
|
110
|
+
writer.writeInt64(photoSource.volumeId);
|
|
111
|
+
writer.writeInt32(photoSource.localId);
|
|
112
|
+
writer.writeInt64(photoSource.secret);
|
|
113
|
+
break;
|
|
114
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
115
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
116
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
117
|
+
writer.writeInt64(photoSource.volumeId);
|
|
118
|
+
writer.writeInt32(photoSource.localId);
|
|
119
|
+
break;
|
|
120
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
121
|
+
writer.writeInt32(photoSource.version);
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
175
124
|
UNREACHABLE();
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getPhotoSourceCompareType(source) {
|
|
128
|
+
switch (source.type) {
|
|
129
|
+
case PhotoSourceType.Legacy:
|
|
130
|
+
break;
|
|
131
|
+
case PhotoSourceType.Thumbnail: {
|
|
132
|
+
const type = source.thumbnailType;
|
|
133
|
+
if (!(0 <= type && type <= 127)) {
|
|
181
134
|
UNREACHABLE();
|
|
182
135
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
writer.writeInt32(Number(this.params.thumbnailSource));
|
|
136
|
+
if (type == "a".charCodeAt(0)) {
|
|
137
|
+
return 0;
|
|
186
138
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (this.params.secret == undefined) {
|
|
190
|
-
UNREACHABLE();
|
|
191
|
-
}
|
|
192
|
-
writer.writeInt64(this.params.secret);
|
|
193
|
-
writer.writeInt32(this.params.localId);
|
|
194
|
-
break;
|
|
195
|
-
case ThumbnailSource.Thumbnail:
|
|
196
|
-
if (this.params.thumbnailFileType == undefined || this.params.thumbnailSize == undefined) {
|
|
197
|
-
UNREACHABLE();
|
|
198
|
-
}
|
|
199
|
-
writer.writeInt32(Number(this.params.thumbnailFileType));
|
|
200
|
-
writer.writeInt32(this.params.thumbnailSize.charCodeAt(0));
|
|
201
|
-
writer.writeInt32(this.params.localId);
|
|
202
|
-
break;
|
|
203
|
-
case ThumbnailSource.ChatPhotoSmall:
|
|
204
|
-
case ThumbnailSource.ChatPhotoBig:
|
|
205
|
-
if (this.params.chatId == undefined || this.params.chatAccessHash == undefined) {
|
|
206
|
-
UNREACHABLE();
|
|
207
|
-
}
|
|
208
|
-
writer.writeInt64(BigInt(this.params.chatId));
|
|
209
|
-
writer.writeInt64(this.params.chatAccessHash);
|
|
210
|
-
writer.writeInt32(this.params.localId);
|
|
211
|
-
break;
|
|
212
|
-
case ThumbnailSource.StickerSetThumbnail:
|
|
213
|
-
if (this.params.stickerSetId == undefined || this.params.stickerSetAccessHash == undefined) {
|
|
214
|
-
UNREACHABLE();
|
|
215
|
-
}
|
|
216
|
-
writer.writeInt64(this.params.stickerSetId);
|
|
217
|
-
writer.writeInt64(this.params.stickerSetAccessHash);
|
|
218
|
-
writer.writeInt32(this.params.localId);
|
|
219
|
-
break;
|
|
220
|
-
default:
|
|
221
|
-
UNREACHABLE();
|
|
139
|
+
if (type == "c".charCodeAt(0)) {
|
|
140
|
+
return 1;
|
|
222
141
|
}
|
|
142
|
+
return type + 5;
|
|
223
143
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
144
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
145
|
+
return 0;
|
|
146
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
147
|
+
return 1;
|
|
148
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
149
|
+
break;
|
|
150
|
+
case PhotoSourceType.FullLegacy:
|
|
151
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
152
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
153
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
154
|
+
return 3;
|
|
155
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
156
|
+
return 2;
|
|
157
|
+
default:
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
UNREACHABLE();
|
|
161
|
+
}
|
|
162
|
+
function writePhotoSourceUniqueId(photoSource, writer) {
|
|
163
|
+
const compareType = getPhotoSourceCompareType(photoSource);
|
|
164
|
+
if (compareType != 2 && compareType != 3) {
|
|
165
|
+
writer.write(new Uint8Array([compareType]));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (compareType == 2) {
|
|
169
|
+
writer.write(new Uint8Array([0x02]));
|
|
170
|
+
}
|
|
171
|
+
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : UNREACHABLE());
|
|
172
|
+
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : UNREACHABLE());
|
|
173
|
+
}
|
|
174
|
+
function getFileTypeClass(fileType) {
|
|
175
|
+
switch (fileType) {
|
|
176
|
+
case FileType.Photo:
|
|
177
|
+
case FileType.ProfilePhoto:
|
|
178
|
+
case FileType.Thumbnail:
|
|
179
|
+
case FileType.EncryptedThumbnail:
|
|
180
|
+
case FileType.Wallpaper:
|
|
181
|
+
case FileType.PhotoStory:
|
|
182
|
+
return FileTypeClass.Photo;
|
|
183
|
+
case FileType.Video:
|
|
184
|
+
case FileType.VoiceNote:
|
|
185
|
+
case FileType.Document:
|
|
186
|
+
case FileType.Sticker:
|
|
187
|
+
case FileType.Audio:
|
|
188
|
+
case FileType.Animation:
|
|
189
|
+
case FileType.VideoNote:
|
|
190
|
+
case FileType.Background:
|
|
191
|
+
case FileType.DocumentAsFile:
|
|
192
|
+
case FileType.Ringtone:
|
|
193
|
+
case FileType.CallLog:
|
|
194
|
+
case FileType.VideoStory:
|
|
195
|
+
return FileTypeClass.Document;
|
|
196
|
+
case FileType.SecureDecrypted:
|
|
197
|
+
case FileType.SecureEncrypted:
|
|
198
|
+
return FileTypeClass.Secure;
|
|
199
|
+
case FileType.Encrypted:
|
|
200
|
+
return FileTypeClass.Encrypted;
|
|
201
|
+
case FileType.Temp:
|
|
202
|
+
return FileTypeClass.Temp;
|
|
203
|
+
case FileType.None:
|
|
204
|
+
case FileType.Size:
|
|
205
|
+
default:
|
|
229
206
|
UNREACHABLE();
|
|
230
|
-
}
|
|
231
|
-
writer.write(new Uint8Array([minor, major]));
|
|
232
|
-
return base64EncodeUrlSafe(rleEncode(writer.buffer));
|
|
233
207
|
}
|
|
234
208
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
value: 30
|
|
246
|
-
});
|
|
247
|
-
export var FileUniqueType;
|
|
248
|
-
(function (FileUniqueType) {
|
|
249
|
-
FileUniqueType[FileUniqueType["Web"] = 0] = "Web";
|
|
250
|
-
FileUniqueType[FileUniqueType["Photo"] = 1] = "Photo";
|
|
251
|
-
FileUniqueType[FileUniqueType["Document"] = 2] = "Document";
|
|
252
|
-
FileUniqueType[FileUniqueType["Secure"] = 3] = "Secure";
|
|
253
|
-
FileUniqueType[FileUniqueType["Encrypted"] = 4] = "Encrypted";
|
|
254
|
-
FileUniqueType[FileUniqueType["Temp"] = 5] = "Temp";
|
|
255
|
-
})(FileUniqueType || (FileUniqueType = {}));
|
|
256
|
-
export class FileUniqueID {
|
|
257
|
-
constructor(fileUniqueType, params) {
|
|
258
|
-
Object.defineProperty(this, "fileUniqueType", {
|
|
259
|
-
enumerable: true,
|
|
260
|
-
configurable: true,
|
|
261
|
-
writable: true,
|
|
262
|
-
value: fileUniqueType
|
|
263
|
-
});
|
|
264
|
-
Object.defineProperty(this, "params", {
|
|
265
|
-
enumerable: true,
|
|
266
|
-
configurable: true,
|
|
267
|
-
writable: true,
|
|
268
|
-
value: params
|
|
269
|
-
});
|
|
209
|
+
function isWeb(fileType) {
|
|
210
|
+
return !!(fileType & WEB_LOCATION_FLAG);
|
|
211
|
+
}
|
|
212
|
+
function hasFileReference(fileType) {
|
|
213
|
+
return !!(fileType && FILE_REFERENCE_FLAG);
|
|
214
|
+
}
|
|
215
|
+
export function deserializeFileId(fileId) {
|
|
216
|
+
const reader = new TLReader(rleDecode(base64DecodeUrlSafe(fileId)));
|
|
217
|
+
if (reader.buffer[reader.buffer.length - 1] != PERSISTENT_ID_VERSION) {
|
|
218
|
+
throw new Error("Unsupported version");
|
|
270
219
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
220
|
+
const originalType = reader.readInt32();
|
|
221
|
+
const type = ((originalType & ~WEB_LOCATION_FLAG) & ~FILE_REFERENCE_FLAG);
|
|
222
|
+
const dcId = reader.readInt32();
|
|
223
|
+
if (isWeb(originalType)) {
|
|
224
|
+
const url = reader.readString();
|
|
225
|
+
const accessHash = reader.readInt64();
|
|
226
|
+
return { type, dcId, location: { type: "web", url, accessHash } };
|
|
227
|
+
}
|
|
228
|
+
const fileReference = hasFileReference(originalType) ? reader.readBytes() : undefined;
|
|
229
|
+
const id = reader.readInt64();
|
|
230
|
+
const accessHash = reader.readInt64();
|
|
231
|
+
if (getFileTypeClass(type) == FileTypeClass.Photo) {
|
|
232
|
+
const source = deserializePhotoSource(reader);
|
|
233
|
+
return { type, dcId, fileReference, location: { type: "photo", id, accessHash, source } };
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
return { type, dcId, fileReference, location: { type: "common", id, accessHash } };
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
export function serializeFileId(fileId) {
|
|
240
|
+
const writer = new TLWriter();
|
|
241
|
+
let type = fileId.type;
|
|
242
|
+
if (fileId.fileReference) {
|
|
243
|
+
type |= FILE_REFERENCE_FLAG;
|
|
244
|
+
}
|
|
245
|
+
if (fileId.location.type == "web") {
|
|
246
|
+
type |= WEB_LOCATION_FLAG;
|
|
247
|
+
}
|
|
248
|
+
writer.writeInt32(type);
|
|
249
|
+
writer.writeInt32(fileId.dcId);
|
|
250
|
+
if (fileId.location.type == "web") {
|
|
251
|
+
writer.writeString(fileId.location.url);
|
|
252
|
+
writer.writeInt64(fileId.location.accessHash);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
if (fileId.fileReference) {
|
|
256
|
+
writer.writeBytes(fileId.fileReference);
|
|
290
257
|
}
|
|
258
|
+
writer.writeInt64(fileId.location.id);
|
|
259
|
+
writer.writeInt64(fileId.location.accessHash);
|
|
260
|
+
if (fileId.location.type == "photo") {
|
|
261
|
+
serializePhotoSource(fileId.location.source, writer);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
writer.write(new Uint8Array([NEXT_VERSION - 1, PERSISTENT_ID_VERSION]));
|
|
265
|
+
return base64EncodeUrlSafe(rleEncode(writer.buffer));
|
|
266
|
+
}
|
|
267
|
+
export function toUniqueFileId(fileId) {
|
|
268
|
+
const writer = new TLWriter();
|
|
269
|
+
const type = fileId.location.type == "web" ? 0 : (getFileTypeClass(fileId.type) + 1);
|
|
270
|
+
writer.writeInt32(type);
|
|
271
|
+
if (fileId.location.type == "web") {
|
|
272
|
+
writer.writeString(fileId.location.url);
|
|
291
273
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
274
|
+
else if (fileId.location.type == "common") {
|
|
275
|
+
writer.writeInt64(fileId.location.id);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
switch (fileId.location.source.type) {
|
|
279
|
+
case PhotoSourceType.Legacy:
|
|
280
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
281
|
+
UNREACHABLE();
|
|
282
|
+
/* falls through */
|
|
283
|
+
case PhotoSourceType.FullLegacy:
|
|
284
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
285
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
286
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
287
|
+
writer.writeInt64(fileId.location.id);
|
|
288
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
301
289
|
break;
|
|
302
|
-
case
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
writer.writeInt32(this.params.localId);
|
|
290
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
291
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
292
|
+
case PhotoSourceType.Thumbnail:
|
|
293
|
+
writer.writeInt64(fileId.location.id);
|
|
294
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
308
295
|
break;
|
|
309
|
-
case
|
|
310
|
-
|
|
311
|
-
UNREACHABLE();
|
|
312
|
-
}
|
|
313
|
-
writer.writeInt64(this.params.mediaId);
|
|
296
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
297
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
314
298
|
break;
|
|
315
|
-
default:
|
|
316
|
-
UNREACHABLE();
|
|
317
299
|
}
|
|
318
|
-
return base64EncodeUrlSafe(rleEncode(writer.buffer));
|
|
319
300
|
}
|
|
301
|
+
return base64EncodeUrlSafe(rleEncode(writer.buffer));
|
|
320
302
|
}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
|
-
import {
|
|
2
|
+
import { FileType, PhotoSourceType, serializeFileId, toUniqueFileId } from "./0__file_id.js";
|
|
3
3
|
export function constructChatPhoto(photo, chatId, chatAccessHash) {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
chatId,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
chatAccessHash,
|
|
19
|
-
accessHash: 0n,
|
|
20
|
-
volumeId: 0n,
|
|
21
|
-
localId: 0,
|
|
22
|
-
}).encode();
|
|
23
|
-
const bigFileUniqueId = new FileUniqueID(FileUniqueType.Document, { mediaId: photo.photo_id }).encode();
|
|
4
|
+
const smallFileId_ = {
|
|
5
|
+
type: FileType.ProfilePhoto,
|
|
6
|
+
dcId: photo.dc_id,
|
|
7
|
+
location: { type: "photo", id: photo.photo_id, accessHash: 0n, source: { type: PhotoSourceType.ChatPhotoSmall, chatId: BigInt(chatId), chatAccessHash } },
|
|
8
|
+
};
|
|
9
|
+
const smallFileId = serializeFileId(smallFileId_);
|
|
10
|
+
const smallFileUniqueId = toUniqueFileId(smallFileId_);
|
|
11
|
+
const bigFileId_ = {
|
|
12
|
+
type: FileType.ProfilePhoto,
|
|
13
|
+
dcId: photo.dc_id,
|
|
14
|
+
location: { type: "photo", id: photo.photo_id, accessHash: 0n, source: { type: PhotoSourceType.ChatPhotoBig, chatId: BigInt(chatId), chatAccessHash } },
|
|
15
|
+
};
|
|
16
|
+
const bigFileId = serializeFileId(bigFileId_);
|
|
17
|
+
const bigFileUniqueId = toUniqueFileId(bigFileId_);
|
|
24
18
|
if (photo instanceof types.ChatPhoto) {
|
|
25
19
|
return {
|
|
26
20
|
smallFileId,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
2
|
/** Giveaway parameters. */
|
|
3
3
|
export interface GiveawayParameters {
|
|
4
|
+
/** The identifier of the chat that will be boosted for the duration of the given away Premium subscriptions. */
|
|
4
5
|
boostedChatId: number;
|
|
6
|
+
/** The identifiers of additional chats that the user must subscribe to in order to be eligible for the prizes. */
|
|
5
7
|
additionalChatIds: number[];
|
|
8
|
+
/** The point of time in which the winners will be chosen. */
|
|
6
9
|
winnerSelectionDate: Date;
|
|
10
|
+
/** Whether only new members of the chats will be eligible for the prizes. */
|
|
7
11
|
onlyNewMembers: boolean;
|
|
12
|
+
/** A list of countries that are eligible for the prizes. */
|
|
8
13
|
countries: string[];
|
|
9
14
|
}
|
|
10
15
|
export declare function constructGiveawayParameters(g: types.MessageMediaGiveaway): GiveawayParameters;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/** A login URL. */
|
|
2
2
|
export interface LoginUrl {
|
|
3
|
+
/** The login URL. */
|
|
3
4
|
url: string;
|
|
5
|
+
/** A different text for the login button that will be shown when the message is forwarded. */
|
|
4
6
|
forwardText?: string;
|
|
7
|
+
/** The username of the bot that performs the authorization. */
|
|
5
8
|
botUsername?: string;
|
|
9
|
+
/** Whether logging in will allow the bot to privately message the user. */
|
|
6
10
|
requestWriteAccess?: boolean;
|
|
7
11
|
}
|