@mtkruto/node 0.1.156 → 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 +5341 -1
- package/esm/tl/2_types.js +6569 -319
- package/esm/tl/3_functions.d.ts +2387 -2
- package/esm/tl/3_functions.js +2956 -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 +5341 -1
- package/script/tl/2_types.js +6649 -345
- package/script/tl/3_functions.d.ts +2387 -2
- package/script/tl/3_functions.js +2990 -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
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toUniqueFileId = exports.serializeFileId = exports.deserializeFileId = exports.PhotoSourceType = exports.FileType = void 0;
|
|
4
4
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
5
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
|
+
const NEXT_VERSION = 53;
|
|
7
|
+
const PERSISTENT_ID_VERSION = 4;
|
|
8
|
+
const WEB_LOCATION_FLAG = 1 << 24;
|
|
9
|
+
const FILE_REFERENCE_FLAG = 1 << 25;
|
|
6
10
|
var FileType;
|
|
7
11
|
(function (FileType) {
|
|
8
12
|
FileType[FileType["Thumbnail"] = 0] = "Thumbnail";
|
|
9
|
-
FileType[FileType["
|
|
13
|
+
FileType[FileType["ProfilePhoto"] = 1] = "ProfilePhoto";
|
|
10
14
|
FileType[FileType["Photo"] = 2] = "Photo";
|
|
11
|
-
FileType[FileType["
|
|
15
|
+
FileType[FileType["VoiceNote"] = 3] = "VoiceNote";
|
|
12
16
|
FileType[FileType["Video"] = 4] = "Video";
|
|
13
17
|
FileType[FileType["Document"] = 5] = "Document";
|
|
14
18
|
FileType[FileType["Encrypted"] = 6] = "Encrypted";
|
|
@@ -19,307 +23,286 @@ var FileType;
|
|
|
19
23
|
FileType[FileType["EncryptedThumbnail"] = 11] = "EncryptedThumbnail";
|
|
20
24
|
FileType[FileType["Wallpaper"] = 12] = "Wallpaper";
|
|
21
25
|
FileType[FileType["VideoNote"] = 13] = "VideoNote";
|
|
22
|
-
FileType[FileType["
|
|
23
|
-
FileType[FileType["
|
|
26
|
+
FileType[FileType["SecureDecrypted"] = 14] = "SecureDecrypted";
|
|
27
|
+
FileType[FileType["SecureEncrypted"] = 15] = "SecureEncrypted";
|
|
24
28
|
FileType[FileType["Background"] = 16] = "Background";
|
|
25
29
|
FileType[FileType["DocumentAsFile"] = 17] = "DocumentAsFile";
|
|
30
|
+
FileType[FileType["Ringtone"] = 18] = "Ringtone";
|
|
31
|
+
FileType[FileType["CallLog"] = 19] = "CallLog";
|
|
32
|
+
FileType[FileType["PhotoStory"] = 20] = "PhotoStory";
|
|
33
|
+
FileType[FileType["VideoStory"] = 21] = "VideoStory";
|
|
34
|
+
FileType[FileType["Size"] = 22] = "Size";
|
|
35
|
+
FileType[FileType["None"] = 23] = "None";
|
|
26
36
|
})(FileType || (exports.FileType = FileType = {}));
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "minor", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
if (major == null) {
|
|
72
|
-
this.major = FileID.MAJOR;
|
|
37
|
+
var FileTypeClass;
|
|
38
|
+
(function (FileTypeClass) {
|
|
39
|
+
FileTypeClass[FileTypeClass["Photo"] = 0] = "Photo";
|
|
40
|
+
FileTypeClass[FileTypeClass["Document"] = 1] = "Document";
|
|
41
|
+
FileTypeClass[FileTypeClass["Secure"] = 2] = "Secure";
|
|
42
|
+
FileTypeClass[FileTypeClass["Encrypted"] = 3] = "Encrypted";
|
|
43
|
+
FileTypeClass[FileTypeClass["Temp"] = 4] = "Temp";
|
|
44
|
+
})(FileTypeClass || (FileTypeClass = {}));
|
|
45
|
+
var PhotoSourceType;
|
|
46
|
+
(function (PhotoSourceType) {
|
|
47
|
+
PhotoSourceType[PhotoSourceType["Legacy"] = 0] = "Legacy";
|
|
48
|
+
PhotoSourceType[PhotoSourceType["Thumbnail"] = 1] = "Thumbnail";
|
|
49
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoSmall"] = 2] = "ChatPhotoSmall";
|
|
50
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoBig"] = 3] = "ChatPhotoBig";
|
|
51
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnail"] = 4] = "StickerSetThumbnail";
|
|
52
|
+
PhotoSourceType[PhotoSourceType["FullLegacy"] = 5] = "FullLegacy";
|
|
53
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoSmallLegacy"] = 6] = "ChatPhotoSmallLegacy";
|
|
54
|
+
PhotoSourceType[PhotoSourceType["ChatPhotoBigLegacy"] = 7] = "ChatPhotoBigLegacy";
|
|
55
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnailLegacy"] = 8] = "StickerSetThumbnailLegacy";
|
|
56
|
+
PhotoSourceType[PhotoSourceType["StickerSetThumbnailVersion"] = 9] = "StickerSetThumbnailVersion";
|
|
57
|
+
})(PhotoSourceType || (exports.PhotoSourceType = PhotoSourceType = {}));
|
|
58
|
+
function deserializePhotoSource(reader) {
|
|
59
|
+
const type = reader.readInt32();
|
|
60
|
+
switch (type) {
|
|
61
|
+
case PhotoSourceType.Legacy:
|
|
62
|
+
return { type, secret: reader.readInt64() };
|
|
63
|
+
case PhotoSourceType.Thumbnail:
|
|
64
|
+
return { type, fileType: reader.readInt32(), thumbnailType: reader.readInt32() };
|
|
65
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
66
|
+
case PhotoSourceType.ChatPhotoBig: {
|
|
67
|
+
const chatId = reader.readInt64();
|
|
68
|
+
const chatAccessHash = reader.readInt64();
|
|
69
|
+
return { type, chatId, chatAccessHash };
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
case PhotoSourceType.StickerSetThumbnail: {
|
|
72
|
+
const stickerSetId = reader.readInt64();
|
|
73
|
+
const stickerSetAccessHash = reader.readInt64();
|
|
74
|
+
return { type, stickerSetId, stickerSetAccessHash };
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
this.minor = FileID.MINOR;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this.minor = minor;
|
|
82
|
-
}
|
|
83
|
-
this.params.thumbnailSize ??= "";
|
|
84
|
-
}
|
|
85
|
-
static decode(fileId) {
|
|
86
|
-
const decoded = (0, _1_utilities_js_1.rleDecode)((0, _1_utilities_js_1.base64DecodeUrlSafe)(fileId));
|
|
87
|
-
const major = decoded[decoded.length - 1];
|
|
88
|
-
let minor;
|
|
89
|
-
let buffer;
|
|
90
|
-
if (major < 4) {
|
|
91
|
-
minor = 0;
|
|
92
|
-
buffer = decoded.subarray(0, -1);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
minor = decoded[decoded.length - 2];
|
|
96
|
-
buffer = decoded.subarray(0, -2);
|
|
97
|
-
}
|
|
98
|
-
const reader = new _2_tl_js_1.TLReader(buffer);
|
|
99
|
-
let fileType = reader.readInt32();
|
|
100
|
-
const dcId = reader.readInt32();
|
|
101
|
-
const hasWebLocation = Boolean(fileType & WEB_LOCATION_FLAG);
|
|
102
|
-
const hasFileReference = Boolean(fileType & FILE_REFERENCE_FLAG);
|
|
103
|
-
fileType &= ~WEB_LOCATION_FLAG;
|
|
104
|
-
fileType &= ~FILE_REFERENCE_FLAG;
|
|
105
|
-
if (hasWebLocation) {
|
|
106
|
-
const url = reader.readString();
|
|
107
|
-
const accessHash = reader.readInt64();
|
|
108
|
-
return new FileID(major, minor, fileType, dcId, { url, accessHash });
|
|
109
|
-
}
|
|
110
|
-
let fileReference = new Uint8Array();
|
|
111
|
-
if (hasFileReference) {
|
|
112
|
-
fileReference = reader.readBytes();
|
|
113
|
-
}
|
|
114
|
-
const mediaId = reader.readInt64();
|
|
115
|
-
const accessHash = reader.readInt64();
|
|
116
|
-
if (PHOTO_TYPES.includes(fileType)) {
|
|
76
|
+
case PhotoSourceType.FullLegacy: {
|
|
117
77
|
const volumeId = reader.readInt64();
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
switch (thumbnailSource) {
|
|
123
|
-
case ThumbnailSource.Legacy: {
|
|
124
|
-
const secret = reader.readInt64();
|
|
125
|
-
const localId = reader.readInt32();
|
|
126
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, secret, localId });
|
|
127
|
-
}
|
|
128
|
-
case ThumbnailSource.Thumbnail: {
|
|
129
|
-
const thumbnailFileType = reader.readInt32();
|
|
130
|
-
const thumbnailSize = String.fromCharCode(reader.readInt32());
|
|
131
|
-
const localId = reader.readInt32();
|
|
132
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, thumbnailFileType, thumbnailSize, localId });
|
|
133
|
-
}
|
|
134
|
-
case ThumbnailSource.ChatPhotoSmall:
|
|
135
|
-
case ThumbnailSource.ChatPhotoBig: {
|
|
136
|
-
const chatId = Number(reader.readInt64());
|
|
137
|
-
const chatAccessHash = reader.readInt64();
|
|
138
|
-
const localId = reader.readInt32();
|
|
139
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, chatId: Number(chatId), chatAccessHash, localId });
|
|
140
|
-
}
|
|
141
|
-
case ThumbnailSource.StickerSetThumbnail: {
|
|
142
|
-
const stickerSetId = reader.readInt64();
|
|
143
|
-
const stickerSetAccessHash = reader.readInt64();
|
|
144
|
-
const localId = reader.readInt32();
|
|
145
|
-
return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, stickerSetId, stickerSetAccessHash, localId });
|
|
146
|
-
}
|
|
147
|
-
default:
|
|
148
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
else if (DOCUMENT_TYPES.includes(fileType)) {
|
|
152
|
-
return new FileID(minor, major, fileType, dcId, { fileReference, mediaId, accessHash });
|
|
78
|
+
const localId = reader.readInt32();
|
|
79
|
+
const secret = reader.readInt64();
|
|
80
|
+
return { type, volumeId, localId, secret };
|
|
153
81
|
}
|
|
154
|
-
|
|
155
|
-
|
|
82
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
83
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
84
|
+
case PhotoSourceType.StickerSetThumbnailLegacy: {
|
|
85
|
+
const volumeId = reader.readInt64();
|
|
86
|
+
const localId = reader.readInt32();
|
|
87
|
+
return { type, volumeId, localId };
|
|
156
88
|
}
|
|
89
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
90
|
+
return { type, version: reader.readInt32() };
|
|
157
91
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
writer.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
writer.
|
|
176
|
-
|
|
177
|
-
|
|
92
|
+
}
|
|
93
|
+
function serializePhotoSource(photoSource, writer) {
|
|
94
|
+
writer.writeInt32(photoSource.type);
|
|
95
|
+
switch (photoSource.type) {
|
|
96
|
+
case PhotoSourceType.Legacy:
|
|
97
|
+
writer.writeInt64(photoSource.secret);
|
|
98
|
+
break;
|
|
99
|
+
case PhotoSourceType.Thumbnail:
|
|
100
|
+
writer.writeInt32(photoSource.fileType);
|
|
101
|
+
writer.writeInt32(photoSource.thumbnailType);
|
|
102
|
+
break;
|
|
103
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
104
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
105
|
+
writer.writeInt64(photoSource.chatId);
|
|
106
|
+
writer.writeInt64(photoSource.chatAccessHash);
|
|
107
|
+
break;
|
|
108
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
109
|
+
writer.writeInt64(photoSource.stickerSetId);
|
|
110
|
+
writer.writeInt64(photoSource.stickerSetAccessHash);
|
|
111
|
+
break;
|
|
112
|
+
case PhotoSourceType.FullLegacy:
|
|
113
|
+
writer.writeInt64(photoSource.volumeId);
|
|
114
|
+
writer.writeInt32(photoSource.localId);
|
|
115
|
+
writer.writeInt64(photoSource.secret);
|
|
116
|
+
break;
|
|
117
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
118
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
119
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
120
|
+
writer.writeInt64(photoSource.volumeId);
|
|
121
|
+
writer.writeInt32(photoSource.localId);
|
|
122
|
+
break;
|
|
123
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
124
|
+
writer.writeInt32(photoSource.version);
|
|
125
|
+
break;
|
|
126
|
+
default:
|
|
178
127
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function getPhotoSourceCompareType(source) {
|
|
131
|
+
switch (source.type) {
|
|
132
|
+
case PhotoSourceType.Legacy:
|
|
133
|
+
break;
|
|
134
|
+
case PhotoSourceType.Thumbnail: {
|
|
135
|
+
const type = source.thumbnailType;
|
|
136
|
+
if (!(0 <= type && type <= 127)) {
|
|
184
137
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
185
138
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
writer.writeInt32(Number(this.params.thumbnailSource));
|
|
139
|
+
if (type == "a".charCodeAt(0)) {
|
|
140
|
+
return 0;
|
|
189
141
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (this.params.secret == undefined) {
|
|
193
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
194
|
-
}
|
|
195
|
-
writer.writeInt64(this.params.secret);
|
|
196
|
-
writer.writeInt32(this.params.localId);
|
|
197
|
-
break;
|
|
198
|
-
case ThumbnailSource.Thumbnail:
|
|
199
|
-
if (this.params.thumbnailFileType == undefined || this.params.thumbnailSize == undefined) {
|
|
200
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
201
|
-
}
|
|
202
|
-
writer.writeInt32(Number(this.params.thumbnailFileType));
|
|
203
|
-
writer.writeInt32(this.params.thumbnailSize.charCodeAt(0));
|
|
204
|
-
writer.writeInt32(this.params.localId);
|
|
205
|
-
break;
|
|
206
|
-
case ThumbnailSource.ChatPhotoSmall:
|
|
207
|
-
case ThumbnailSource.ChatPhotoBig:
|
|
208
|
-
if (this.params.chatId == undefined || this.params.chatAccessHash == undefined) {
|
|
209
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
210
|
-
}
|
|
211
|
-
writer.writeInt64(BigInt(this.params.chatId));
|
|
212
|
-
writer.writeInt64(this.params.chatAccessHash);
|
|
213
|
-
writer.writeInt32(this.params.localId);
|
|
214
|
-
break;
|
|
215
|
-
case ThumbnailSource.StickerSetThumbnail:
|
|
216
|
-
if (this.params.stickerSetId == undefined || this.params.stickerSetAccessHash == undefined) {
|
|
217
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
218
|
-
}
|
|
219
|
-
writer.writeInt64(this.params.stickerSetId);
|
|
220
|
-
writer.writeInt64(this.params.stickerSetAccessHash);
|
|
221
|
-
writer.writeInt32(this.params.localId);
|
|
222
|
-
break;
|
|
223
|
-
default:
|
|
224
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
142
|
+
if (type == "c".charCodeAt(0)) {
|
|
143
|
+
return 1;
|
|
225
144
|
}
|
|
145
|
+
return type + 5;
|
|
226
146
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
147
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
148
|
+
return 0;
|
|
149
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
150
|
+
return 1;
|
|
151
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
152
|
+
break;
|
|
153
|
+
case PhotoSourceType.FullLegacy:
|
|
154
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
155
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
156
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
157
|
+
return 3;
|
|
158
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
159
|
+
return 2;
|
|
160
|
+
default:
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
164
|
+
}
|
|
165
|
+
function writePhotoSourceUniqueId(photoSource, writer) {
|
|
166
|
+
const compareType = getPhotoSourceCompareType(photoSource);
|
|
167
|
+
if (compareType != 2 && compareType != 3) {
|
|
168
|
+
writer.write(new Uint8Array([compareType]));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (compareType == 2) {
|
|
172
|
+
writer.write(new Uint8Array([0x02]));
|
|
173
|
+
}
|
|
174
|
+
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : (0, _1_utilities_js_1.UNREACHABLE)());
|
|
175
|
+
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : (0, _1_utilities_js_1.UNREACHABLE)());
|
|
176
|
+
}
|
|
177
|
+
function getFileTypeClass(fileType) {
|
|
178
|
+
switch (fileType) {
|
|
179
|
+
case FileType.Photo:
|
|
180
|
+
case FileType.ProfilePhoto:
|
|
181
|
+
case FileType.Thumbnail:
|
|
182
|
+
case FileType.EncryptedThumbnail:
|
|
183
|
+
case FileType.Wallpaper:
|
|
184
|
+
case FileType.PhotoStory:
|
|
185
|
+
return FileTypeClass.Photo;
|
|
186
|
+
case FileType.Video:
|
|
187
|
+
case FileType.VoiceNote:
|
|
188
|
+
case FileType.Document:
|
|
189
|
+
case FileType.Sticker:
|
|
190
|
+
case FileType.Audio:
|
|
191
|
+
case FileType.Animation:
|
|
192
|
+
case FileType.VideoNote:
|
|
193
|
+
case FileType.Background:
|
|
194
|
+
case FileType.DocumentAsFile:
|
|
195
|
+
case FileType.Ringtone:
|
|
196
|
+
case FileType.CallLog:
|
|
197
|
+
case FileType.VideoStory:
|
|
198
|
+
return FileTypeClass.Document;
|
|
199
|
+
case FileType.SecureDecrypted:
|
|
200
|
+
case FileType.SecureEncrypted:
|
|
201
|
+
return FileTypeClass.Secure;
|
|
202
|
+
case FileType.Encrypted:
|
|
203
|
+
return FileTypeClass.Encrypted;
|
|
204
|
+
case FileType.Temp:
|
|
205
|
+
return FileTypeClass.Temp;
|
|
206
|
+
case FileType.None:
|
|
207
|
+
case FileType.Size:
|
|
208
|
+
default:
|
|
232
209
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
233
|
-
}
|
|
234
|
-
writer.write(new Uint8Array([minor, major]));
|
|
235
|
-
return (0, _1_utilities_js_1.base64EncodeUrlSafe)((0, _1_utilities_js_1.rleEncode)(writer.buffer));
|
|
236
210
|
}
|
|
237
211
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
writable: true,
|
|
249
|
-
value: 30
|
|
250
|
-
});
|
|
251
|
-
var FileUniqueType;
|
|
252
|
-
(function (FileUniqueType) {
|
|
253
|
-
FileUniqueType[FileUniqueType["Web"] = 0] = "Web";
|
|
254
|
-
FileUniqueType[FileUniqueType["Photo"] = 1] = "Photo";
|
|
255
|
-
FileUniqueType[FileUniqueType["Document"] = 2] = "Document";
|
|
256
|
-
FileUniqueType[FileUniqueType["Secure"] = 3] = "Secure";
|
|
257
|
-
FileUniqueType[FileUniqueType["Encrypted"] = 4] = "Encrypted";
|
|
258
|
-
FileUniqueType[FileUniqueType["Temp"] = 5] = "Temp";
|
|
259
|
-
})(FileUniqueType || (exports.FileUniqueType = FileUniqueType = {}));
|
|
260
|
-
class FileUniqueID {
|
|
261
|
-
constructor(fileUniqueType, params) {
|
|
262
|
-
Object.defineProperty(this, "fileUniqueType", {
|
|
263
|
-
enumerable: true,
|
|
264
|
-
configurable: true,
|
|
265
|
-
writable: true,
|
|
266
|
-
value: fileUniqueType
|
|
267
|
-
});
|
|
268
|
-
Object.defineProperty(this, "params", {
|
|
269
|
-
enumerable: true,
|
|
270
|
-
configurable: true,
|
|
271
|
-
writable: true,
|
|
272
|
-
value: params
|
|
273
|
-
});
|
|
212
|
+
function isWeb(fileType) {
|
|
213
|
+
return !!(fileType & WEB_LOCATION_FLAG);
|
|
214
|
+
}
|
|
215
|
+
function hasFileReference(fileType) {
|
|
216
|
+
return !!(fileType && FILE_REFERENCE_FLAG);
|
|
217
|
+
}
|
|
218
|
+
function deserializeFileId(fileId) {
|
|
219
|
+
const reader = new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)((0, _1_utilities_js_1.base64DecodeUrlSafe)(fileId)));
|
|
220
|
+
if (reader.buffer[reader.buffer.length - 1] != PERSISTENT_ID_VERSION) {
|
|
221
|
+
throw new Error("Unsupported version");
|
|
274
222
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
223
|
+
const originalType = reader.readInt32();
|
|
224
|
+
const type = ((originalType & ~WEB_LOCATION_FLAG) & ~FILE_REFERENCE_FLAG);
|
|
225
|
+
const dcId = reader.readInt32();
|
|
226
|
+
if (isWeb(originalType)) {
|
|
227
|
+
const url = reader.readString();
|
|
228
|
+
const accessHash = reader.readInt64();
|
|
229
|
+
return { type, dcId, location: { type: "web", url, accessHash } };
|
|
230
|
+
}
|
|
231
|
+
const fileReference = hasFileReference(originalType) ? reader.readBytes() : undefined;
|
|
232
|
+
const id = reader.readInt64();
|
|
233
|
+
const accessHash = reader.readInt64();
|
|
234
|
+
if (getFileTypeClass(type) == FileTypeClass.Photo) {
|
|
235
|
+
const source = deserializePhotoSource(reader);
|
|
236
|
+
return { type, dcId, fileReference, location: { type: "photo", id, accessHash, source } };
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return { type, dcId, fileReference, location: { type: "common", id, accessHash } };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.deserializeFileId = deserializeFileId;
|
|
243
|
+
function serializeFileId(fileId) {
|
|
244
|
+
const writer = new _2_tl_js_1.TLWriter();
|
|
245
|
+
let type = fileId.type;
|
|
246
|
+
if (fileId.fileReference) {
|
|
247
|
+
type |= FILE_REFERENCE_FLAG;
|
|
248
|
+
}
|
|
249
|
+
if (fileId.location.type == "web") {
|
|
250
|
+
type |= WEB_LOCATION_FLAG;
|
|
251
|
+
}
|
|
252
|
+
writer.writeInt32(type);
|
|
253
|
+
writer.writeInt32(fileId.dcId);
|
|
254
|
+
if (fileId.location.type == "web") {
|
|
255
|
+
writer.writeString(fileId.location.url);
|
|
256
|
+
writer.writeInt64(fileId.location.accessHash);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
if (fileId.fileReference) {
|
|
260
|
+
writer.writeBytes(fileId.fileReference);
|
|
294
261
|
}
|
|
262
|
+
writer.writeInt64(fileId.location.id);
|
|
263
|
+
writer.writeInt64(fileId.location.accessHash);
|
|
264
|
+
if (fileId.location.type == "photo") {
|
|
265
|
+
serializePhotoSource(fileId.location.source, writer);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
writer.write(new Uint8Array([NEXT_VERSION - 1, PERSISTENT_ID_VERSION]));
|
|
269
|
+
return (0, _1_utilities_js_1.base64EncodeUrlSafe)((0, _1_utilities_js_1.rleEncode)(writer.buffer));
|
|
270
|
+
}
|
|
271
|
+
exports.serializeFileId = serializeFileId;
|
|
272
|
+
function toUniqueFileId(fileId) {
|
|
273
|
+
const writer = new _2_tl_js_1.TLWriter();
|
|
274
|
+
const type = fileId.location.type == "web" ? 0 : (getFileTypeClass(fileId.type) + 1);
|
|
275
|
+
writer.writeInt32(type);
|
|
276
|
+
if (fileId.location.type == "web") {
|
|
277
|
+
writer.writeString(fileId.location.url);
|
|
295
278
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
279
|
+
else if (fileId.location.type == "common") {
|
|
280
|
+
writer.writeInt64(fileId.location.id);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
switch (fileId.location.source.type) {
|
|
284
|
+
case PhotoSourceType.Legacy:
|
|
285
|
+
case PhotoSourceType.StickerSetThumbnail:
|
|
286
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
287
|
+
/* falls through */
|
|
288
|
+
case PhotoSourceType.FullLegacy:
|
|
289
|
+
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
290
|
+
case PhotoSourceType.ChatPhotoBigLegacy:
|
|
291
|
+
case PhotoSourceType.StickerSetThumbnailLegacy:
|
|
292
|
+
writer.writeInt64(fileId.location.id);
|
|
293
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
305
294
|
break;
|
|
306
|
-
case
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
writer.writeInt32(this.params.localId);
|
|
295
|
+
case PhotoSourceType.ChatPhotoSmall:
|
|
296
|
+
case PhotoSourceType.ChatPhotoBig:
|
|
297
|
+
case PhotoSourceType.Thumbnail:
|
|
298
|
+
writer.writeInt64(fileId.location.id);
|
|
299
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
312
300
|
break;
|
|
313
|
-
case
|
|
314
|
-
|
|
315
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
316
|
-
}
|
|
317
|
-
writer.writeInt64(this.params.mediaId);
|
|
301
|
+
case PhotoSourceType.StickerSetThumbnailVersion:
|
|
302
|
+
writePhotoSourceUniqueId(fileId.location.source, writer);
|
|
318
303
|
break;
|
|
319
|
-
default:
|
|
320
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
321
304
|
}
|
|
322
|
-
return (0, _1_utilities_js_1.base64EncodeUrlSafe)((0, _1_utilities_js_1.rleEncode)(writer.buffer));
|
|
323
305
|
}
|
|
306
|
+
return (0, _1_utilities_js_1.base64EncodeUrlSafe)((0, _1_utilities_js_1.rleEncode)(writer.buffer));
|
|
324
307
|
}
|
|
325
|
-
exports.
|
|
308
|
+
exports.toUniqueFileId = toUniqueFileId;
|
|
@@ -4,26 +4,20 @@ exports.constructChatPhoto = void 0;
|
|
|
4
4
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
5
5
|
const _0__file_id_js_1 = require("./0__file_id.js");
|
|
6
6
|
function constructChatPhoto(photo, chatId, chatAccessHash) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
chatId,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
chatAccessHash,
|
|
22
|
-
accessHash: 0n,
|
|
23
|
-
volumeId: 0n,
|
|
24
|
-
localId: 0,
|
|
25
|
-
}).encode();
|
|
26
|
-
const bigFileUniqueId = new _0__file_id_js_1.FileUniqueID(_0__file_id_js_1.FileUniqueType.Document, { mediaId: photo.photo_id }).encode();
|
|
7
|
+
const smallFileId_ = {
|
|
8
|
+
type: _0__file_id_js_1.FileType.ProfilePhoto,
|
|
9
|
+
dcId: photo.dc_id,
|
|
10
|
+
location: { type: "photo", id: photo.photo_id, accessHash: 0n, source: { type: _0__file_id_js_1.PhotoSourceType.ChatPhotoSmall, chatId: BigInt(chatId), chatAccessHash } },
|
|
11
|
+
};
|
|
12
|
+
const smallFileId = (0, _0__file_id_js_1.serializeFileId)(smallFileId_);
|
|
13
|
+
const smallFileUniqueId = (0, _0__file_id_js_1.toUniqueFileId)(smallFileId_);
|
|
14
|
+
const bigFileId_ = {
|
|
15
|
+
type: _0__file_id_js_1.FileType.ProfilePhoto,
|
|
16
|
+
dcId: photo.dc_id,
|
|
17
|
+
location: { type: "photo", id: photo.photo_id, accessHash: 0n, source: { type: _0__file_id_js_1.PhotoSourceType.ChatPhotoBig, chatId: BigInt(chatId), chatAccessHash } },
|
|
18
|
+
};
|
|
19
|
+
const bigFileId = (0, _0__file_id_js_1.serializeFileId)(bigFileId_);
|
|
20
|
+
const bigFileUniqueId = (0, _0__file_id_js_1.toUniqueFileId)(bigFileId_);
|
|
27
21
|
if (photo instanceof _2_tl_js_1.types.ChatPhoto) {
|
|
28
22
|
return {
|
|
29
23
|
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;
|