@mtkruto/node 0.2.44 → 0.2.50
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 +1 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +1 -0
- 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 +7 -13
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_storage_operations.d.ts +3 -2
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +11 -4
- package/esm/client/2_account_manager.js +5 -5
- package/esm/client/2_bot_info_manager.js +8 -8
- 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 -1
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +111 -19
- package/esm/client/3_video_chat_manager.js +8 -8
- package/esm/client/4_callback_query_manager.js +2 -2
- package/esm/client/4_chat_list_manager.js +1 -1
- 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 +33 -1
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +43 -3
- 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/3_types.d.ts +1 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +1 -0
- 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 +7 -13
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_storage_operations.d.ts +3 -2
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +11 -4
- package/script/client/2_account_manager.js +5 -5
- package/script/client/2_bot_info_manager.js +8 -8
- 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 -1
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +111 -19
- package/script/client/3_video_chat_manager.js +8 -8
- package/script/client/4_callback_query_manager.js +2 -2
- package/script/client/4_chat_list_manager.js +1 -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 +33 -1
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +43 -3
- 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,7 +1001,7 @@ 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.");
|
|
@@ -967,6 +1033,7 @@ class MessageManager {
|
|
|
967
1033
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
968
1034
|
}
|
|
969
1035
|
async stopPoll(chatId, messageId, params) {
|
|
1036
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
970
1037
|
const message = await this.getMessage(chatId, messageId);
|
|
971
1038
|
if (!message) {
|
|
972
1039
|
throw new _0_errors_js_1.InputError("Message not found.");
|
|
@@ -982,6 +1049,7 @@ class MessageManager {
|
|
|
982
1049
|
return (0, _3_types_js_2.assertMessageType)(message_, "poll").poll;
|
|
983
1050
|
}
|
|
984
1051
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
1052
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
985
1053
|
const message = await this.getMessage(chatId, messageId);
|
|
986
1054
|
if (message && "location" in message && message.location.livePeriod) {
|
|
987
1055
|
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 +1059,14 @@ class MessageManager {
|
|
|
991
1059
|
(0, _0_deps_js_1.unreachable)();
|
|
992
1060
|
}
|
|
993
1061
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
994
|
-
|
|
1062
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1063
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
|
|
995
1064
|
const id = (0, _3_types_js_2.deserializeInlineMessageId)(inlineMessageId);
|
|
996
1065
|
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
1066
|
}
|
|
998
1067
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1068
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("sendInvoice");
|
|
1069
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
999
1070
|
if (title.length < 1) {
|
|
1000
1071
|
throw new _0_errors_js_1.InputError("Invoice title cannot be empty.");
|
|
1001
1072
|
}
|
|
@@ -1048,6 +1119,7 @@ class MessageManager {
|
|
|
1048
1119
|
return (0, _3_types_js_2.assertMessageType)(message, "invoice");
|
|
1049
1120
|
}
|
|
1050
1121
|
async addChatMember(chatId, userId, params) {
|
|
1122
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMember");
|
|
1051
1123
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1052
1124
|
if ((0, _2_tl_js_1.isOneOf)(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1053
1125
|
throw new _0_errors_js_1.InputError("Cannot add members to private chats");
|
|
@@ -1064,6 +1136,7 @@ class MessageManager {
|
|
|
1064
1136
|
(0, _0_deps_js_1.unreachable)();
|
|
1065
1137
|
}
|
|
1066
1138
|
async addChatMembers(chatId, userIds) {
|
|
1139
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMembers");
|
|
1067
1140
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1068
1141
|
if ((0, _2_tl_js_1.isOneOf)(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1069
1142
|
throw new _0_errors_js_1.InputError("Cannot add members to private chats");
|
|
@@ -1082,6 +1155,7 @@ class MessageManager {
|
|
|
1082
1155
|
(0, _0_deps_js_1.unreachable)();
|
|
1083
1156
|
}
|
|
1084
1157
|
async sendMediaGroup(chatId, media, params) {
|
|
1158
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1085
1159
|
{
|
|
1086
1160
|
if (!Array.isArray(media) || !media.length) {
|
|
1087
1161
|
throw new _0_errors_js_1.InputError("Media group must not be empty.");
|
|
@@ -1139,15 +1213,32 @@ class MessageManager {
|
|
|
1139
1213
|
}
|
|
1140
1214
|
}
|
|
1141
1215
|
exports.MessageManager = MessageManager;
|
|
1142
|
-
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(),
|
|
1216
|
+
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
|
|
1217
|
+
if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
|
|
1218
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1219
|
+
}
|
|
1220
|
+
if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
|
|
1221
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
|
|
1222
|
+
}
|
|
1223
|
+
if (params && "sendAs" in params && params.sendAs !== undefined) {
|
|
1224
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1225
|
+
}
|
|
1226
|
+
if (params && "sendAt" in params && params.sendAt !== undefined) {
|
|
1227
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
|
|
1228
|
+
}
|
|
1229
|
+
}, _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates, businessConnectionId) {
|
|
1143
1230
|
const messages = new Array();
|
|
1144
1231
|
if ((0, _2_tl_js_1.is)("updates", updates)) {
|
|
1145
1232
|
for (const update of updates.updates) {
|
|
1146
1233
|
if ("message" in update && (0, _2_tl_js_1.is)("messageEmpty", update.message)) {
|
|
1147
1234
|
continue;
|
|
1148
1235
|
}
|
|
1149
|
-
if ((0, _2_tl_js_1.is)("updateNewMessage", update) || (0, _2_tl_js_1.is)("updateEditMessage", update)) {
|
|
1150
|
-
|
|
1236
|
+
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)) {
|
|
1237
|
+
const message = await this.constructMessage(update.message);
|
|
1238
|
+
if ((0, _2_tl_js_1.is)("updateNewScheduledMessage", update)) {
|
|
1239
|
+
message.scheduled = true;
|
|
1240
|
+
}
|
|
1241
|
+
messages.push(message);
|
|
1151
1242
|
}
|
|
1152
1243
|
else if ((0, _2_tl_js_1.is)("updateNewChannelMessage", update) || (0, _2_tl_js_1.is)("updateEditChannelMessage", update)) {
|
|
1153
1244
|
messages.push(await this.constructMessage(update.message));
|
|
@@ -1169,13 +1260,13 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1169
1260
|
return messages;
|
|
1170
1261
|
}, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
|
|
1171
1262
|
if (params?.replyMarkup) {
|
|
1172
|
-
|
|
1173
|
-
return (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1263
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1264
|
+
return await (0, _3_types_js_2.replyMarkupToTlObject)(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1174
1265
|
}
|
|
1175
1266
|
}, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
|
|
1176
1267
|
const sendAs = params?.sendAs;
|
|
1177
1268
|
if (sendAs !== undefined) {
|
|
1178
|
-
|
|
1269
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1179
1270
|
return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
|
|
1180
1271
|
}
|
|
1181
1272
|
}, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
|
|
@@ -1259,6 +1350,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1259
1350
|
message: caption ?? "",
|
|
1260
1351
|
entities: captionEntities,
|
|
1261
1352
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
1353
|
+
schedule_date: params?.sendAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.sendAt) : undefined,
|
|
1262
1354
|
}, params?.businessConnectionId);
|
|
1263
1355
|
return (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
1264
1356
|
}, _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.");
|
|
@@ -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);
|
|
@@ -127,7 +127,7 @@ class ChatListManager {
|
|
|
127
127
|
return () => Promise.resolve();
|
|
128
128
|
}
|
|
129
129
|
async getChats(from = "main", after, limit = 100) {
|
|
130
|
-
|
|
130
|
+
__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("getChats");
|
|
131
131
|
if (!__classPrivateFieldGet(this, _ChatListManager_chatsLoadedFromStorage, "f")) {
|
|
132
132
|
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadChatsFromStorage).call(this);
|
|
133
133
|
}
|
|
@@ -46,7 +46,7 @@ class InlineQueryManager {
|
|
|
46
46
|
__classPrivateFieldSet(this, _InlineQueryManager_c, c, "f");
|
|
47
47
|
}
|
|
48
48
|
async answerInlineQuery(id, results, params) {
|
|
49
|
-
|
|
49
|
+
__classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertBot("answerInlineQuery");
|
|
50
50
|
(0, _0_utilities_js_1.checkInlineQueryId)(id);
|
|
51
51
|
await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").invoke({ _: "messages.setInlineBotResults", query_id: BigInt(id), results: await Promise.all(results.map((v) => (0, _3_types_js_1.inlineQueryResultToTlObject)(v, __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.parseText.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager), __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager.usernameResolver.bind(__classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageManager)))), cache_time: params?.cacheTime ?? 300, private: params?.isPersonal ? true : undefined, switch_webview: params?.button && params.button.miniApp ? ({ _: "inlineBotWebView", text: params.button.text, url: params.button.miniApp.url }) : undefined, switch_pm: params?.button && params.button.startParameter ? ({ _: "inlineBotSwitchPM", text: params.button.text, start_param: params.button.startParameter }) : undefined, gallery: params?.isGallery ? true : undefined, next_offset: params?.nextOffset });
|
|
52
52
|
}
|
|
@@ -65,7 +65,7 @@ class InlineQueryManager {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
async sendInlineQuery(userId, chatId, params) {
|
|
68
|
-
|
|
68
|
+
__classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertUser("sendInlineQuery");
|
|
69
69
|
const bot = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").getInputUser(userId), peer = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").getInputPeer(chatId), query = params?.query ?? "", offset = params?.offset ?? "";
|
|
70
70
|
const botId = (0, _2_tl_js_1.peerToChatId)(bot), peerId = (0, _2_tl_js_1.peerToChatId)(peer);
|
|
71
71
|
const maybeResults = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageStorage.getInlineQueryAnswer(botId, peerId, query, offset);
|