@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
|
@@ -28,7 +28,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
28
28
|
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");
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
|
-
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;
|
|
31
|
+
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;
|
|
32
32
|
import { contentType, unreachable } from "../0_deps.js";
|
|
33
33
|
import { InputError } from "../0_errors.js";
|
|
34
34
|
import { getLogger, getRandomId, toUnixTimestamp } from "../1_utilities.js";
|
|
@@ -47,12 +47,14 @@ const messageManagerUpdates = [
|
|
|
47
47
|
"updateNewMessage",
|
|
48
48
|
"updateNewChannelMessage",
|
|
49
49
|
"updateEditMessage",
|
|
50
|
+
"updateNewScheduledMessage",
|
|
50
51
|
"updateEditChannelMessage",
|
|
51
52
|
"updateBotNewBusinessMessage",
|
|
52
53
|
"updateBotEditBusinessMessage",
|
|
53
54
|
"updateBotDeleteBusinessMessage",
|
|
54
55
|
"updateDeleteMessages",
|
|
55
56
|
"updateDeleteChannelMessages",
|
|
57
|
+
"updateDeleteScheduledMessages",
|
|
56
58
|
"updateChannelParticipant",
|
|
57
59
|
"updateChatParticipant",
|
|
58
60
|
"updateBotChatInviteRequester",
|
|
@@ -172,7 +174,7 @@ export class MessageManager {
|
|
|
172
174
|
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, to, result);
|
|
173
175
|
}
|
|
174
176
|
async getHistory(chatId, params) {
|
|
175
|
-
|
|
177
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
|
|
176
178
|
let limit = params?.limit ?? 100;
|
|
177
179
|
if (limit <= 0) {
|
|
178
180
|
limit = 1;
|
|
@@ -200,6 +202,7 @@ export class MessageManager {
|
|
|
200
202
|
return messages;
|
|
201
203
|
}
|
|
202
204
|
async sendMessage(chatId, text, params) {
|
|
205
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
203
206
|
const [message, entities] = await this.parseText(text, params);
|
|
204
207
|
const replyMarkup = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params);
|
|
205
208
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
@@ -210,6 +213,7 @@ export class MessageManager {
|
|
|
210
213
|
const noforwards = params?.protectContent ? true : undefined;
|
|
211
214
|
const sendAs = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_resolveSendAs).call(this, params);
|
|
212
215
|
const effect = params?.effectId ? BigInt(params.effectId) : undefined;
|
|
216
|
+
const schedule_date = params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined;
|
|
213
217
|
let result;
|
|
214
218
|
if (!noWebpage && params?.linkPreview?.url) {
|
|
215
219
|
result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
@@ -232,6 +236,7 @@ export class MessageManager {
|
|
|
232
236
|
entities,
|
|
233
237
|
reply_markup: replyMarkup,
|
|
234
238
|
effect,
|
|
239
|
+
schedule_date,
|
|
235
240
|
}, params?.businessConnectionId);
|
|
236
241
|
}
|
|
237
242
|
else {
|
|
@@ -249,12 +254,14 @@ export class MessageManager {
|
|
|
249
254
|
entities,
|
|
250
255
|
reply_markup: replyMarkup,
|
|
251
256
|
effect,
|
|
257
|
+
schedule_date,
|
|
252
258
|
}, params?.businessConnectionId);
|
|
253
259
|
}
|
|
254
260
|
const message_ = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
255
261
|
return assertMessageType(message_, "text");
|
|
256
262
|
}
|
|
257
263
|
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
264
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
258
265
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
259
266
|
const randomId = getRandomId();
|
|
260
267
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -285,11 +292,13 @@ export class MessageManager {
|
|
|
285
292
|
}),
|
|
286
293
|
message: "",
|
|
287
294
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
295
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
288
296
|
}, params?.businessConnectionId);
|
|
289
297
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
290
298
|
return assertMessageType(message, "venue");
|
|
291
299
|
}
|
|
292
300
|
async sendContact(chatId, firstName, number, params) {
|
|
301
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
293
302
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
294
303
|
const randomId = getRandomId();
|
|
295
304
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -314,11 +323,13 @@ export class MessageManager {
|
|
|
314
323
|
}),
|
|
315
324
|
message: "",
|
|
316
325
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
326
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
317
327
|
}, params?.businessConnectionId);
|
|
318
328
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
319
329
|
return assertMessageType(message, "contact");
|
|
320
330
|
}
|
|
321
331
|
async sendDice(chatId, params) {
|
|
332
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
322
333
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
323
334
|
const randomId = getRandomId();
|
|
324
335
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -340,11 +351,13 @@ export class MessageManager {
|
|
|
340
351
|
}),
|
|
341
352
|
message: "",
|
|
342
353
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
354
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
343
355
|
}, params?.businessConnectionId);
|
|
344
356
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
345
357
|
return assertMessageType(message, "dice");
|
|
346
358
|
}
|
|
347
359
|
async sendLocation(chatId, latitude, longitude, params) {
|
|
360
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
348
361
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
349
362
|
const randomId = getRandomId();
|
|
350
363
|
const silent = params?.disableNotification ? true : undefined;
|
|
@@ -384,29 +397,34 @@ export class MessageManager {
|
|
|
384
397
|
}),
|
|
385
398
|
message: "",
|
|
386
399
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
400
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
387
401
|
}, params?.businessConnectionId);
|
|
388
402
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
389
403
|
return assertMessageType(message, "location");
|
|
390
404
|
}
|
|
391
405
|
async sendVideoNote(chatId, audio, params) {
|
|
406
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
392
407
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.VideoNote, [
|
|
393
408
|
{ _: "documentAttributeVideo", round_message: true, w: params?.length ?? 0, h: params?.length ?? 0, duration: params?.duration ?? 0 },
|
|
394
409
|
], false);
|
|
395
410
|
return assertMessageType(message, "videoNote");
|
|
396
411
|
}
|
|
397
412
|
async sendAudio(chatId, audio, params) {
|
|
413
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
398
414
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, audio, params, FileType.Audio, [
|
|
399
415
|
{ _: "documentAttributeAudio", duration: params?.duration ?? 0, performer: params?.performer, title: params?.title },
|
|
400
416
|
]);
|
|
401
417
|
return assertMessageType(message, "audio");
|
|
402
418
|
}
|
|
403
419
|
async sendVoice(chatId, voice, params) {
|
|
420
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
404
421
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, FileType.VoiceNote, [
|
|
405
422
|
{ _: "documentAttributeAudio", voice: true, duration: params?.duration ?? 0 },
|
|
406
423
|
]);
|
|
407
424
|
return assertMessageType(message, "voice");
|
|
408
425
|
}
|
|
409
426
|
async sendAnimation(chatId, animation, params) {
|
|
427
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
410
428
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, animation, params, FileType.Animation, [
|
|
411
429
|
{ _: "documentAttributeAnimated" },
|
|
412
430
|
{ _: "documentAttributeVideo", supports_streaming: true, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
@@ -414,20 +432,24 @@ export class MessageManager {
|
|
|
414
432
|
return assertMessageType(message, "animation");
|
|
415
433
|
}
|
|
416
434
|
async sendVideo(chatId, video, params) {
|
|
435
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
417
436
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, video, params, FileType.Video, [
|
|
418
437
|
{ _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
|
|
419
438
|
]);
|
|
420
439
|
return assertMessageType(message, "video");
|
|
421
440
|
}
|
|
422
441
|
async sendDocument(chatId, document, params) {
|
|
442
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
423
443
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, document, params, FileType.Document, []);
|
|
424
444
|
return assertMessageType(message, "document");
|
|
425
445
|
}
|
|
426
446
|
async sendSticker(chatId, sticker, params) {
|
|
447
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
427
448
|
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, sticker, params, FileType.Sticker, [{ _: "documentAttributeSticker", alt: params?.emoji || "", stickerset: { _: "inputStickerSetEmpty" } }], undefined, STICKER_MIME_TYPES);
|
|
428
449
|
return assertMessageType(message, "sticker");
|
|
429
450
|
}
|
|
430
451
|
async sendPhoto(chatId, photo, params) {
|
|
452
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
431
453
|
let media = null;
|
|
432
454
|
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
433
455
|
const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
|
|
@@ -471,6 +493,7 @@ export class MessageManager {
|
|
|
471
493
|
return null;
|
|
472
494
|
}
|
|
473
495
|
async sendPoll(chatId, question, options, params) {
|
|
496
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
474
497
|
question = question?.trim();
|
|
475
498
|
if (!question) {
|
|
476
499
|
throw new Error("Question must not be empty.");
|
|
@@ -509,11 +532,13 @@ export class MessageManager {
|
|
|
509
532
|
media,
|
|
510
533
|
message: "",
|
|
511
534
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
535
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
512
536
|
}, params?.businessConnectionId);
|
|
513
537
|
const message = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
514
538
|
return assertMessageType(message, "poll");
|
|
515
539
|
}
|
|
516
540
|
async editMessageReplyMarkup(chatId, messageId, params) {
|
|
541
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
517
542
|
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editMessage", id: checkMessageId(messageId), peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
518
543
|
const message_ = (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result))[0];
|
|
519
544
|
return message_;
|
|
@@ -523,6 +548,7 @@ export class MessageManager {
|
|
|
523
548
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.editInlineBotMessage", id, reply_markup: await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_constructReplyMarkup).call(this, params) });
|
|
524
549
|
}
|
|
525
550
|
async editMessageText(chatId, messageId, text, params) {
|
|
551
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
526
552
|
const [message, entities] = await this.parseText(text, params);
|
|
527
553
|
const noWebpage = params?.linkPreview?.disable ? true : undefined;
|
|
528
554
|
const invertMedia = params?.linkPreview?.aboveText ? true : undefined;
|
|
@@ -535,6 +561,7 @@ export class MessageManager {
|
|
|
535
561
|
return assertMessageType(message_, "text");
|
|
536
562
|
}
|
|
537
563
|
async editInlineMessageText(inlineMessageId, text, params) {
|
|
564
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
538
565
|
const [message, entities] = await this.parseText(text, params);
|
|
539
566
|
const id = deserializeInlineMessageId(inlineMessageId);
|
|
540
567
|
const noWebpage = params?.linkPreview?.disable ? true : undefined;
|
|
@@ -546,6 +573,7 @@ export class MessageManager {
|
|
|
546
573
|
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) });
|
|
547
574
|
}
|
|
548
575
|
async editMessageMedia(chatId, messageId, media, params) {
|
|
576
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
549
577
|
const message = await this.getMessage(chatId, messageId);
|
|
550
578
|
if (!message) {
|
|
551
579
|
throw new InputError("Message not found.");
|
|
@@ -567,7 +595,8 @@ export class MessageManager {
|
|
|
567
595
|
return message_;
|
|
568
596
|
}
|
|
569
597
|
async editInlineMessageMedia(inlineMessageId, media, params) {
|
|
570
|
-
|
|
598
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
599
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageMedia");
|
|
571
600
|
const id = deserializeInlineMessageId(inlineMessageId);
|
|
572
601
|
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) });
|
|
573
602
|
}
|
|
@@ -581,15 +610,39 @@ export class MessageManager {
|
|
|
581
610
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
|
|
582
611
|
}
|
|
583
612
|
}
|
|
613
|
+
async deleteScheduledMessages(chatId, messageIds) {
|
|
614
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
|
|
615
|
+
checkArray(messageIds, checkMessageId);
|
|
616
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
617
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.deleteScheduledMessages", peer, id: messageIds });
|
|
618
|
+
}
|
|
619
|
+
async deleteScheduledMessage(chatId, messageId) {
|
|
620
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteScheduledMessage");
|
|
621
|
+
return await this.deleteScheduledMessages(chatId, [messageId]);
|
|
622
|
+
}
|
|
623
|
+
async sendScheduledMessages(chatId, messageIds) {
|
|
624
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessages");
|
|
625
|
+
checkArray(messageIds, checkMessageId);
|
|
626
|
+
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
627
|
+
const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.sendScheduledMessages", peer, id: messageIds });
|
|
628
|
+
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result);
|
|
629
|
+
}
|
|
630
|
+
async sendScheduledMessage(chatId, messageId) {
|
|
631
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendScheduledMessage");
|
|
632
|
+
return (await this.sendScheduledMessages(chatId, [messageId]))[0];
|
|
633
|
+
}
|
|
584
634
|
async deleteChatMemberMessages(chatId, memberId) {
|
|
635
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("deleteChatMemberMessages");
|
|
585
636
|
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
|
|
586
637
|
const participant = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(memberId);
|
|
587
638
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.deleteParticipantHistory", channel, participant });
|
|
588
639
|
}
|
|
589
640
|
async pinMessage(chatId, messageId, params) {
|
|
641
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
590
642
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.disableNotification ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
|
|
591
643
|
}
|
|
592
644
|
async unpinMessage(chatId, messageId, params) {
|
|
645
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
593
646
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "messages.updatePinnedMessage", peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId), id: checkMessageId(messageId), unpin: true }, params?.businessConnectionId);
|
|
594
647
|
}
|
|
595
648
|
async unpinMessages(chatId) {
|
|
@@ -644,7 +697,8 @@ export class MessageManager {
|
|
|
644
697
|
is("updateEditMessage", update) ||
|
|
645
698
|
is("updateEditChannelMessage", update) ||
|
|
646
699
|
is("updateBotNewBusinessMessage", update) ||
|
|
647
|
-
is("updateBotEditBusinessMessage", update)
|
|
700
|
+
is("updateBotEditBusinessMessage", update) ||
|
|
701
|
+
is("updateNewScheduledMessage", update)) {
|
|
648
702
|
if (!(is("messageEmpty", update.message))) {
|
|
649
703
|
const isOutgoing = update.message.out;
|
|
650
704
|
let shouldIgnore = isOutgoing ? (await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.getAccountType()) == "user" ? false : true : false;
|
|
@@ -657,6 +711,10 @@ export class MessageManager {
|
|
|
657
711
|
if (is("updateNewMessage", update) || is("updateNewChannelMessage", update) || is("updateBotNewBusinessMessage", update)) {
|
|
658
712
|
return { message };
|
|
659
713
|
}
|
|
714
|
+
else if (is("updateNewScheduledMessage", update)) {
|
|
715
|
+
message.scheduled = true;
|
|
716
|
+
return { scheduledMessage: message };
|
|
717
|
+
}
|
|
660
718
|
else {
|
|
661
719
|
return { editedMessage: message };
|
|
662
720
|
}
|
|
@@ -686,6 +744,11 @@ export class MessageManager {
|
|
|
686
744
|
}
|
|
687
745
|
return { deletedMessages };
|
|
688
746
|
}
|
|
747
|
+
else if (is("updateDeleteScheduledMessages", update)) {
|
|
748
|
+
const chatId = peerToChatId(update.peer);
|
|
749
|
+
const deletedMessages = update.messages.map((v) => ({ chatId, messageId: v }));
|
|
750
|
+
return { deletedMessages, scheduled: true };
|
|
751
|
+
}
|
|
689
752
|
else if (is("updateBotDeleteBusinessMessage", update)) {
|
|
690
753
|
const chatId = peerToChatId(update.peer);
|
|
691
754
|
const deletedMessages = update.messages.map((v) => ({ chatId, messageId: v }));
|
|
@@ -708,6 +771,7 @@ export class MessageManager {
|
|
|
708
771
|
return null;
|
|
709
772
|
}
|
|
710
773
|
async sendChatAction(chatId, action, params) {
|
|
774
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
711
775
|
let action_;
|
|
712
776
|
switch (action) {
|
|
713
777
|
case "type":
|
|
@@ -825,11 +889,11 @@ export class MessageManager {
|
|
|
825
889
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.editBanned", channel, participant: member, banned_rights: chatMemberRightsToTlObject(params?.rights, params?.untilDate) });
|
|
826
890
|
}
|
|
827
891
|
async enableJoinRequests(chatId) {
|
|
828
|
-
|
|
892
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("enableJoinRequests");
|
|
829
893
|
await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, true);
|
|
830
894
|
}
|
|
831
895
|
async disableJoinRequests(chatId) {
|
|
832
|
-
|
|
896
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("disableJoinRequests");
|
|
833
897
|
await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, false);
|
|
834
898
|
}
|
|
835
899
|
async approveJoinRequest(chatId, userId) {
|
|
@@ -848,7 +912,7 @@ export class MessageManager {
|
|
|
848
912
|
});
|
|
849
913
|
}
|
|
850
914
|
async approveJoinRequests(chatId, params) {
|
|
851
|
-
|
|
915
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("approveJoinRequests");
|
|
852
916
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
853
917
|
_: "messages.hideAllChatJoinRequests",
|
|
854
918
|
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
|
|
@@ -857,7 +921,7 @@ export class MessageManager {
|
|
|
857
921
|
});
|
|
858
922
|
}
|
|
859
923
|
async declineJoinRequests(chatId, params) {
|
|
860
|
-
|
|
924
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("declineJoinRequests");
|
|
861
925
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({
|
|
862
926
|
_: "messages.hideAllChatJoinRequests",
|
|
863
927
|
peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
|
|
@@ -865,6 +929,7 @@ export class MessageManager {
|
|
|
865
929
|
});
|
|
866
930
|
}
|
|
867
931
|
async searchMessages(chatId, query, params) {
|
|
932
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("searchMessages");
|
|
868
933
|
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: 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 });
|
|
869
934
|
if (!("messages" in result)) {
|
|
870
935
|
unreachable();
|
|
@@ -877,6 +942,7 @@ export class MessageManager {
|
|
|
877
942
|
return messages;
|
|
878
943
|
}
|
|
879
944
|
async setBoostsRequiredToCircumventRestrictions(chatId, boosts) {
|
|
945
|
+
await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("setBoostsRequiredToCircumventRestrictions");
|
|
880
946
|
const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
|
|
881
947
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setBoostsToUnblockRestrictions", channel, boosts });
|
|
882
948
|
}
|
|
@@ -888,12 +954,12 @@ export class MessageManager {
|
|
|
888
954
|
return await constructInviteLink(as("chatInviteExported", result), __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
|
|
889
955
|
}
|
|
890
956
|
async getCreatedInviteLinks(chatId, params) {
|
|
891
|
-
|
|
957
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getCreatedInviteLinks");
|
|
892
958
|
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 ? toUnixTimestamp(params.afterDate) : undefined, offset_link: params?.afterInviteLink });
|
|
893
959
|
return await Promise.all(invites.map((v) => as("chatInviteExported", v)).map((v) => constructInviteLink(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)));
|
|
894
960
|
}
|
|
895
961
|
async joinChat(chatId) {
|
|
896
|
-
|
|
962
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("joinChat");
|
|
897
963
|
const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
898
964
|
if (is("inputPeerUser", peer)) {
|
|
899
965
|
throw new InputError("Cannot join private chats.");
|
|
@@ -924,7 +990,7 @@ export class MessageManager {
|
|
|
924
990
|
}
|
|
925
991
|
}
|
|
926
992
|
async blockUser(userId) {
|
|
927
|
-
|
|
993
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
|
|
928
994
|
const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
|
|
929
995
|
if (!(is("user", id))) {
|
|
930
996
|
throw new InputError("Only users can be blocked or unblocked.");
|
|
@@ -932,7 +998,7 @@ export class MessageManager {
|
|
|
932
998
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "contacts.block", id });
|
|
933
999
|
}
|
|
934
1000
|
async unblockUser(userId) {
|
|
935
|
-
|
|
1001
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
|
|
936
1002
|
const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
|
|
937
1003
|
if (!(is("user", id))) {
|
|
938
1004
|
throw new InputError("Only users can be blocked or unblocked.");
|
|
@@ -964,6 +1030,7 @@ export class MessageManager {
|
|
|
964
1030
|
await __classPrivateFieldGet(this, _MessageManager_c, "f").invoke({ _: "channels.setStickers", channel, stickerset: { _: "inputStickerSetEmpty" } });
|
|
965
1031
|
}
|
|
966
1032
|
async stopPoll(chatId, messageId, params) {
|
|
1033
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
967
1034
|
const message = await this.getMessage(chatId, messageId);
|
|
968
1035
|
if (!message) {
|
|
969
1036
|
throw new InputError("Message not found.");
|
|
@@ -979,6 +1046,7 @@ export class MessageManager {
|
|
|
979
1046
|
return assertMessageType(message_, "poll").poll;
|
|
980
1047
|
}
|
|
981
1048
|
async editMessageLiveLocation(chatId, messageId, latitude, longitude, params) {
|
|
1049
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
982
1050
|
const message = await this.getMessage(chatId, messageId);
|
|
983
1051
|
if (message && "location" in message && message.location.livePeriod) {
|
|
984
1052
|
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) });
|
|
@@ -988,11 +1056,14 @@ export class MessageManager {
|
|
|
988
1056
|
unreachable();
|
|
989
1057
|
}
|
|
990
1058
|
async editInlineMessageLiveLocation(inlineMessageId, latitude, longitude, params) {
|
|
991
|
-
|
|
1059
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1060
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("editInlineMessageLiveLocation");
|
|
992
1061
|
const id = deserializeInlineMessageId(inlineMessageId);
|
|
993
1062
|
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) });
|
|
994
1063
|
}
|
|
995
1064
|
async sendInvoice(chatId, title, description, payload, currency, prices, params) {
|
|
1065
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("sendInvoice");
|
|
1066
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
996
1067
|
if (title.length < 1) {
|
|
997
1068
|
throw new InputError("Invoice title cannot be empty.");
|
|
998
1069
|
}
|
|
@@ -1045,6 +1116,7 @@ export class MessageManager {
|
|
|
1045
1116
|
return assertMessageType(message, "invoice");
|
|
1046
1117
|
}
|
|
1047
1118
|
async addChatMember(chatId, userId, params) {
|
|
1119
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMember");
|
|
1048
1120
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1049
1121
|
if (isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1050
1122
|
throw new InputError("Cannot add members to private chats");
|
|
@@ -1061,6 +1133,7 @@ export class MessageManager {
|
|
|
1061
1133
|
unreachable();
|
|
1062
1134
|
}
|
|
1063
1135
|
async addChatMembers(chatId, userIds) {
|
|
1136
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("addChatMembers");
|
|
1064
1137
|
const chat = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
|
|
1065
1138
|
if (isOneOf(["inputPeerEmpty", "inputPeerSelf", "inputPeerUser", "inputPeerUserFromMessage"], chat)) {
|
|
1066
1139
|
throw new InputError("Cannot add members to private chats");
|
|
@@ -1079,6 +1152,7 @@ export class MessageManager {
|
|
|
1079
1152
|
unreachable();
|
|
1080
1153
|
}
|
|
1081
1154
|
async sendMediaGroup(chatId, media, params) {
|
|
1155
|
+
__classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_checkParams).call(this, params);
|
|
1082
1156
|
{
|
|
1083
1157
|
if (!Array.isArray(media) || !media.length) {
|
|
1084
1158
|
throw new InputError("Media group must not be empty.");
|
|
@@ -1135,15 +1209,32 @@ export class MessageManager {
|
|
|
1135
1209
|
return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result);
|
|
1136
1210
|
}
|
|
1137
1211
|
}
|
|
1138
|
-
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(),
|
|
1212
|
+
_MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_checkParams = function _MessageManager_checkParams(params) {
|
|
1213
|
+
if (params && "replyMarkup" in params && params.replyMarkup !== undefined) {
|
|
1214
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1215
|
+
}
|
|
1216
|
+
if (params && "businessConnectionId" in params && params.businessConnectionId !== undefined) {
|
|
1217
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("businessConnectionId");
|
|
1218
|
+
}
|
|
1219
|
+
if (params && "sendAs" in params && params.sendAs !== undefined) {
|
|
1220
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1221
|
+
}
|
|
1222
|
+
if (params && "sendAt" in params && params.sendAt !== undefined) {
|
|
1223
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("businessConsendAtnectionId");
|
|
1224
|
+
}
|
|
1225
|
+
}, _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates, businessConnectionId) {
|
|
1139
1226
|
const messages = new Array();
|
|
1140
1227
|
if (is("updates", updates)) {
|
|
1141
1228
|
for (const update of updates.updates) {
|
|
1142
1229
|
if ("message" in update && is("messageEmpty", update.message)) {
|
|
1143
1230
|
continue;
|
|
1144
1231
|
}
|
|
1145
|
-
if (is("updateNewMessage", update) || is("updateEditMessage", update)) {
|
|
1146
|
-
|
|
1232
|
+
if (is("updateNewMessage", update) || is("updateEditMessage", update) || is("updateNewScheduledMessage", update)) {
|
|
1233
|
+
const message = await this.constructMessage(update.message);
|
|
1234
|
+
if (is("updateNewScheduledMessage", update)) {
|
|
1235
|
+
message.scheduled = true;
|
|
1236
|
+
}
|
|
1237
|
+
messages.push(message);
|
|
1147
1238
|
}
|
|
1148
1239
|
else if (is("updateNewChannelMessage", update) || is("updateEditChannelMessage", update)) {
|
|
1149
1240
|
messages.push(await this.constructMessage(update.message));
|
|
@@ -1165,13 +1256,13 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1165
1256
|
return messages;
|
|
1166
1257
|
}, _MessageManager_constructReplyMarkup = async function _MessageManager_constructReplyMarkup(params) {
|
|
1167
1258
|
if (params?.replyMarkup) {
|
|
1168
|
-
|
|
1169
|
-
return replyMarkupToTlObject(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1259
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertBot("replyMarkup");
|
|
1260
|
+
return await replyMarkupToTlObject(params.replyMarkup, this.usernameResolver.bind(this));
|
|
1170
1261
|
}
|
|
1171
1262
|
}, _MessageManager_resolveSendAs = async function _MessageManager_resolveSendAs(params) {
|
|
1172
1263
|
const sendAs = params?.sendAs;
|
|
1173
1264
|
if (sendAs !== undefined) {
|
|
1174
|
-
|
|
1265
|
+
__classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("sendAs");
|
|
1175
1266
|
return sendAs ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(sendAs) : undefined;
|
|
1176
1267
|
}
|
|
1177
1268
|
}, _MessageManager_constructReplyTo = async function _MessageManager_constructReplyTo(params) {
|
|
@@ -1255,6 +1346,7 @@ _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(
|
|
|
1255
1346
|
message: caption ?? "",
|
|
1256
1347
|
entities: captionEntities,
|
|
1257
1348
|
effect: params?.effectId ? BigInt(params.effectId) : undefined,
|
|
1349
|
+
schedule_date: params?.sendAt ? toUnixTimestamp(params.sendAt) : undefined,
|
|
1258
1350
|
}, params?.businessConnectionId);
|
|
1259
1351
|
return (await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, chatId, result, params?.businessConnectionId))[0];
|
|
1260
1352
|
}, _MessageManager_resolveInputMediaInner = async function _MessageManager_resolveInputMediaInner(document, media, fileType, otherAttribs) {
|
|
@@ -44,15 +44,15 @@ export class VideoChatManager {
|
|
|
44
44
|
__classPrivateFieldSet(this, _VideoChatManager_c, c, "f");
|
|
45
45
|
}
|
|
46
46
|
async startVideoChat(chatId, params) {
|
|
47
|
-
|
|
47
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("startVideoChat");
|
|
48
48
|
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined);
|
|
49
49
|
}
|
|
50
50
|
async scheduleVideoChat(chatId, startAt, params) {
|
|
51
|
-
|
|
51
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("scheduleVideoChat");
|
|
52
52
|
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined, startAt);
|
|
53
53
|
}
|
|
54
54
|
async joinVideoChat(id, params, params_) {
|
|
55
|
-
|
|
55
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinVideoChat");
|
|
56
56
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
57
57
|
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) => as("updates", v));
|
|
58
58
|
const updateGroupCall = updates
|
|
@@ -62,11 +62,11 @@ export class VideoChatManager {
|
|
|
62
62
|
return updateGroupCall.params.data;
|
|
63
63
|
}
|
|
64
64
|
async leaveVideoChat(id) {
|
|
65
|
-
|
|
65
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("leaveVideoChat");
|
|
66
66
|
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").invoke({ _: "phone.leaveGroupCall", call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id), source: 0 });
|
|
67
67
|
}
|
|
68
68
|
async joinLiveStream(id) {
|
|
69
|
-
|
|
69
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinLiveStream");
|
|
70
70
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
71
71
|
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").invoke({
|
|
72
72
|
_: "phone.joinGroupCall",
|
|
@@ -89,7 +89,7 @@ export class VideoChatManager {
|
|
|
89
89
|
unreachable();
|
|
90
90
|
}
|
|
91
91
|
async getVideoChat(id) {
|
|
92
|
-
|
|
92
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getVideoChat");
|
|
93
93
|
return constructVideoChat(await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id));
|
|
94
94
|
}
|
|
95
95
|
static canHandleUpdate(update) {
|
|
@@ -123,7 +123,7 @@ export class VideoChatManager {
|
|
|
123
123
|
return { videoChat: constructVideoChat(update.call) };
|
|
124
124
|
}
|
|
125
125
|
async getLiveStreamChannels(id) {
|
|
126
|
-
|
|
126
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getLiveStreamChannels");
|
|
127
127
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
128
128
|
if (!(is("groupCall", call)) || !call.rtmp_stream) {
|
|
129
129
|
throw new InputError("Not a live stream.");
|
|
@@ -139,7 +139,7 @@ export class VideoChatManager {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
async *downloadLiveStreamChunk(id, channel, scale, timestamp, params) {
|
|
142
|
-
|
|
142
|
+
__classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("downloadLiveStreamChunk");
|
|
143
143
|
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
144
144
|
if (!(is("groupCall", call)) || !call.rtmp_stream) {
|
|
145
145
|
throw new InputError("Not a live stream.");
|
|
@@ -44,12 +44,12 @@ export class CallbackQueryManager {
|
|
|
44
44
|
__classPrivateFieldSet(this, _CallbackQueryManager_c, c, "f");
|
|
45
45
|
}
|
|
46
46
|
async answerCallbackQuery(id, params) {
|
|
47
|
-
|
|
47
|
+
__classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertBot("answerCallbackQuery");
|
|
48
48
|
checkCallbackQueryId(id);
|
|
49
49
|
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 });
|
|
50
50
|
}
|
|
51
51
|
async sendCallbackQuery(chatId, messageId, question) {
|
|
52
|
-
|
|
52
|
+
__classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertUser("sendCallbackQuery");
|
|
53
53
|
checkMessageId(messageId);
|
|
54
54
|
validateCallbackQueryQuestion(question);
|
|
55
55
|
const peer = await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getInputPeer(chatId), peerId = peerToChatId(peer), questionKey = JSON.stringify(question);
|
|
@@ -124,7 +124,7 @@ export class ChatListManager {
|
|
|
124
124
|
return () => Promise.resolve();
|
|
125
125
|
}
|
|
126
126
|
async getChats(from = "main", after, limit = 100) {
|
|
127
|
-
|
|
127
|
+
__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.assertUser("getChats");
|
|
128
128
|
if (!__classPrivateFieldGet(this, _ChatListManager_chatsLoadedFromStorage, "f")) {
|
|
129
129
|
await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadChatsFromStorage).call(this);
|
|
130
130
|
}
|
|
@@ -43,7 +43,7 @@ export class InlineQueryManager {
|
|
|
43
43
|
__classPrivateFieldSet(this, _InlineQueryManager_c, c, "f");
|
|
44
44
|
}
|
|
45
45
|
async answerInlineQuery(id, results, params) {
|
|
46
|
-
|
|
46
|
+
__classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertBot("answerInlineQuery");
|
|
47
47
|
checkInlineQueryId(id);
|
|
48
48
|
await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").invoke({ _: "messages.setInlineBotResults", query_id: BigInt(id), results: await Promise.all(results.map((v) => 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 });
|
|
49
49
|
}
|
|
@@ -62,7 +62,7 @@ export class InlineQueryManager {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
async sendInlineQuery(userId, chatId, params) {
|
|
65
|
-
|
|
65
|
+
__classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertUser("sendInlineQuery");
|
|
66
66
|
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 ?? "";
|
|
67
67
|
const botId = peerToChatId(bot), peerId = peerToChatId(peer);
|
|
68
68
|
const maybeResults = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageStorage.getInlineQueryAnswer(botId, peerId, query, offset);
|