@mtkruto/node 0.2.45 → 0.2.51
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/client/0_filters.d.ts +6 -5
- package/esm/client/0_filters.d.ts.map +1 -1
- package/esm/client/0_filters.js +3 -0
- package/esm/client/0_params.d.ts +18 -24
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_storage_operations.d.ts +4 -3
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +13 -5
- package/esm/client/2_account_manager.js +5 -5
- package/esm/client/2_bot_info_manager.js +8 -8
- package/esm/client/2_file_manager.d.ts +3 -6
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +9 -1
- package/esm/client/2_payment_manager.d.ts.map +1 -1
- package/esm/client/2_payment_manager.js +2 -1
- package/esm/client/2_update_manager.js +2 -2
- package/esm/client/3_message_manager.d.ts +5 -2
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +112 -36
- package/esm/client/3_video_chat_manager.js +9 -9
- package/esm/client/4_callback_query_manager.js +2 -2
- package/esm/client/4_chat_list_manager.d.ts +3 -0
- package/esm/client/4_chat_list_manager.d.ts.map +1 -1
- package/esm/client/4_chat_list_manager.js +47 -2
- package/esm/client/4_inline_query_manager.js +2 -2
- package/esm/client/4_story_manager.js +9 -9
- package/esm/client/5_client.d.ts +43 -2
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +57 -4
- package/esm/types/1_input_media.d.ts +1 -1
- package/esm/types/1_input_media.d.ts.map +1 -1
- package/esm/types/4_message.d.ts +2 -0
- package/esm/types/4_message.d.ts.map +1 -1
- package/esm/types/4_message.js +1 -0
- package/esm/types/6_update.d.ts +28 -7
- package/esm/types/6_update.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/client/0_filters.d.ts +6 -5
- package/script/client/0_filters.d.ts.map +1 -1
- package/script/client/0_filters.js +3 -0
- package/script/client/0_params.d.ts +18 -24
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_storage_operations.d.ts +4 -3
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +13 -5
- package/script/client/2_account_manager.js +5 -5
- package/script/client/2_bot_info_manager.js +8 -8
- package/script/client/2_file_manager.d.ts +3 -6
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +9 -1
- package/script/client/2_payment_manager.d.ts.map +1 -1
- package/script/client/2_payment_manager.js +2 -1
- package/script/client/2_update_manager.js +2 -2
- package/script/client/3_message_manager.d.ts +5 -2
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +111 -35
- package/script/client/3_video_chat_manager.js +9 -9
- package/script/client/4_callback_query_manager.js +2 -2
- package/script/client/4_chat_list_manager.d.ts +3 -0
- package/script/client/4_chat_list_manager.d.ts.map +1 -1
- package/script/client/4_chat_list_manager.js +46 -1
- package/script/client/4_inline_query_manager.js +2 -2
- package/script/client/4_story_manager.js +9 -9
- package/script/client/5_client.d.ts +43 -2
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +57 -4
- package/script/types/1_input_media.d.ts +1 -1
- package/script/types/1_input_media.d.ts.map +1 -1
- package/script/types/4_message.d.ts +2 -0
- package/script/types/4_message.d.ts.map +1 -1
- package/script/types/4_message.js +1 -0
- package/script/types/6_update.d.ts +28 -7
- package/script/types/6_update.d.ts.map +1 -1
|
@@ -29,7 +29,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
29
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
30
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
31
|
};
|
|
32
|
-
var _MessageManager_instances, _MessageManager_c, _MessageManager_LresolveFileId, _MessageManager_updatesToMessages, _MessageManager_constructReplyMarkup, _MessageManager_resolveSendAs, _MessageManager_constructReplyTo, _MessageManager_sendDocumentInner, _MessageManager_sendMedia, _MessageManager_resolveInputMediaInner, _MessageManager_resolveInputMedia, _MessageManager_sendReaction, _MessageManager_toggleJoinRequests;
|
|
32
|
+
var _MessageManager_instances, _MessageManager_c, _MessageManager_LresolveFileId, _MessageManager_checkParams, _MessageManager_updatesToMessages, _MessageManager_constructReplyMarkup, _MessageManager_resolveSendAs, _MessageManager_constructReplyTo, _MessageManager_sendDocumentInner, _MessageManager_sendMedia, _MessageManager_resolveInputMediaInner, _MessageManager_resolveInputMedia, _MessageManager_sendReaction, _MessageManager_toggleJoinRequests;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.MessageManager = void 0;
|
|
35
35
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -50,12 +50,14 @@ const messageManagerUpdates = [
|
|
|
50
50
|
"updateNewMessage",
|
|
51
51
|
"updateNewChannelMessage",
|
|
52
52
|
"updateEditMessage",
|
|
53
|
+
"updateNewScheduledMessage",
|
|
53
54
|
"updateEditChannelMessage",
|
|
54
55
|
"updateBotNewBusinessMessage",
|
|
55
56
|
"updateBotEditBusinessMessage",
|
|
56
57
|
"updateBotDeleteBusinessMessage",
|
|
57
58
|
"updateDeleteMessages",
|
|
58
59
|
"updateDeleteChannelMessages",
|
|
60
|
+
"updateDeleteScheduledMessages",
|
|
59
61
|
"updateChannelParticipant",
|
|
60
62
|
"updateChatParticipant",
|
|
61
63
|
"updateBotChatInviteRequester",
|
|
@@ -175,7 +177,7 @@ class MessageManager {
|
|
|
175
177
|
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, to, result);
|
|
176
178
|
}
|
|
177
179
|
async getHistory(chatId, params) {
|
|
178
|
-
|
|
180
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
|
|
179
181
|
let limit = params?.limit ?? 100;
|
|
180
182
|
if (limit <= 0) {
|
|
181
183
|
limit = 1;
|
|
@@ -203,6 +205,7 @@ class MessageManager {
|
|
|
203
205
|
return messages;
|
|
204
206
|
}
|
|
205
207
|
async sendMessage(chatId, text, params) {
|
|
208
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
206
209
|
const [message, entities] = await this.parseText(text, params);
|
|
207
210
|
const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
|
|
208
211
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
@@ -213,6 +216,7 @@ class MessageManager {
|
|
|
213
216
|
const noforwards = params?.protectContent ? true : undefined;
|
|
214
217
|
const sendAs = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveSendAs).call(this, params);
|
|
215
218
|
const effect = params?.effectId ? BigInt(params.effectId) : undefined;
|
|
219
|
+
const schedule_date = params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined;
|
|
216
220
|
let result;
|
|
217
221
|
if (!noWebpage && params?.linkPreview?.url) {
|
|
218
222
|
result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
@@ -235,6 +239,7 @@ class MessageManager {
|
|
|
235
239
|
entities,
|
|
236
240
|
reply_markup: replyMarkup,
|
|
237
241
|
effect,
|
|
242
|
+
schedule_date,
|
|
238
243
|
}, params?.businessConnectionId);
|
|
239
244
|
}
|
|
240
245
|
else {
|
|
@@ -252,12 +257,14 @@ class MessageManager {
|
|
|
252
257
|
entities,
|
|
253
258
|
reply_markup: replyMarkup,
|
|
254
259
|
effect,
|
|
260
|
+
schedule_date,
|
|
255
261
|
}, params?.businessConnectionId);
|
|
256
262
|
}
|
|
257
263
|
const message_ = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
258
264
|
return (0, _3_types_js_2.assertMessageType)(message_, "text");
|
|
259
265
|
}
|
|
260
266
|
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
267
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
261
268
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
262
269
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
263
270
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -288,11 +295,13 @@ class MessageManager {
|
|
|
288
295
|
}),
|
|
289
296
|
message: "",
|
|
290
297
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
298
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
291
299
|
}, params?.businessConnectionId);
|
|
292
300
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
293
301
|
return (0, _3_types_js_2.assertMessageType)(message, "venue");
|
|
294
302
|
}
|
|
295
303
|
async sendContact(chatId, firstName, number, params) {
|
|
304
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
296
305
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
297
306
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
298
307
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -317,11 +326,13 @@ class MessageManager {
|
|
|
317
326
|
}),
|
|
318
327
|
message: "",
|
|
319
328
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
329
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
320
330
|
}, params?.businessConnectionId);
|
|
321
331
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
322
332
|
return (0, _3_types_js_2.assertMessageType)(message, "contact");
|
|
323
333
|
}
|
|
324
334
|
async sendDice(chatId, params) {
|
|
335
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
325
336
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
326
337
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
327
338
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -343,11 +354,13 @@ class MessageManager {
|
|
|
343
354
|
}),
|
|
344
355
|
message: "",
|
|
345
356
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
357
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
346
358
|
}, params?.businessConnectionId);
|
|
347
359
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
348
360
|
return (0, _3_types_js_2.assertMessageType)(message, "dice");
|
|
349
361
|
}
|
|
350
362
|
async sendLocation(chatId, latitude, longitude, params) {
|
|
363
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
351
364
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
352
365
|
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
353
366
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -387,29 +400,34 @@ class MessageManager {
|
|
|
387
400
|
}),
|
|
388
401
|
message: "",
|
|
389
402
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
403
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
390
404
|
}, params?.businessConnectionId);
|
|
391
405
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
392
406
|
return (0, _3_types_js_2.assertMessageType)(message, "location");
|
|
393
407
|
}
|
|
394
408
|
async sendVideoNote(chatId, audio, params) {
|
|
409
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
395
410
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_2.FileType.VideoNote, [
|
|
396
411
|
{ _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
|
|
397
412
|
], false);
|
|
398
413
|
return (0, _3_types_js_2.assertMessageType)(message, "videoNote");
|
|
399
414
|
}
|
|
400
415
|
async sendAudio(chatId, audio, params) {
|
|
416
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
401
417
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_2.FileType.Audio, [
|
|
402
418
|
{ _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
|
|
403
419
|
]);
|
|
404
420
|
return (0, _3_types_js_2.assertMessageType)(message, "audio");
|
|
405
421
|
}
|
|
406
422
|
async sendVoice(chatId, voice, params) {
|
|
423
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
407
424
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_2.FileType.VoiceNote, [
|
|
408
425
|
{ _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
|
|
409
426
|
]);
|
|
410
427
|
return (0, _3_types_js_2.assertMessageType)(message, "voice");
|
|
411
428
|
}
|
|
412
429
|
async sendAnimation(chatId, animation, params) {
|
|
430
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
413
431
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, animation, params, _3_types_js_2.FileType.Animation, [
|
|
414
432
|
{ _: "documentAttributeAnimated" },
|
|
415
433
|
{ _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
@@ -417,20 +435,24 @@ class MessageManager {
|
|
|
417
435
|
return (0, _3_types_js_2.assertMessageType)(message, "animation");
|
|
418
436
|
}
|
|
419
437
|
async sendVideo(chatId, video, params) {
|
|
438
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
420
439
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, video, params, _3_types_js_2.FileType.Video, [
|
|
421
440
|
{ _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
422
441
|
]);
|
|
423
442
|
return (0, _3_types_js_2.assertMessageType)(message, "video");
|
|
424
443
|
}
|
|
425
444
|
async sendDocument(chatId, document, params) {
|
|
445
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
426
446
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, document, params, _3_types_js_2.FileType.Document, []);
|
|
427
447
|
return (0, _3_types_js_2.assertMessageType)(message, "document");
|
|
428
448
|
}
|
|
429
449
|
async sendSticker(chatId, sticker, params) {
|
|
450
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
430
451
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, _3_types_js_2.FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
|
|
431
452
|
return (0, _3_types_js_2.assertMessageType)(message, "sticker");
|
|
432
453
|
}
|
|
433
454
|
async sendPhoto(chatId, photo, params) {
|
|
455
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
434
456
|
let media = null;
|
|
435
457
|
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
436
458
|
const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? (0, _3_types_js_1.selfDestructOptionToInt)(params.selfDestruct) : undefined;
|
|
@@ -474,6 +496,7 @@ class MessageManager {
|
|
|
474
496
|
return null;
|
|
475
497
|
}
|
|
476
498
|
async sendPoll(chatId, question, options, params) {
|
|
499
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
477
500
|
question = question?.trim();
|
|
478
501
|
if (!question) {
|
|
479
502
|
throw new Error("Question must not be empty.");
|
|
@@ -512,11 +535,13 @@ class MessageManager {
|
|
|
512
535
|
media,
|
|
513
536
|
message: "",
|
|
514
537
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
538
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
515
539
|
}, params?.businessConnectionId);
|
|
516
540
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
517
541
|
return (0, _3_types_js_2.assertMessageType)(message, "poll");
|
|
518
542
|
}
|
|
519
543
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
544
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
520
545
|
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", id: (0, _0_utilities_js_1.checkMessageId)(messageId), peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
521
546
|
const message_ = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result))[0];
|
|
522
547
|
return message_;
|
|
@@ -526,6 +551,7 @@ class MessageManager {
|
|
|
526
551
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
527
552
|
}
|
|
528
553
|
async editMessageText(chatId, messageId, text, params) {
|
|
554
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
529
555
|
const [message, entities] = await this.parseText(text, params);
|
|
530
556
|
const noWebpage = params?.linkPreview?.disable ? true : undefined;
|
|
531
557
|
const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
|
|
@@ -538,6 +564,7 @@ class MessageManager {
|
|
|
538
564
|
return (0, _3_types_js_2.assertMessageType)(message_, "text");
|
|
539
565
|
}
|
|
540
566
|
async editInlineMessageText(inlineMessageId, text, params) {
|
|
567
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
541
568
|
const [message, entities] = await this.parseText(text, params);
|
|
542
569
|
const id = (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
543
570
|
const noWebpage = params?.linkPreview?.disable ? true : undefined;
|
|
@@ -549,6 +576,7 @@ class MessageManager {
|
|
|
549
576
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, entities, message, media, no_webpage: noWebpage, invert_media: invertMedia, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
550
577
|
}
|
|
551
578
|
async editMessageMedia(chatId, messageId, media, params) {
|
|
579
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
552
580
|
const message = await this.getMessage(chatId, messageId);
|
|
553
581
|
if (!message) {
|
|
554
582
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -570,7 +598,8 @@ class MessageManager {
|
|
|
570
598
|
return message_;
|
|
571
599
|
}
|
|
572
600
|
async editInlineMessageMedia(inlineMessageId, media, params) {
|
|
573
|
-
|
|
601
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
602
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageMedia");
|
|
574
603
|
const id = (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
575
604
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, media: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveInputMedia).call(this, media), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
576
605
|
}
|
|
@@ -584,15 +613,39 @@ class MessageManager {
|
|
|
584
613
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
|
|
585
614
|
}
|
|
586
615
|
}
|
|
616
|
+
async deleteScheduledMessages(chatId, messageIds) {
|
|
617
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
|
|
618
|
+
(0, _0_utilities_js_2.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
619
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
620
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
|
|
621
|
+
}
|
|
622
|
+
async deleteScheduledMessage(chatId, messageId) {
|
|
623
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteScheduledMessage");
|
|
624
|
+
return await this.deleteScheduledMessages(chatId, [messageId]);
|
|
625
|
+
}
|
|
626
|
+
async sendScheduledMessages(chatId, messageIds) {
|
|
627
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessages");
|
|
628
|
+
(0, _0_utilities_js_2.checkArray)(messageIds, _0_utilities_js_1.checkMessageId);
|
|
629
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
630
|
+
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
|
|
631
|
+
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result);
|
|
632
|
+
}
|
|
633
|
+
async sendScheduledMessage(chatId, messageId) {
|
|
634
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
|
|
635
|
+
return (await this.sendScheduledMessages(chatId, [messageId]))[0];
|
|
636
|
+
}
|
|
587
637
|
async deleteChatMemberMessages(chatId, memberId) {
|
|
638
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteChatMemberMessages");
|
|
588
639
|
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
|
|
589
640
|
const participant = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
|
|
590
641
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteParticipantHistory", channel, participant });
|
|
591
642
|
}
|
|
592
643
|
async pinMessage(chatId, messageId, params) {
|
|
644
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
593
645
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
|
|
594
646
|
}
|
|
595
647
|
async unpinMessage(chatId, messageId, params) {
|
|
648
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
596
649
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: (0, _0_utilities_js_1.checkMessageId)(messageId), unpin: true }, params?.businessConnectionId);
|
|
597
650
|
}
|
|
598
651
|
async unpinMessages(chatId) {
|
|
@@ -647,7 +700,8 @@ class MessageManager {
|
|
|
647
700
|
(0, _2_tl_js_1.is)("updateEditMessage", update) ||
|
|
648
701
|
(0, _2_tl_js_1.is)("updateEditChannelMessage", update) ||
|
|
649
702
|
(0, _2_tl_js_1.is)("updateBotNewBusinessMessage", update) ||
|
|
650
|
-
(0, _2_tl_js_1.is)("updateBotEditBusinessMessage", update)
|
|
703
|
+
(0, _2_tl_js_1.is)("updateBotEditBusinessMessage", update) ||
|
|
704
|
+
(0, _2_tl_js_1.is)("updateNewScheduledMessage", update)) {
|
|
651
705
|
if (!((0, _2_tl_js_1.is)("messageEmpty", update.message))) {
|
|
652
706
|
const isOutgoing = update.message.out;
|
|
653
707
|
let shouldIgnore = isOutgoing ? (await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.getAccountType()) == "user" ? false : true : false;
|
|
@@ -660,6 +714,10 @@ class MessageManager {
|
|
|
660
714
|
if ((0, _2_tl_js_1.is)("updateNewMessage", update) || (0, _2_tl_js_1.is)("updateNewChannelMessage", update) || (0, _2_tl_js_1.is)("updateBotNewBusinessMessage", update)) {
|
|
661
715
|
return { message };
|
|
662
716
|
}
|
|
717
|
+
else if ((0, _2_tl_js_1.is)("updateNewScheduledMessage", update)) {
|
|
718
|
+
message.scheduled = true;
|
|
719
|
+
return { scheduledMessage: message };
|
|
720
|
+
}
|
|
663
721
|
else {
|
|
664
722
|
return { editedMessage: message };
|
|
665
723
|
}
|
|
@@ -689,6 +747,11 @@ class MessageManager {
|
|
|
689
747
|
}
|
|
690
748
|
return { deletedMessages };
|
|
691
749
|
}
|
|
750
|
+
else if ((0, _2_tl_js_1.is)("updateDeleteScheduledMessages", update)) {
|
|
751
|
+
const chatId = (0, _2_tl_js_1.peerToChatId)(update.peer);
|
|
752
|
+
const deletedMessages = update.messages.map((v) => ({ chatId, messageId: v }));
|
|
753
|
+
return { deletedMessages, scheduled: true };
|
|
754
|
+
}
|
|
692
755
|
else if ((0, _2_tl_js_1.is)("updateBotDeleteBusinessMessage", update)) {
|
|
693
756
|
const chatId = (0, _2_tl_js_1.peerToChatId)(update.peer);
|
|
694
757
|
const deletedMessages = update.messages.map((v) => ({ chatId, messageId: v }));
|
|
@@ -711,6 +774,7 @@ class MessageManager {
|
|
|
711
774
|
return null;
|
|
712
775
|
}
|
|
713
776
|
async sendChatAction(chatId, action, params) {
|
|
777
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
714
778
|
let action_;
|
|
715
779
|
switch (action) {
|
|
716
780
|
case "type":
|
|
@@ -828,11 +892,11 @@ class MessageManager {
|
|
|
828
892
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: (0, _3_types_js_2.chatMemberRightsToTlObject)(params?.rights, params?.untilDate) });
|
|
829
893
|
}
|
|
830
894
|
async enableJoinRequests(chatId) {
|
|
831
|
-
|
|
895
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("enableJoinRequests");
|
|
832
896
|
await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, true);
|
|
833
897
|
}
|
|
834
898
|
async disableJoinRequests(chatId) {
|
|
835
|
-
|
|
899
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("disableJoinRequests");
|
|
836
900
|
await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, false);
|
|
837
901
|
}
|
|
838
902
|
async approveJoinRequest(chatId, userId) {
|
|
@@ -851,7 +915,7 @@ class MessageManager {
|
|
|
851
915
|
});
|
|
852
916
|
}
|
|
853
917
|
async approveJoinRequests(chatId, params) {
|
|
854
|
-
|
|
918
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("approveJoinRequests");
|
|
855
919
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
856
920
|
_: "messages.hideAllChatJoinRequests",
|
|
857
921
|
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
|
|
@@ -860,7 +924,7 @@ class MessageManager {
|
|
|
860
924
|
});
|
|
861
925
|
}
|
|
862
926
|
async declineJoinRequests(chatId, params) {
|
|
863
|
-
|
|
927
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("declineJoinRequests");
|
|
864
928
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
865
929
|
_: "messages.hideAllChatJoinRequests",
|
|
866
930
|
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
|
|
@@ -868,6 +932,7 @@ class MessageManager {
|
|
|
868
932
|
});
|
|
869
933
|
}
|
|
870
934
|
async searchMessages(chatId, query, params) {
|
|
935
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("searchMessages");
|
|
871
936
|
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.search", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), q: query, add_offset: 0, filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"), hash: 0n, limit: params?.limit ?? 100, max_date: 0, max_id: 0, min_date: 0, min_id: 0, offset_id: params?.after ? params.after : 0, from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined });
|
|
872
937
|
if (!("messages" in result)) {
|
|
873
938
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -880,6 +945,7 @@ class MessageManager {
|
|
|
880
945
|
return messages;
|
|
881
946
|
}
|
|
882
947
|
async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
|
|
948
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("setBoostsRequiredToCircumventRestrictions");
|
|
883
949
|
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
|
|
884
950
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
|
|
885
951
|
}
|
|
@@ -891,12 +957,12 @@ class MessageManager {
|
|
|
891
957
|
return await (0, _3_types_js_1.constructInviteLink)((0, _2_tl_js_1.as)("chatInviteExported", result), __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
|
|
892
958
|
}
|
|
893
959
|
async getCreatedInviteLinks(chatId, params) {
|
|
894
|
-
|
|
960
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getCreatedInviteLinks");
|
|
895
961
|
const { invites } = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.getExportedChatInvites", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), revoked: params?.revoked ? true : undefined, admin_id: params?.by ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(params.by) : { _: "inputUserEmpty" }, limit: params?.limit ?? 100, offset_date: params?.afterDate ? (0, _1_utilities_js_1.toUnixTimestamp)(params.afterDate) : undefined, offset_link: params?.afterInviteLink });
|
|
896
962
|
return await Promise.all(invites.map((v) => (0, _2_tl_js_1.as)("chatInviteExported", v)).map((v) => (0, _3_types_js_1.constructInviteLink)(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)));
|
|
897
963
|
}
|
|
898
964
|
async joinChat(chatId) {
|
|
899
|
-
|
|
965
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("joinChat");
|
|
900
966
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
901
967
|
if ((0, _2_tl_js_1.is)("inputPeerUser", peer)) {
|
|
902
968
|
throw new _0_errors_js_1.InputError("Cannot join private chats.");
|
|
@@ -927,7 +993,7 @@ class MessageManager {
|
|
|
927
993
|
}
|
|
928
994
|
}
|
|
929
995
|
async blockUser(userId) {
|
|
930
|
-
|
|
996
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
|
|
931
997
|
const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
|
|
932
998
|
if (!((0, _2_tl_js_1.is)("user", id))) {
|
|
933
999
|
throw new _0_errors_js_1.InputError("Only users can be blocked or unblocked.");
|
|
@@ -935,29 +1001,13 @@ class MessageManager {
|
|
|
935
1001
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.block", id });
|
|
936
1002
|
}
|
|
937
1003
|
async unblockUser(userId) {
|
|
938
|
-
|
|
1004
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
|
|
939
1005
|
const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
|
|
940
1006
|
if (!((0, _2_tl_js_1.is)("user", id))) {
|
|
941
1007
|
throw new _0_errors_js_1.InputError("Only users can be blocked or unblocked.");
|
|
942
1008
|
}
|
|
943
1009
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.unblock", id });
|
|
944
1010
|
}
|
|
945
|
-
async getChatMember(chatId, userId) {
|
|
946
|
-
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
947
|
-
if ((0, _2_tl_js_1.is)("inputPeerChannel", peer)) {
|
|
948
|
-
const { participant } = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.getParticipant", channel: { ...peer, _: "inputChannel" }, participant: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId) });
|
|
949
|
-
return await (0, _3_types_js_2.constructChatMember)(participant, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
|
|
950
|
-
}
|
|
951
|
-
else if ((0, _2_tl_js_1.is)("inputPeerChat", peer)) {
|
|
952
|
-
const user = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(userId);
|
|
953
|
-
const fullChat = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ ...peer, _: "messages.getFullChat" }).then((v) => (0, _2_tl_js_1.as)("chatFull", v.full_chat));
|
|
954
|
-
const participant = (0, _2_tl_js_1.as)("chatParticipants", fullChat.participants).participants.find((v) => v.user_id == user.user_id);
|
|
955
|
-
return await (0, _3_types_js_2.constructChatMember)(participant, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
|
|
956
|
-
}
|
|
957
|
-
else {
|
|
958
|
-
throw new _0_errors_js_1.InputError("Expected a channel, supergroup, or group ID. Got a user ID instead.");
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
1011
|
async setChatStickerSet(chatId, setName) {
|
|
962
1012
|
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
|
|
963
1013
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetShortName", short_name: setName } });
|
|
@@ -967,6 +1017,7 @@ class MessageManager {
|
|
|
967
1017
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
968
1018
|
}
|
|
969
1019
|
async stopPoll(chatId, messageId, params) {
|
|
1020
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
970
1021
|
const message = await this.getMessage(chatId, messageId);
|
|
971
1022
|
if (!message) {
|
|
972
1023
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -982,6 +1033,7 @@ class MessageManager {
|
|
|
982
1033
|
return (0, _3_types_js_2.assertMessageType)(message_, "poll").poll;
|
|
983
1034
|
}
|
|
984
1035
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
1036
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
985
1037
|
const message = await this.getMessage(chatId, messageId);
|
|
986
1038
|
if (message && "location" in message && message.location.livePeriod) {
|
|
987
1039
|
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: messageId, media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
@@ -991,11 +1043,14 @@ class MessageManager {
|
|
|
991
1043
|
(0, _0_deps_js_1.unreachable)();
|
|
992
1044
|
}
|
|
993
1045
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
994
|
-
|
|
1046
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1047
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
|
|
995
1048
|
const id = (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
996
1049
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, media: ({ _: "inputMediaGeoLive", geo_point: ({ _: "inputGeoPoint", lat: latitude, long: longitude, accuracy_radius: params?.horizontalAccuracy }), heading: params?.heading, proximity_notification_radius: params?.proximityAlertRadius }), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
997
1050
|
}
|
|
998
1051
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1052
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("sendInvoice");
|
|
1053
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
999
1054
|
if (title.length < 1) {
|
|
1000
1055
|
throw new _0_errors_js_1.InputError("Invoice title cannot be empty.");
|
|
1001
1056
|
}
|
|
@@ -1048,6 +1103,7 @@ class MessageManager {
|
|
|
1048
1103
|
return (0, _3_types_js_2.assertMessageType)(message, "invoice");
|
|
1049
1104
|
}
|
|
1050
1105
|
async addChatMember(chatId, userId, params) {
|
|
1106
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMember");
|
|
1051
1107
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1052
1108
|
if ((0, _2_tl_js_1.isOneOf)(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1053
1109
|
throw new _0_errors_js_1.InputError("Cannot add members to private chats");
|
|
@@ -1064,6 +1120,7 @@ class MessageManager {
|
|
|
1064
1120
|
(0, _0_deps_js_1.unreachable)();
|
|
1065
1121
|
}
|
|
1066
1122
|
async addChatMembers(chatId, userIds) {
|
|
1123
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMembers");
|
|
1067
1124
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1068
1125
|
if ((0, _2_tl_js_1.isOneOf)(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1069
1126
|
throw new _0_errors_js_1.InputError("Cannot add members to private chats");
|
|
@@ -1082,6 +1139,7 @@ class MessageManager {
|
|
|
1082
1139
|
(0, _0_deps_js_1.unreachable)();
|
|
1083
1140
|
}
|
|
1084
1141
|
async sendMediaGroup(chatId, media, params) {
|
|
1142
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1085
1143
|
{
|
|
1086
1144
|
if (!Array.isArray(media) || !media.length) {
|
|
1087
1145
|
throw new _0_errors_js_1.InputError("Media group must not be empty.");
|
|
@@ -1139,15 +1197,32 @@ class MessageManager {
|
|
|
1139
1197
|
}
|
|
1140
1198
|
}
|
|
1141
1199
|
exports.MessageManager = MessageManager;
|
|
1142
|
-
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(),
|
|
1200
|
+
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
|
|
1201
|
+
if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
|
|
1202
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1203
|
+
}
|
|
1204
|
+
if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
|
|
1205
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
|
|
1206
|
+
}
|
|
1207
|
+
if (params && "sendAs" in params && params.sendAs !== undefined) {
|
|
1208
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1209
|
+
}
|
|
1210
|
+
if (params && "sendAt" in params && params.sendAt !== undefined) {
|
|
1211
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
|
|
1212
|
+
}
|
|
1213
|
+
}, _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates, businessConnectionId) {
|
|
1143
1214
|
const messages = new Array();
|
|
1144
1215
|
if ((0, _2_tl_js_1.is)("updates", updates)) {
|
|
1145
1216
|
for (const update of updates.updates) {
|
|
1146
1217
|
if ("message" in update && (0, _2_tl_js_1.is)("messageEmpty", update.message)) {
|
|
1147
1218
|
continue;
|
|
1148
1219
|
}
|
|
1149
|
-
if ((0, _2_tl_js_1.is)("updateNewMessage", update) || (0, _2_tl_js_1.is)("updateEditMessage", update)) {
|
|
1150
|
-
|
|
1220
|
+
if ((0, _2_tl_js_1.is)("updateNewMessage", update) || (0, _2_tl_js_1.is)("updateEditMessage", update) || (0, _2_tl_js_1.is)("updateNewScheduledMessage", update)) {
|
|
1221
|
+
const message = await this.constructMessage(update.message);
|
|
1222
|
+
if ((0, _2_tl_js_1.is)("updateNewScheduledMessage", update)) {
|
|
1223
|
+
message.scheduled = true;
|
|
1224
|
+
}
|
|
1225
|
+
messages.push(message);
|
|
1151
1226
|
}
|
|
1152
1227
|
else if ((0, _2_tl_js_1.is)("updateNewChannelMessage", update) || (0, _2_tl_js_1.is)("updateEditChannelMessage", update)) {
|
|
1153
1228
|
messages.push(await this.constructMessage(update.message));
|
|
@@ -1169,13 +1244,13 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1169
1244
|
return messages;
|
|
1170
1245
|
}, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
|
|
1171
1246
|
if (params?.replyMarkup) {
|
|
1172
|
-
|
|
1173
|
-
return (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1247
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1248
|
+
return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1174
1249
|
}
|
|
1175
1250
|
}, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
|
|
1176
1251
|
const sendAs = params?.sendAs;
|
|
1177
1252
|
if (sendAs !== undefined) {
|
|
1178
|
-
|
|
1253
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1179
1254
|
return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
|
|
1180
1255
|
}
|
|
1181
1256
|
}, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
|
|
@@ -1259,6 +1334,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1259
1334
|
message: caption ?? "",
|
|
1260
1335
|
entities: captionEntities,
|
|
1261
1336
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
1337
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
1262
1338
|
}, params?.businessConnectionId);
|
|
1263
1339
|
return (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
1264
1340
|
}, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
|
|
@@ -47,15 +47,15 @@ class VideoChatManager {
|
|
|
47
47
|
__classPrivateFieldSet(this, _VideoChatManager_c, c, "f");
|
|
48
48
|
}
|
|
49
49
|
async startVideoChat(chatId, params) {
|
|
50
|
-
|
|
50
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("startVideoChat");
|
|
51
51
|
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined);
|
|
52
52
|
}
|
|
53
53
|
async scheduleVideoChat(chatId, startAt, params) {
|
|
54
|
-
|
|
54
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("scheduleVideoChat");
|
|
55
55
|
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined, startAt);
|
|
56
56
|
}
|
|
57
57
|
async joinVideoChat(id, params, params_) {
|
|
58
|
-
|
|
58
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinVideoChat");
|
|
59
59
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
60
60
|
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").invoke({ _: "phone.joinGroupCall", call, join_as: params_?.joinAs ? await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(params_.joinAs) : { _: "inputPeerSelf" }, params: ({ _: "dataJSON", data: params }), invite_hash: params_?.inviteHash, muted: params_?.audio ? undefined : true, video_stopped: params_?.video ? undefined : true }).then((v) => (0, _2_tl_js_1.as)("updates", v));
|
|
61
61
|
const updateGroupCall = updates
|
|
@@ -65,11 +65,11 @@ class VideoChatManager {
|
|
|
65
65
|
return updateGroupCall.params.data;
|
|
66
66
|
}
|
|
67
67
|
async leaveVideoChat(id) {
|
|
68
|
-
|
|
68
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("leaveVideoChat");
|
|
69
69
|
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").invoke({ _: "phone.leaveGroupCall", call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id), source: 0 });
|
|
70
70
|
}
|
|
71
71
|
async joinLiveStream(id) {
|
|
72
|
-
|
|
72
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinLiveStream");
|
|
73
73
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
74
74
|
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").invoke({
|
|
75
75
|
_: "phone.joinGroupCall",
|
|
@@ -92,7 +92,7 @@ class VideoChatManager {
|
|
|
92
92
|
(0, _0_deps_js_1.unreachable)();
|
|
93
93
|
}
|
|
94
94
|
async getVideoChat(id) {
|
|
95
|
-
|
|
95
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getVideoChat");
|
|
96
96
|
return (0, _3_types_js_1.constructVideoChat)(await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id));
|
|
97
97
|
}
|
|
98
98
|
static canHandleUpdate(update) {
|
|
@@ -126,7 +126,7 @@ class VideoChatManager {
|
|
|
126
126
|
return { videoChat: (0, _3_types_js_1.constructVideoChat)(update.call) };
|
|
127
127
|
}
|
|
128
128
|
async getLiveStreamChannels(id) {
|
|
129
|
-
|
|
129
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getLiveStreamChannels");
|
|
130
130
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
131
131
|
if (!((0, _2_tl_js_1.is)("groupCall", call)) || !call.rtmp_stream) {
|
|
132
132
|
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
@@ -142,7 +142,7 @@ class VideoChatManager {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
async *downloadLiveStreamChunk(id, channel, scale, timestamp, params) {
|
|
145
|
-
|
|
145
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("downloadLiveStreamChunk");
|
|
146
146
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
147
147
|
if (!((0, _2_tl_js_1.is)("groupCall", call)) || !call.rtmp_stream) {
|
|
148
148
|
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
@@ -158,7 +158,7 @@ class VideoChatManager {
|
|
|
158
158
|
throw new _0_errors_js_1.InputError("Got invalid quality.");
|
|
159
159
|
})(),
|
|
160
160
|
};
|
|
161
|
-
yield* __classPrivateFieldGet(this, _VideoChatManager_c, "f").fileManager.downloadInner(location, call.stream_dc_id ?? (0, _0_deps_js_1.unreachable)());
|
|
161
|
+
yield* __classPrivateFieldGet(this, _VideoChatManager_c, "f").fileManager.downloadInner(location, call.stream_dc_id ?? (0, _0_deps_js_1.unreachable)(), params);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
exports.VideoChatManager = VideoChatManager;
|
|
@@ -47,12 +47,12 @@ class CallbackQueryManager {
|
|
|
47
47
|
__classPrivateFieldSet(this, _CallbackQueryManager_c, c, "f");
|
|
48
48
|
}
|
|
49
49
|
async answerCallbackQuery(id, params) {
|
|
50
|
-
|
|
50
|
+
__classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertBot("answerCallbackQuery");
|
|
51
51
|
(0, _0_utilities_js_1.checkCallbackQueryId)(id);
|
|
52
52
|
await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").invoke({ _: "messages.setBotCallbackAnswer", query_id: BigInt(id), cache_time: params?.cacheTime ?? 0, message: params?.text, alert: params?.alert ? true : undefined });
|
|
53
53
|
}
|
|
54
54
|
async sendCallbackQuery(chatId, messageId, question) {
|
|
55
|
-
|
|
55
|
+
__classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertUser("sendCallbackQuery");
|
|
56
56
|
(0, _0_utilities_js_1.checkMessageId)(messageId);
|
|
57
57
|
(0, _3_types_js_1.validateCallbackQueryQuestion)(question);
|
|
58
58
|
const peer = await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getInputPeer(chatId), peerId = (0, _2_tl_js_1.peerToChatId)(peer), questionKey = JSON.stringify(question);
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Api } from "../2_tl.js";
|
|
21
21
|
import { ChatListItem, ChatMember, ID } from "../3_types.js";
|
|
22
|
+
import { GetChatMembersParams } from "./0_params.js";
|
|
22
23
|
import { C as C_ } from "./1_types.js";
|
|
23
24
|
import { FileManager } from "./2_file_manager.js";
|
|
24
25
|
import { MessageManager } from "./3_message_manager.js";
|
|
@@ -37,6 +38,8 @@ export declare class ChatListManager {
|
|
|
37
38
|
handleUpdate(update: ChatListManagerUpdate): Promise<void>;
|
|
38
39
|
getChat(chatId: ID): Promise<import("../3_types.js").Chat>;
|
|
39
40
|
getChatAdministrators(chatId: ID): Promise<ChatMember[]>;
|
|
41
|
+
getChatMember(chatId: ID, userId: ID): Promise<ChatMember>;
|
|
42
|
+
getChatMembers(chatId: ID, params?: GetChatMembersParams): Promise<ChatMember[]>;
|
|
40
43
|
}
|
|
41
44
|
export {};
|
|
42
45
|
//# sourceMappingURL=4_chat_list_manager.d.ts.map
|