@mtkruto/node 0.1.500 → 0.1.700
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/3_types.d.ts +6 -1
- package/esm/3_types.js +6 -1
- package/esm/4_errors.js +2 -4
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_params.d.ts +33 -7
- package/esm/client/0_storage_operations.d.ts +182 -0
- package/esm/client/0_storage_operations.js +611 -0
- package/esm/client/1_composer.d.ts +2 -0
- package/esm/client/1_composer.js +28 -0
- package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
- package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
- package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
- package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
- package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
- package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
- package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
- package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/esm/client/3_video_chat_manager.d.ts +43 -0
- package/esm/client/3_video_chat_manager.js +194 -0
- package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
- package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
- package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
- package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
- package/esm/client/{4_client.js → 5_client.js} +172 -73
- package/esm/connection/0_connection.d.ts +6 -15
- package/esm/connection/0_connection.js +1 -38
- package/esm/connection/1_connection_web_socket.d.ts +3 -2
- package/esm/connection/1_connection_web_socket.js +7 -3
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.d.ts +9 -145
- package/esm/storage/0_storage.js +1 -526
- package/esm/storage/2_storage_indexed_db.d.ts +3 -2
- package/esm/storage/2_storage_indexed_db.js +9 -8
- package/esm/storage/2_storage_local_storage.d.ts +3 -2
- package/esm/storage/2_storage_local_storage.js +5 -4
- package/esm/storage/2_storage_memory.d.ts +4 -4
- package/esm/storage/2_storage_memory.js +12 -19
- package/esm/storage/2_storage_session_storage.d.ts +2 -1
- package/esm/storage/2_storage_session_storage.js +5 -4
- package/esm/tl/3_utilities.d.ts +1 -1
- package/esm/tl/3_utilities.js +3 -3
- package/esm/types/0_birthday.d.ts +27 -0
- package/esm/types/0_birthday.js +26 -0
- package/esm/types/0_giveaway_parameters.d.ts +1 -1
- package/esm/types/0_id.d.ts +1 -1
- package/esm/types/0_live_stream_channel.d.ts +30 -0
- package/esm/types/0_live_stream_channel.js +26 -0
- package/esm/types/0_opening_hours.d.ts +25 -0
- package/esm/types/0_opening_hours.js +25 -0
- package/esm/types/0_video_chat.d.ts +60 -0
- package/esm/types/0_video_chat.js +53 -0
- package/esm/types/1_chat_p.d.ts +4 -0
- package/esm/types/1_chat_p.js +1 -0
- package/esm/types/2_business_connection.d.ts +6 -0
- package/esm/types/2_chat.d.ts +62 -0
- package/esm/types/2_chat.js +66 -0
- package/esm/types/2_inactive_chat.d.ts +1 -1
- package/esm/types/2_invite_link.d.ts +1 -1
- package/esm/types/2_message_reaction_count.d.ts +1 -1
- package/esm/types/2_message_reactions.d.ts +1 -1
- package/esm/types/3_chat_member_updated.d.ts +1 -1
- package/esm/types/4_message.d.ts +3 -3
- package/esm/types/5_chat_list_item.d.ts +35 -0
- package/esm/types/5_chat_list_item.js +86 -0
- package/esm/types/6_update.d.ts +14 -5
- package/esm/types/_file_id.d.ts +1 -0
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +7 -3
- package/package.json +1 -1
- package/script/3_types.d.ts +6 -1
- package/script/3_types.js +6 -1
- package/script/4_errors.js +2 -4
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_params.d.ts +33 -7
- package/script/client/0_storage_operations.d.ts +182 -0
- package/script/client/0_storage_operations.js +615 -0
- package/script/client/1_composer.d.ts +2 -0
- package/script/client/1_composer.js +28 -0
- package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
- package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
- package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
- package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
- package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
- package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
- package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
- package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/script/client/3_video_chat_manager.d.ts +43 -0
- package/script/client/3_video_chat_manager.js +198 -0
- package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
- package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
- package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
- package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
- package/script/client/{4_client.js → 5_client.js} +192 -93
- package/script/connection/0_connection.d.ts +6 -15
- package/script/connection/0_connection.js +0 -41
- package/script/connection/1_connection_web_socket.d.ts +3 -2
- package/script/connection/1_connection_web_socket.js +7 -3
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/storage/0_storage.d.ts +9 -145
- package/script/storage/0_storage.js +0 -528
- package/script/storage/2_storage_indexed_db.d.ts +3 -2
- package/script/storage/2_storage_indexed_db.js +9 -8
- package/script/storage/2_storage_local_storage.d.ts +3 -2
- package/script/storage/2_storage_local_storage.js +5 -4
- package/script/storage/2_storage_memory.d.ts +4 -4
- package/script/storage/2_storage_memory.js +12 -19
- package/script/storage/2_storage_session_storage.d.ts +2 -1
- package/script/storage/2_storage_session_storage.js +5 -4
- package/script/tl/3_utilities.d.ts +1 -1
- package/script/tl/3_utilities.js +3 -3
- package/script/types/0_birthday.d.ts +27 -0
- package/script/types/0_birthday.js +30 -0
- package/script/types/0_giveaway_parameters.d.ts +1 -1
- package/script/types/0_id.d.ts +1 -1
- package/script/types/0_live_stream_channel.d.ts +30 -0
- package/script/types/0_live_stream_channel.js +30 -0
- package/script/types/0_opening_hours.d.ts +25 -0
- package/script/types/0_opening_hours.js +29 -0
- package/script/types/0_video_chat.d.ts +60 -0
- package/script/types/0_video_chat.js +57 -0
- package/script/types/1_chat_p.d.ts +4 -0
- package/script/types/1_chat_p.js +1 -0
- package/script/types/2_business_connection.d.ts +6 -0
- package/script/types/2_chat.d.ts +62 -0
- package/script/types/2_chat.js +70 -0
- package/script/types/2_inactive_chat.d.ts +1 -1
- package/script/types/2_invite_link.d.ts +1 -1
- package/script/types/2_message_reaction_count.d.ts +1 -1
- package/script/types/2_message_reactions.d.ts +1 -1
- package/script/types/3_chat_member_updated.d.ts +1 -1
- package/script/types/4_message.d.ts +3 -3
- package/script/types/5_chat_list_item.d.ts +35 -0
- package/script/types/5_chat_list_item.js +94 -0
- package/script/types/6_update.d.ts +14 -5
- package/script/types/_file_id.d.ts +1 -0
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +7 -3
- package/esm/types/5_chat.d.ts +0 -59
- package/esm/types/5_chat.js +0 -126
- package/script/types/5_chat.d.ts +0 -59
- package/script/types/5_chat.js +0 -134
- /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/esm/{3_storage.js → 2_storage.js} +0 -0
- /package/esm/client/{0_types.js → 1_types.js} +0 -0
- /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
- /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/script/{3_storage.js → 2_storage.js} +0 -0
- /package/script/client/{0_types.js → 1_types.js} +0 -0
- /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { ID } from "../3_types.js";
|
|
21
|
-
import { C } from "./
|
|
21
|
+
import { C } from "./1_types.js";
|
|
22
22
|
export declare class AccountManager {
|
|
23
23
|
#private;
|
|
24
24
|
constructor(c: C);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { BotCommand } from "../3_types.js";
|
|
21
21
|
import { GetMyCommandsParams, SetMyCommandsParams } from "./0_params.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
export declare class BotInfoManager {
|
|
24
24
|
#private;
|
|
25
25
|
constructor(c: C);
|
package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts}
RENAMED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { Update } from "../3_types.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect;
|
|
24
24
|
export declare class BusinessConnectionManager {
|
|
25
25
|
#private;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { types } from "../2_tl.js";
|
|
1
|
+
import { enums, types } from "../2_tl.js";
|
|
2
2
|
import { FileSource, Sticker } from "../3_types.js";
|
|
3
3
|
import { DownloadParams, UploadParams } from "./0_params.js";
|
|
4
|
-
import { C } from "./
|
|
4
|
+
import { C } from "./1_types.js";
|
|
5
5
|
export declare class FileManager {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(c: C);
|
|
8
8
|
upload(file: FileSource, params?: UploadParams, checkName?: null | ((name: string) => string), allowStream?: boolean): Promise<import("../tl/2_types.js").InputFile_ | import("../tl/2_types.js").InputFileBig_>;
|
|
9
|
+
downloadInner(location: enums.InputFileLocation, dcId: number, params?: {
|
|
10
|
+
chunkSize?: number;
|
|
11
|
+
offset?: number;
|
|
12
|
+
}): AsyncGenerator<Uint8Array, void, unknown>;
|
|
9
13
|
static validateChunkSize(chunkSize: number, max: number): void;
|
|
10
14
|
download(fileId: string, params?: DownloadParams): AsyncGenerator<Uint8Array, void, unknown>;
|
|
11
15
|
getStickerSetName(inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
|
|
@@ -33,7 +33,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_UPLOAD_REQUEST_PER_CONNECTION, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_handleUploadError, _FileManager_getFileContents,
|
|
36
|
+
var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_UPLOAD_REQUEST_PER_CONNECTION, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_handleUploadError, _FileManager_getFileContents, _FileManager_CUSTOM_EMOJI_TTL;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.FileManager = void 0;
|
|
39
39
|
/**
|
|
@@ -110,6 +110,51 @@ class FileManager {
|
|
|
110
110
|
return new _2_tl_js_1.types.InputFileBig({ id: fileId, parts: result.parts, name });
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
async *downloadInner(location, dcId, params) {
|
|
114
|
+
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
115
|
+
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
116
|
+
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
117
|
+
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
118
|
+
if (file != null && file[0] > 0) {
|
|
119
|
+
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
124
|
+
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
125
|
+
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
126
|
+
await connection.connect();
|
|
127
|
+
const limit = chunkSize;
|
|
128
|
+
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
129
|
+
let part = 0;
|
|
130
|
+
try {
|
|
131
|
+
while (true) {
|
|
132
|
+
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
133
|
+
if (file instanceof _2_tl_js_1.types.upload.File) {
|
|
134
|
+
yield file.bytes;
|
|
135
|
+
if (id != null) {
|
|
136
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
137
|
+
}
|
|
138
|
+
++part;
|
|
139
|
+
if (file.bytes.length < limit) {
|
|
140
|
+
if (id != null) {
|
|
141
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
offset += BigInt(file.bytes.length);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
(0, _0_deps_js_1.unreachable)();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
(0, _1_utilities_js_1.drop)(connection.disconnect());
|
|
156
|
+
}
|
|
157
|
+
}
|
|
113
158
|
static validateChunkSize(chunkSize, max) {
|
|
114
159
|
if (chunkSize <= 0) {
|
|
115
160
|
throw new _0_errors_js_1.InputError("chunkSize must be bigger than zero.");
|
|
@@ -135,7 +180,7 @@ class FileManager {
|
|
|
135
180
|
const big = fileId_.location.source.type == _3_types_js_1.PhotoSourceType.ChatPhotoBig;
|
|
136
181
|
const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId)); // TODO: use access hash from source?
|
|
137
182
|
const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.location.id });
|
|
138
|
-
yield*
|
|
183
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
139
184
|
break;
|
|
140
185
|
}
|
|
141
186
|
case _3_types_js_1.FileType.Photo: {
|
|
@@ -145,7 +190,7 @@ class FileManager {
|
|
|
145
190
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
146
191
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : "",
|
|
147
192
|
});
|
|
148
|
-
yield*
|
|
193
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
149
194
|
break;
|
|
150
195
|
}
|
|
151
196
|
case _3_types_js_1.FileType.Thumbnail: {
|
|
@@ -155,7 +200,7 @@ class FileManager {
|
|
|
155
200
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
156
201
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : (0, _0_deps_js_1.unreachable)(),
|
|
157
202
|
});
|
|
158
|
-
yield*
|
|
203
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
159
204
|
break;
|
|
160
205
|
}
|
|
161
206
|
}
|
|
@@ -167,7 +212,7 @@ class FileManager {
|
|
|
167
212
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
168
213
|
thumb_size: "",
|
|
169
214
|
});
|
|
170
|
-
yield*
|
|
215
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
171
216
|
}
|
|
172
217
|
else {
|
|
173
218
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -273,14 +318,16 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
273
318
|
const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
|
|
274
319
|
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
275
320
|
let promises = new Array();
|
|
276
|
-
for (let part = 0; part < partCount;) {
|
|
321
|
+
main: for (let part = 0; part < partCount;) {
|
|
277
322
|
for (let i = 0; i < pool.size; ++i) {
|
|
278
323
|
const api = pool.api();
|
|
279
324
|
for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_REQUEST_PER_CONNECTION); ++i) {
|
|
280
325
|
const start = part * chunkSize;
|
|
281
326
|
const end = start + chunkSize;
|
|
282
327
|
const bytes = buffer.subarray(start, end);
|
|
283
|
-
|
|
328
|
+
if (!bytes.length) {
|
|
329
|
+
break main;
|
|
330
|
+
}
|
|
284
331
|
const thisPart = part++; // `thisPart` must be used instead of `part` in the promise body
|
|
285
332
|
promises.push(Promise.resolve().then(async () => {
|
|
286
333
|
while (true) {
|
|
@@ -400,50 +447,6 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
400
447
|
}
|
|
401
448
|
}
|
|
402
449
|
return { size: params?.fileSize ? params.fileSize : size, name, contents };
|
|
403
|
-
}, _FileManager_downloadInner = async function* _FileManager_downloadInner(location, dcId, params) {
|
|
404
|
-
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
405
|
-
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
406
|
-
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
407
|
-
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
408
|
-
if (file != null && file[0] > 0) {
|
|
409
|
-
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
414
|
-
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
415
|
-
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
416
|
-
await connection.connect();
|
|
417
|
-
const limit = chunkSize;
|
|
418
|
-
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
419
|
-
let part = 0;
|
|
420
|
-
try {
|
|
421
|
-
while (true) {
|
|
422
|
-
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
423
|
-
if (file instanceof _2_tl_js_1.types.upload.File) {
|
|
424
|
-
yield file.bytes;
|
|
425
|
-
if (id != null) {
|
|
426
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
427
|
-
}
|
|
428
|
-
++part;
|
|
429
|
-
if (file.bytes.length < limit) {
|
|
430
|
-
if (id != null) {
|
|
431
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
432
|
-
}
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
offset += BigInt(file.bytes.length);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
(0, _0_deps_js_1.unreachable)();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
finally {
|
|
445
|
-
(0, _1_utilities_js_1.drop)(connection.disconnect());
|
|
446
|
-
}
|
|
447
450
|
};
|
|
448
451
|
_FileManager_UPLOAD_MAX_CHUNK_SIZE = { value: 512 * _1_utilities_js_1.kilobyte };
|
|
449
452
|
_FileManager_DOWNLOAD_MAX_CHUNK_SIZE = { value: 1 * _1_utilities_js_1.megabyte };
|
package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts}
RENAMED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import { C } from "./
|
|
20
|
+
import { C } from "./1_types.js";
|
|
21
21
|
export declare class NetworkStatisticsManager {
|
|
22
22
|
#private;
|
|
23
23
|
constructor(c: C);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { Update } from "../3_types.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
type ReactionManagerUpdate = types.UpdateBotMessageReactions | types.UpdateBotMessageReaction | types.UpdateMessageReactions | types.UpdateChannelMessageViews | types.UpdateChannelMessageForwards;
|
|
24
24
|
export declare class ReactionManager {
|
|
25
25
|
#private;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Queue } from "../1_utilities.js";
|
|
21
21
|
import { enums, ReadObject, TLObject, types } from "../2_tl.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
type UpdateHandler = (update: enums.Update) => Promise<(() => Promise<unknown>)>;
|
|
24
24
|
export type PtsUpdate = types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
|
|
25
25
|
export type ChannelPtsUpdate = types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages | types.UpdateChannelTooLong;
|
|
@@ -21,8 +21,8 @@ import { enums, types } from "../2_tl.js";
|
|
|
21
21
|
import { InputMedia } from "../3_types.js";
|
|
22
22
|
import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
|
|
23
23
|
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendChatActionParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
|
|
24
|
-
import { C as C_ } from "./
|
|
25
|
-
import { FileManager } from "./
|
|
24
|
+
import { C as C_ } from "./1_types.js";
|
|
25
|
+
import { FileManager } from "./2_file_manager.js";
|
|
26
26
|
interface C extends C_ {
|
|
27
27
|
fileManager: FileManager;
|
|
28
28
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import { enums, types } from "../2_tl.js";
|
|
21
|
+
import { ID, Update, VideoChatActive, VideoChatScheduled } from "../3_types.js";
|
|
22
|
+
import { DownloadLiveStreamChunkParams, JoinVideoChatParams, StartVideoChatParams } from "./0_params.js";
|
|
23
|
+
import { C as C_ } from "./1_types.js";
|
|
24
|
+
import { FileManager } from "./2_file_manager.js";
|
|
25
|
+
interface C extends C_ {
|
|
26
|
+
fileManager: FileManager;
|
|
27
|
+
}
|
|
28
|
+
type VideoChatManagerUpdate = types.UpdateGroupCall;
|
|
29
|
+
export declare class VideoChatManager {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(c: C);
|
|
32
|
+
startVideoChat(chatId: ID, params?: StartVideoChatParams): Promise<VideoChatActive>;
|
|
33
|
+
scheduleVideoChat(chatId: ID, startAt: Date, params?: StartVideoChatParams): Promise<VideoChatScheduled>;
|
|
34
|
+
joinVideoChat(id: string, params: string, params_?: JoinVideoChatParams): Promise<string>;
|
|
35
|
+
leaveVideoChat(id: string): Promise<void>;
|
|
36
|
+
joinLiveStream(id: string): Promise<void>;
|
|
37
|
+
getVideoChat(id: string): Promise<import("../3_types.js").VideoChat>;
|
|
38
|
+
static canHandleUpdate(update: enums.Update): update is VideoChatManagerUpdate;
|
|
39
|
+
handleUpdate(update: VideoChatManagerUpdate): Promise<Update>;
|
|
40
|
+
getLiveStreamChannels(id: string): Promise<import("../3_types.js").LiveStreamChannel[]>;
|
|
41
|
+
downloadLiveStreamChunk(id: string, channel: number, scale: number, timestamp: number, params?: DownloadLiveStreamChunkParams): AsyncGenerator<Uint8Array, void, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
25
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
+
};
|
|
27
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
30
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
+
};
|
|
32
|
+
var _VideoChatManager_instances, _VideoChatManager_c, _VideoChatManager_createGroupCall, _VideoChatManager_getInputGroupCall, _VideoChatManager_getCall;
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.VideoChatManager = void 0;
|
|
35
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
36
|
+
const _0_errors_js_1 = require("../0_errors.js");
|
|
37
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
|
+
const _3_types_js_1 = require("../3_types.js");
|
|
40
|
+
class VideoChatManager {
|
|
41
|
+
constructor(c) {
|
|
42
|
+
_VideoChatManager_instances.add(this);
|
|
43
|
+
_VideoChatManager_c.set(this, void 0);
|
|
44
|
+
__classPrivateFieldSet(this, _VideoChatManager_c, c, "f");
|
|
45
|
+
}
|
|
46
|
+
async startVideoChat(chatId, params) {
|
|
47
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("startVideoChat");
|
|
48
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined);
|
|
49
|
+
}
|
|
50
|
+
async scheduleVideoChat(chatId, startAt, params) {
|
|
51
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("scheduleVideoChat");
|
|
52
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined, startAt);
|
|
53
|
+
}
|
|
54
|
+
async joinVideoChat(id, params, params_) {
|
|
55
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinVideoChat");
|
|
56
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
57
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
58
|
+
call,
|
|
59
|
+
join_as: params_?.joinAs ? await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(params_.joinAs) : new _2_tl_js_1.types.InputPeerSelf(),
|
|
60
|
+
params: new _2_tl_js_1.types.DataJSON({ data: params }),
|
|
61
|
+
invite_hash: params_?.inviteHash,
|
|
62
|
+
muted: params_?.audio ? undefined : true,
|
|
63
|
+
video_stopped: params_?.video ? undefined : true,
|
|
64
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
65
|
+
const updateGroupCall = updates
|
|
66
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCallConnection);
|
|
67
|
+
if (!updateGroupCall)
|
|
68
|
+
(0, _0_deps_js_1.unreachable)();
|
|
69
|
+
return updateGroupCall.params.data;
|
|
70
|
+
}
|
|
71
|
+
async leaveVideoChat(id) {
|
|
72
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("leaveVideoChat");
|
|
73
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.leaveGroupCall({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id), source: 0 });
|
|
74
|
+
}
|
|
75
|
+
async joinLiveStream(id) {
|
|
76
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinLiveStream");
|
|
77
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
78
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
79
|
+
call,
|
|
80
|
+
join_as: new _2_tl_js_1.types.InputPeerSelf(),
|
|
81
|
+
params: new _2_tl_js_1.types.DataJSON({
|
|
82
|
+
data: JSON.stringify({
|
|
83
|
+
fingerprints: [],
|
|
84
|
+
pwd: "",
|
|
85
|
+
ssrc: (0, _1_utilities_js_1.getRandomId)(true),
|
|
86
|
+
"ssrc-groups": [],
|
|
87
|
+
ufrag: "",
|
|
88
|
+
}),
|
|
89
|
+
}),
|
|
90
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
91
|
+
const updateGroupCall = updates
|
|
92
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCallConnection);
|
|
93
|
+
if (!updateGroupCall)
|
|
94
|
+
(0, _0_deps_js_1.unreachable)();
|
|
95
|
+
}
|
|
96
|
+
async getVideoChat(id) {
|
|
97
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getVideoChat");
|
|
98
|
+
return (0, _3_types_js_1.constructVideoChat)(await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id));
|
|
99
|
+
}
|
|
100
|
+
static canHandleUpdate(update) {
|
|
101
|
+
return update instanceof _2_tl_js_1.types.UpdateGroupCall;
|
|
102
|
+
}
|
|
103
|
+
async handleUpdate(update) {
|
|
104
|
+
let chatId = Number(-update.chat_id);
|
|
105
|
+
const fullChat = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId).then((v) => v == null ? __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId = _1_utilities_js_1.ZERO_CHANNEL_ID - Number(update.chat_id)) : v);
|
|
106
|
+
let updateFullChat = false;
|
|
107
|
+
if (update.call instanceof _2_tl_js_1.types.GroupCallDiscarded) {
|
|
108
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, null);
|
|
109
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, null);
|
|
110
|
+
if (fullChat != null) {
|
|
111
|
+
fullChat.call = undefined;
|
|
112
|
+
updateFullChat = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, update.call);
|
|
117
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, update.call.access_hash);
|
|
118
|
+
if (fullChat != null) {
|
|
119
|
+
if (!("call" in fullChat) || !fullChat.call || fullChat.call.id != update.call.id) {
|
|
120
|
+
fullChat.call = new _2_tl_js_1.types.InputGroupCall(update.call);
|
|
121
|
+
updateFullChat = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (updateFullChat) {
|
|
126
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setFullChat(chatId, fullChat);
|
|
127
|
+
}
|
|
128
|
+
return { videoChat: (0, _3_types_js_1.constructVideoChat)(update.call) };
|
|
129
|
+
}
|
|
130
|
+
async getLiveStreamChannels(id) {
|
|
131
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getLiveStreamChannels");
|
|
132
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
133
|
+
if (!(call instanceof _2_tl_js_1.types.GroupCall) || !call.rtmp_stream) {
|
|
134
|
+
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
135
|
+
}
|
|
136
|
+
const client = __classPrivateFieldGet(this, _VideoChatManager_c, "f").getCdnConnection(call.stream_dc_id);
|
|
137
|
+
await client.connect();
|
|
138
|
+
try {
|
|
139
|
+
const streams = await client.api.phone.getGroupCallStreamChannels({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id) });
|
|
140
|
+
return streams.channels.map(_3_types_js_1.constructLiveStreamChannel);
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
await client.disconnect();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async *downloadLiveStreamChunk(id, channel, scale, timestamp, params) {
|
|
147
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("downloadLiveStreamChunk");
|
|
148
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
149
|
+
if (!(call instanceof _2_tl_js_1.types.GroupCall) || !call.rtmp_stream) {
|
|
150
|
+
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
151
|
+
}
|
|
152
|
+
const quality = params?.quality ?? "low";
|
|
153
|
+
const location = new _2_tl_js_1.types.InputGroupCallStream({
|
|
154
|
+
call: new _2_tl_js_1.types.InputGroupCall(call),
|
|
155
|
+
scale,
|
|
156
|
+
time_ms: BigInt(timestamp),
|
|
157
|
+
video_channel: channel,
|
|
158
|
+
video_quality: quality == "low" ? 0 : quality == "medium" ? 1 : quality == "high" ? 2 : (() => {
|
|
159
|
+
throw new _0_errors_js_1.InputError("Got invalid quality.");
|
|
160
|
+
})(),
|
|
161
|
+
});
|
|
162
|
+
yield* __classPrivateFieldGet(this, _VideoChatManager_c, "f").fileManager.downloadInner(location, call.stream_dc_id ?? (0, _0_deps_js_1.unreachable)());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.VideoChatManager = VideoChatManager;
|
|
166
|
+
_VideoChatManager_c = new WeakMap(), _VideoChatManager_instances = new WeakSet(), _VideoChatManager_createGroupCall = async function _VideoChatManager_createGroupCall(chatId, title, liveStream, scheduleDate) {
|
|
167
|
+
const peer = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(chatId);
|
|
168
|
+
if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
|
|
169
|
+
throw new _0_errors_js_1.InputError("Video chats are only available for groups and channels.");
|
|
170
|
+
}
|
|
171
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.createGroupCall({
|
|
172
|
+
peer,
|
|
173
|
+
random_id: (0, _1_utilities_js_1.getRandomId)(true),
|
|
174
|
+
title,
|
|
175
|
+
rtmp_stream: liveStream,
|
|
176
|
+
schedule_date: scheduleDate ? (0, _1_utilities_js_1.toUnixTimestamp)(scheduleDate) : undefined,
|
|
177
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
178
|
+
const updateGroupCall = updates
|
|
179
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCall);
|
|
180
|
+
if (!updateGroupCall) {
|
|
181
|
+
(0, _0_deps_js_1.unreachable)();
|
|
182
|
+
}
|
|
183
|
+
return (0, _3_types_js_1.constructVideoChat)(updateGroupCall.call);
|
|
184
|
+
}, _VideoChatManager_getInputGroupCall = async function _VideoChatManager_getInputGroupCall(id_) {
|
|
185
|
+
const id = BigInt(id_);
|
|
186
|
+
const accessHash = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCallAccessHash(id);
|
|
187
|
+
if (accessHash == null) {
|
|
188
|
+
throw new _0_errors_js_1.InputError("Video chat not found.");
|
|
189
|
+
}
|
|
190
|
+
return new _2_tl_js_1.types.InputGroupCall({ id, access_hash: accessHash });
|
|
191
|
+
}, _VideoChatManager_getCall = async function _VideoChatManager_getCall(id) {
|
|
192
|
+
let groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCall(BigInt(id));
|
|
193
|
+
if (groupCall == null) {
|
|
194
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
195
|
+
groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.getGroupCall({ call, limit: 1 }).then((v) => v.call);
|
|
196
|
+
}
|
|
197
|
+
return groupCall;
|
|
198
|
+
};
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { CallbackQueryQuestion, ID, Update } from "../3_types.js";
|
|
22
22
|
import { AnswerCallbackQueryParams } from "./0_params.js";
|
|
23
|
-
import { C as C_ } from "./
|
|
24
|
-
import { MessageManager } from "./
|
|
23
|
+
import { C as C_ } from "./1_types.js";
|
|
24
|
+
import { MessageManager } from "./3_message_manager.js";
|
|
25
25
|
type C = C_ & {
|
|
26
26
|
messageManager: MessageManager;
|
|
27
27
|
};
|
|
@@ -53,6 +53,7 @@ class CallbackQueryManager {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
async sendCallbackQuery(chatId, messageId, question) {
|
|
56
|
+
await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertUser("sendCallbackQuery");
|
|
56
57
|
(0, _0_utilities_js_1.checkMessageId)(messageId);
|
|
57
58
|
(0, _3_types_js_1.validateCallbackQueryQuestion)(question);
|
|
58
59
|
const peer = await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getInputPeer(chatId), peerId = (0, _2_tl_js_1.peerToChatId)(peer), questionKey = JSON.stringify(question);
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
|
-
import {
|
|
22
|
-
import { C as C_ } from "./
|
|
23
|
-
import { FileManager } from "./
|
|
24
|
-
import { MessageManager } from "./
|
|
21
|
+
import { ChatListItem, ID } from "../3_types.js";
|
|
22
|
+
import { C as C_ } from "./1_types.js";
|
|
23
|
+
import { FileManager } from "./2_file_manager.js";
|
|
24
|
+
import { MessageManager } from "./3_message_manager.js";
|
|
25
25
|
type C = C_ & {
|
|
26
26
|
fileManager: FileManager;
|
|
27
27
|
messageManager: MessageManager;
|
|
@@ -31,9 +31,9 @@ export declare class ChatListManager {
|
|
|
31
31
|
#private;
|
|
32
32
|
constructor(c: C);
|
|
33
33
|
reassignChatLastMessage(chatId: number, add?: boolean, sendUpdate?: boolean): Promise<() => Promise<void>>;
|
|
34
|
-
getChats(from?: "archived" | "main", after?:
|
|
34
|
+
getChats(from?: "archived" | "main", after?: ChatListItem, limit?: number): Promise<ChatListItem[]>;
|
|
35
35
|
static canHandleUpdate(update: enums.Update): update is ChatListManagerUpdate;
|
|
36
36
|
handleUpdate(update: ChatListManagerUpdate): Promise<void>;
|
|
37
|
-
getChat(chatId: ID): Promise<Chat>;
|
|
37
|
+
getChat(chatId: ID): Promise<import("../3_types.js").Chat>;
|
|
38
38
|
}
|
|
39
39
|
export {};
|