@mtkruto/node 0.154.0 → 0.160.0

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.
Files changed (171) hide show
  1. package/esm/3_types.d.ts +3 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +3 -0
  4. package/esm/client/0_markdown.js +4 -4
  5. package/esm/client/0_params.d.ts +11 -1
  6. package/esm/client/0_params.d.ts.map +1 -1
  7. package/esm/client/1_client_generic.d.ts +100 -3
  8. package/esm/client/1_client_generic.d.ts.map +1 -1
  9. package/esm/client/2_client_encrypted.d.ts.map +1 -1
  10. package/esm/client/2_client_encrypted.js +12 -2
  11. package/esm/client/2_file_manager.js +1 -1
  12. package/esm/client/2_payment_manager.js +2 -2
  13. package/esm/client/2_takeout_manager.js +2 -2
  14. package/esm/client/2_update_manager.js +10 -10
  15. package/esm/client/3_account_manager.js +3 -3
  16. package/esm/client/3_message_manager.d.ts +11 -0
  17. package/esm/client/3_message_manager.d.ts.map +1 -1
  18. package/esm/client/3_message_manager.js +195 -74
  19. package/esm/client/3_sticker_set_manager.js +3 -3
  20. package/esm/client/3_video_chat_manager.js +1 -1
  21. package/esm/client/4_callback_query_manager.js +2 -2
  22. package/esm/client/4_chat_list_manager.js +3 -3
  23. package/esm/client/4_chat_manager.d.ts +3 -2
  24. package/esm/client/4_chat_manager.d.ts.map +1 -1
  25. package/esm/client/4_chat_manager.js +12 -5
  26. package/esm/client/4_contact_manager.js +1 -1
  27. package/esm/client/4_gift_manager.js +11 -11
  28. package/esm/client/4_inline_query_manager.js +1 -1
  29. package/esm/client/4_story_manager.d.ts +3 -1
  30. package/esm/client/4_story_manager.d.ts.map +1 -1
  31. package/esm/client/4_story_manager.js +17 -3
  32. package/esm/client/6_client.d.ts +100 -3
  33. package/esm/client/6_client.d.ts.map +1 -1
  34. package/esm/client/6_client.js +126 -1
  35. package/esm/client/6_client_dispatcher.d.ts +100 -3
  36. package/esm/client/6_client_dispatcher.d.ts.map +1 -1
  37. package/esm/client/6_client_dispatcher.js +126 -1
  38. package/esm/connection/0_get_tls_header.d.ts.map +1 -1
  39. package/esm/connection/0_get_tls_header.js +19 -0
  40. package/esm/connection/1_connection_web_socket.js +2 -2
  41. package/esm/session/2_session_encrypted.js +2 -2
  42. package/esm/storage/1_utilities.js +2 -2
  43. package/esm/transport/2_transport_provider_web_socket.js +1 -1
  44. package/esm/types/0_button_style.js +1 -1
  45. package/esm/types/0_chat_member_rights.js +34 -34
  46. package/esm/types/0_chat_photo.js +2 -2
  47. package/esm/types/0_dice.d.ts +1 -1
  48. package/esm/types/0_dice.d.ts.map +1 -1
  49. package/esm/types/0_giveaway_parameters.js +1 -1
  50. package/esm/types/0_live_stream_channel.d.ts +1 -1
  51. package/esm/types/0_live_stream_channel.d.ts.map +1 -1
  52. package/esm/types/0_report_reason.d.ts +53 -0
  53. package/esm/types/0_report_reason.d.ts.map +1 -0
  54. package/esm/types/0_report_reason.js +45 -0
  55. package/esm/types/0_story_report_option.d.ts +26 -0
  56. package/esm/types/0_story_report_option.d.ts.map +1 -0
  57. package/esm/types/0_story_report_option.js +25 -0
  58. package/esm/types/0_video_chat.js +2 -2
  59. package/esm/types/1_inline_keyboard_button.d.ts +2 -2
  60. package/esm/types/1_message_reaction.js +1 -1
  61. package/esm/types/1_sticker.js +1 -1
  62. package/esm/types/1_story_reaction.js +1 -1
  63. package/esm/types/1_story_report_result.d.ts +37 -0
  64. package/esm/types/1_story_report_result.d.ts.map +1 -0
  65. package/esm/types/1_story_report_result.js +36 -0
  66. package/esm/types/2_chat.js +2 -2
  67. package/esm/types/2_chat_member.js +3 -3
  68. package/esm/types/2_message_entity.js +1 -1
  69. package/esm/types/2_story_interactive_area.js +3 -3
  70. package/esm/types/3_chat_settings.js +1 -1
  71. package/esm/types/3_forward_header.js +3 -3
  72. package/esm/types/3_inline_query.js +1 -1
  73. package/esm/types/3_invite_link.js +2 -2
  74. package/esm/types/3_story.js +3 -3
  75. package/esm/types/4_gift.js +1 -1
  76. package/esm/types/5_gift_non_upgraded_information.js +8 -8
  77. package/esm/types/5_gift_upgraded_information.js +5 -5
  78. package/esm/types/6_poll_media.d.ts +1 -1
  79. package/esm/types/6_poll_media.d.ts.map +1 -1
  80. package/esm/types/7_inline_query_result.js +8 -8
  81. package/esm/types/7_poll_option.d.ts +1 -1
  82. package/esm/types/7_poll_option.d.ts.map +1 -1
  83. package/esm/types/8_inline_query_answer.js +1 -1
  84. package/esm/types/9_message.js +3 -3
  85. package/esm/utilities/0_env.js +1 -1
  86. package/package.json +1 -1
  87. package/script/3_types.d.ts +3 -0
  88. package/script/3_types.d.ts.map +1 -1
  89. package/script/3_types.js +3 -0
  90. package/script/client/0_markdown.js +4 -4
  91. package/script/client/0_params.d.ts +11 -1
  92. package/script/client/0_params.d.ts.map +1 -1
  93. package/script/client/1_client_generic.d.ts +100 -3
  94. package/script/client/1_client_generic.d.ts.map +1 -1
  95. package/script/client/2_client_encrypted.d.ts.map +1 -1
  96. package/script/client/2_client_encrypted.js +12 -2
  97. package/script/client/2_file_manager.js +1 -1
  98. package/script/client/2_payment_manager.js +2 -2
  99. package/script/client/2_takeout_manager.js +2 -2
  100. package/script/client/2_update_manager.js +10 -10
  101. package/script/client/3_account_manager.js +3 -3
  102. package/script/client/3_message_manager.d.ts +11 -0
  103. package/script/client/3_message_manager.d.ts.map +1 -1
  104. package/script/client/3_message_manager.js +194 -73
  105. package/script/client/3_sticker_set_manager.js +3 -3
  106. package/script/client/3_video_chat_manager.js +1 -1
  107. package/script/client/4_callback_query_manager.js +2 -2
  108. package/script/client/4_chat_list_manager.js +3 -3
  109. package/script/client/4_chat_manager.d.ts +3 -2
  110. package/script/client/4_chat_manager.d.ts.map +1 -1
  111. package/script/client/4_chat_manager.js +11 -4
  112. package/script/client/4_contact_manager.js +1 -1
  113. package/script/client/4_gift_manager.js +11 -11
  114. package/script/client/4_inline_query_manager.js +1 -1
  115. package/script/client/4_story_manager.d.ts +3 -1
  116. package/script/client/4_story_manager.d.ts.map +1 -1
  117. package/script/client/4_story_manager.js +15 -1
  118. package/script/client/6_client.d.ts +100 -3
  119. package/script/client/6_client.d.ts.map +1 -1
  120. package/script/client/6_client.js +126 -1
  121. package/script/client/6_client_dispatcher.d.ts +100 -3
  122. package/script/client/6_client_dispatcher.d.ts.map +1 -1
  123. package/script/client/6_client_dispatcher.js +126 -1
  124. package/script/connection/0_get_tls_header.d.ts.map +1 -1
  125. package/script/connection/0_get_tls_header.js +19 -0
  126. package/script/connection/1_connection_web_socket.js +2 -2
  127. package/script/session/2_session_encrypted.js +2 -2
  128. package/script/storage/1_utilities.js +2 -2
  129. package/script/transport/2_transport_provider_web_socket.js +1 -1
  130. package/script/types/0_button_style.js +1 -1
  131. package/script/types/0_chat_member_rights.js +34 -34
  132. package/script/types/0_chat_photo.js +2 -2
  133. package/script/types/0_dice.d.ts +1 -1
  134. package/script/types/0_dice.d.ts.map +1 -1
  135. package/script/types/0_giveaway_parameters.js +1 -1
  136. package/script/types/0_live_stream_channel.d.ts +1 -1
  137. package/script/types/0_live_stream_channel.d.ts.map +1 -1
  138. package/script/types/0_report_reason.d.ts +53 -0
  139. package/script/types/0_report_reason.d.ts.map +1 -0
  140. package/script/types/0_report_reason.js +48 -0
  141. package/script/types/0_story_report_option.d.ts +26 -0
  142. package/script/types/0_story_report_option.d.ts.map +1 -0
  143. package/script/types/0_story_report_option.js +28 -0
  144. package/script/types/0_video_chat.js +2 -2
  145. package/script/types/1_inline_keyboard_button.d.ts +2 -2
  146. package/script/types/1_message_reaction.js +1 -1
  147. package/script/types/1_sticker.js +1 -1
  148. package/script/types/1_story_reaction.js +1 -1
  149. package/script/types/1_story_report_result.d.ts +37 -0
  150. package/script/types/1_story_report_result.d.ts.map +1 -0
  151. package/script/types/1_story_report_result.js +39 -0
  152. package/script/types/2_chat.js +2 -2
  153. package/script/types/2_chat_member.js +3 -3
  154. package/script/types/2_message_entity.js +1 -1
  155. package/script/types/2_story_interactive_area.js +3 -3
  156. package/script/types/3_chat_settings.js +1 -1
  157. package/script/types/3_forward_header.js +3 -3
  158. package/script/types/3_inline_query.js +1 -1
  159. package/script/types/3_invite_link.js +2 -2
  160. package/script/types/3_story.js +3 -3
  161. package/script/types/4_gift.js +1 -1
  162. package/script/types/5_gift_non_upgraded_information.js +8 -8
  163. package/script/types/5_gift_upgraded_information.js +5 -5
  164. package/script/types/6_poll_media.d.ts +1 -1
  165. package/script/types/6_poll_media.d.ts.map +1 -1
  166. package/script/types/7_inline_query_result.js +8 -8
  167. package/script/types/7_poll_option.d.ts +1 -1
  168. package/script/types/7_poll_option.d.ts.map +1 -1
  169. package/script/types/8_inline_query_answer.js +1 -1
  170. package/script/types/9_message.js +3 -3
  171. package/script/utilities/0_env.js +1 -1
@@ -22,7 +22,7 @@ import { InputError } from "../0_errors.js";
22
22
  import { base64EncodeUrlSafe, encodeText, fromUnixTimestamp, getLogger, getRandomId } from "../1_utilities.js";
23
23
  import { Api } from "../2_tl.js";
24
24
  import { getDc } from "../3_transport.js";
25
- import { collectMediaFileIds, constructBlockedUserList, constructChatAction, constructMessageDraft, constructMessageEntity, constructMessageReactionList, constructMiniAppInfo, constructSavedChats, constructSummarizedText, constructVoiceTranscription, deserializeFileId, inlineQueryResultToTlObject, messageSearchFilterToTlObject, pageBlockToTlObject, selfDestructOptionToInt } from "../3_types.js";
25
+ import { collectMediaFileIds, constructAnimation, constructBlockedUserList, constructChatAction, constructMessageDraft, constructMessageEntity, constructMessageReactionList, constructMiniAppInfo, constructSavedChats, constructSticker, constructSummarizedText, constructVoiceTranscription, deserializeFileId, inlineQueryResultToTlObject, messageSearchFilterToTlObject, pageBlockToTlObject, selfDestructOptionToInt, serializeFileId, toUniqueFileId } from "../3_types.js";
26
26
  import { assertMessageType, constructMessage as constructMessage_, deserializeInlineMessageId, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
27
27
  import { parseHtml } from "./0_html.js";
28
28
  import { parseMarkdown } from "./0_markdown.js";
@@ -300,14 +300,14 @@ export class MessageManager {
300
300
  const replyMarkup = await this.#constructReplyMarkup(params);
301
301
  const peer = await this.#c.getInputPeer(chatId);
302
302
  const randomId = getRandomId();
303
- const noWebpage = params?.linkPreview?.isDisabled ? true : undefined;
304
- const invertMedia = params?.linkPreview?.isAboveText ? true : undefined;
305
- const silent = params?.isSilent ? true : undefined;
306
- const noforwards = params?.isContentProtected ? true : undefined;
303
+ const noWebpage = params?.linkPreview?.isDisabled || undefined;
304
+ const invertMedia = params?.linkPreview?.isAboveText || undefined;
305
+ const silent = params?.isSilent || undefined;
306
+ const noforwards = params?.isContentProtected || undefined;
307
307
  const sendAs = await this.#resolveSendAs(params);
308
308
  const effect = params?.effectId ? BigInt(params.effectId) : undefined;
309
309
  const schedule_date = params?.sendAt;
310
- const allow_paid_floodskip = params?.isPaidBroadcast ? true : undefined;
310
+ const allow_paid_floodskip = params?.isPaidBroadcast || undefined;
311
311
  let result;
312
312
  if (!noWebpage && params?.linkPreview?.url) {
313
313
  result = await this.#c.invoke({
@@ -317,9 +317,9 @@ export class MessageManager {
317
317
  media: {
318
318
  _: "inputMediaWebPage",
319
319
  url: params.linkPreview.url,
320
- force_large_media: params.linkPreview.mediaSize === "large" ? true : undefined,
321
- force_small_media: params.linkPreview.mediaSize === "small" ? true : undefined,
322
- optional: message.length ? undefined : true,
320
+ force_large_media: params.linkPreview.mediaSize === "large" || undefined,
321
+ force_small_media: params.linkPreview.mediaSize === "small" || undefined,
322
+ optional: !message.length || undefined,
323
323
  },
324
324
  message,
325
325
  invert_media: invertMedia,
@@ -361,12 +361,12 @@ export class MessageManager {
361
361
  const replyMarkup = await this.#constructReplyMarkup(params);
362
362
  const peer = await this.#c.getInputPeer(chatId);
363
363
  const randomId = getRandomId();
364
- const silent = params?.isSilent ? true : undefined;
365
- const noforwards = params?.isContentProtected ? true : undefined;
364
+ const silent = params?.isSilent || undefined;
365
+ const noforwards = params?.isContentProtected || undefined;
366
366
  const sendAs = await this.#resolveSendAs(params);
367
367
  const effect = params?.effectId ? BigInt(params.effectId) : undefined;
368
368
  const schedule_date = params?.sendAt;
369
- const allow_paid_floodskip = params?.isPaidBroadcast ? true : undefined;
369
+ const allow_paid_floodskip = params?.isPaidBroadcast || undefined;
370
370
  const rich_message = MessageManager.inputRichTextToInputRichMessage(richText);
371
371
  const result = await this.#c.invoke({
372
372
  _: "messages.sendMessage",
@@ -463,8 +463,8 @@ export class MessageManager {
463
463
  this.#checkParams(params);
464
464
  const peer = await this.#c.getInputPeer(chatId);
465
465
  const randomId = getRandomId();
466
- const silent = params?.isSilent ? true : undefined;
467
- const noforwards = params?.isContentProtected ? true : undefined;
466
+ const silent = params?.isSilent || undefined;
467
+ const noforwards = params?.isContentProtected || undefined;
468
468
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
469
469
  const replyMarkup = await this.#constructReplyMarkup(params);
470
470
  const result = await this.#c.invoke({
@@ -492,7 +492,7 @@ export class MessageManager {
492
492
  message: "",
493
493
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
494
494
  schedule_date: params?.sendAt,
495
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
495
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
496
496
  }, { businessConnectionId: params?.businessConnectionId });
497
497
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
498
498
  return assertMessageType(message, "venue");
@@ -501,8 +501,8 @@ export class MessageManager {
501
501
  this.#checkParams(params);
502
502
  const peer = await this.#c.getInputPeer(chatId);
503
503
  const randomId = getRandomId();
504
- const silent = params?.isSilent ? true : undefined;
505
- const noforwards = params?.isContentProtected ? true : undefined;
504
+ const silent = params?.isSilent || undefined;
505
+ const noforwards = params?.isContentProtected || undefined;
506
506
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
507
507
  const replyMarkup = await this.#constructReplyMarkup(params);
508
508
  const result = await this.#c.invoke({
@@ -524,7 +524,7 @@ export class MessageManager {
524
524
  message: "",
525
525
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
526
526
  schedule_date: params?.sendAt,
527
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
527
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
528
528
  }, { businessConnectionId: params?.businessConnectionId });
529
529
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
530
530
  return assertMessageType(message, "contact");
@@ -533,8 +533,8 @@ export class MessageManager {
533
533
  this.#checkParams(params);
534
534
  const peer = await this.#c.getInputPeer(chatId);
535
535
  const randomId = getRandomId();
536
- const silent = params?.isSilent ? true : undefined;
537
- const noforwards = params?.isContentProtected ? true : undefined;
536
+ const silent = params?.isSilent || undefined;
537
+ const noforwards = params?.isContentProtected || undefined;
538
538
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
539
539
  const replyMarkup = await this.#constructReplyMarkup(params);
540
540
  const result = await this.#c.invoke({
@@ -553,7 +553,7 @@ export class MessageManager {
553
553
  message: "",
554
554
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
555
555
  schedule_date: params?.sendAt,
556
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
556
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
557
557
  }, { businessConnectionId: params?.businessConnectionId });
558
558
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
559
559
  return assertMessageType(message, "dice");
@@ -562,8 +562,8 @@ export class MessageManager {
562
562
  this.#checkParams(params);
563
563
  const peer = await this.#c.getInputPeer(chatId);
564
564
  const randomId = getRandomId();
565
- const silent = params?.isSilent ? true : undefined;
566
- const noforwards = params?.isContentProtected ? true : undefined;
565
+ const silent = params?.isSilent || undefined;
566
+ const noforwards = params?.isContentProtected || undefined;
567
567
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
568
568
  const replyMarkup = await this.#constructReplyMarkup(params);
569
569
  const result = await this.#c.invoke({
@@ -600,7 +600,7 @@ export class MessageManager {
600
600
  message: "",
601
601
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
602
602
  schedule_date: params?.sendAt,
603
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
603
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
604
604
  }, { businessConnectionId: params?.businessConnectionId });
605
605
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
606
606
  return assertMessageType(message, "location");
@@ -627,7 +627,7 @@ export class MessageManager {
627
627
  return assertMessageType(message, "audio");
628
628
  }
629
629
  static #isM4a(firstPart) {
630
- return firstPart.length >= 10 && startsWith(firstPart.subarray(4), new Uint8Array([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34]));
630
+ return firstPart.byteLength >= 10 && startsWith(firstPart.subarray(4), new Uint8Array([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34]));
631
631
  }
632
632
  async sendVoice(chatId, voice, params) {
633
633
  this.#checkParams(params);
@@ -664,13 +664,13 @@ export class MessageManager {
664
664
  async sendVideo(chatId, video, params) {
665
665
  this.#checkParams(params);
666
666
  const message = await this.#sendDocumentInner(chatId, video, params, FileType.Video, [
667
- { _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming ? true : undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
667
+ { _: "documentAttributeVideo", supports_streaming: params?.supportsStreaming || undefined, w: params?.width ?? 0, h: params?.height ?? 0, duration: params?.duration ?? 0 },
668
668
  ], undefined, VIDEO_MIME_TYPES, () => "video.mp4");
669
669
  return assertMessageType(message, "video");
670
670
  }
671
671
  async #sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = true, expectedMimeTypes, createName) {
672
672
  let media = null;
673
- const spoiler = params?.hasSpoiler ? true : undefined;
673
+ const spoiler = params?.hasSpoiler || undefined;
674
674
  const ttl_seconds = params && "selfDestruct" in params && typeof params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
675
675
  if (typeof document === "string") {
676
676
  const fileId = this.resolveFileId(document, fileType);
@@ -708,7 +708,7 @@ export class MessageManager {
708
708
  if (params?.thumbnail) {
709
709
  thumb = await this.#c.fileManager.upload(params.thumbnail, { chunkSize: params?.chunkSize, signal: params?.signal });
710
710
  }
711
- media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType === FileType.Document ? true : undefined, ttl_seconds };
711
+ media = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType === FileType.Document || undefined, ttl_seconds };
712
712
  }
713
713
  }
714
714
  const message = await this.#sendMedia(chatId, media, params);
@@ -745,8 +745,8 @@ export class MessageManager {
745
745
  }
746
746
  const peer = await this.#c.getInputPeer(chatId);
747
747
  const randomId = getRandomId();
748
- const silent = params?.isSilent ? true : undefined;
749
- const noforwards = params?.isContentProtected ? true : undefined;
748
+ const silent = params?.isSilent || undefined;
749
+ const noforwards = params?.isContentProtected || undefined;
750
750
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
751
751
  const replyMarkup = await this.#constructReplyMarkup(params);
752
752
  const caption_ = params?.caption;
@@ -767,7 +767,7 @@ export class MessageManager {
767
767
  entities: captionEntities,
768
768
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
769
769
  schedule_date: params?.sendAt,
770
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
770
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
771
771
  }, { businessConnectionId: params?.businessConnectionId });
772
772
  return (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
773
773
  }
@@ -803,8 +803,8 @@ export class MessageManager {
803
803
  }
804
804
  const peer = await this.#c.getInputPeer(chatId);
805
805
  const randomId = getRandomId();
806
- const silent = params?.isSilent ? true : undefined;
807
- const noforwards = params?.isContentProtected ? true : undefined;
806
+ const silent = params?.isSilent || undefined;
807
+ const noforwards = params?.isContentProtected || undefined;
808
808
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
809
809
  const replyMarkup = await this.#constructReplyMarkup(params);
810
810
  const explanation = params?.explanation;
@@ -829,17 +829,17 @@ export class MessageManager {
829
829
  id: getRandomId(),
830
830
  answers,
831
831
  question: { _: "textWithEntities", text: questionParseResult[0], entities: questionParseResult[1] ?? [] },
832
- closed: params?.isClosed ? true : undefined,
832
+ closed: params?.isClosed || undefined,
833
833
  close_date: params?.closeDate,
834
- close_period: params?.openPeriod ? params.openPeriod : undefined,
835
- multiple_choice: params?.isMultipleAnswersAllowed ? true : undefined,
836
- public_voters: params?.isAnonymous === false ? true : undefined,
837
- quiz: params?.type === "quiz" ? true : undefined,
834
+ close_period: params?.openPeriod || undefined,
835
+ multiple_choice: params?.isMultipleAnswersAllowed || undefined,
836
+ public_voters: params?.isAnonymous === false || undefined,
837
+ quiz: params?.type === "quiz" || undefined,
838
838
  hash: 0n,
839
- revoting_disabled: params?.isRevotingAllowed === false ? true : undefined,
840
- shuffle_answers: params?.isShuffled ? true : undefined,
841
- hide_results_until_close: params?.isResultHidden ? true : undefined,
842
- open_answers: params?.isAddingOptionsAllowed ? true : undefined,
839
+ revoting_disabled: params?.isRevotingAllowed === false || undefined,
840
+ shuffle_answers: params?.isShuffled || undefined,
841
+ hide_results_until_close: params?.isResultHidden || undefined,
842
+ open_answers: params?.isAddingOptionsAllowed || undefined,
843
843
  countries_iso2: params?.countries,
844
844
  subscribers_only: params?.isSubscriberOnly || undefined,
845
845
  };
@@ -870,7 +870,7 @@ export class MessageManager {
870
870
  entities,
871
871
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
872
872
  schedule_date: params?.sendAt,
873
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
873
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
874
874
  }, { businessConnectionId: params?.businessConnectionId });
875
875
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
876
876
  return assertMessageType(message, "poll");
@@ -919,8 +919,8 @@ export class MessageManager {
919
919
  }
920
920
  const peer = await this.#c.getInputPeer(chatId);
921
921
  const randomId = getRandomId();
922
- const silent = params?.isSilent ? true : undefined;
923
- const noforwards = params?.isContentProtected ? true : undefined;
922
+ const silent = params?.isSilent || undefined;
923
+ const noforwards = params?.isContentProtected || undefined;
924
924
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
925
925
  const list = items.map((v, i) => {
926
926
  const text = v.text;
@@ -933,8 +933,8 @@ export class MessageManager {
933
933
  _: "todoList",
934
934
  title: { _: "textWithEntities", text: titleParseResult[0], entities: titleParseResult[1] ?? [] },
935
935
  list,
936
- others_can_append: params?.isExtendableByOthers ? true : undefined,
937
- others_can_complete: params?.isCompletableByOthers ? true : undefined,
936
+ others_can_append: params?.isExtendableByOthers || undefined,
937
+ others_can_complete: params?.isCompletableByOthers || undefined,
938
938
  };
939
939
  const media = { _: "inputMediaTodo", todo };
940
940
  const result = await this.#c.invoke({
@@ -949,7 +949,7 @@ export class MessageManager {
949
949
  message: "",
950
950
  effect: params?.effectId ? BigInt(params.effectId) : undefined,
951
951
  schedule_date: params?.sendAt,
952
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
952
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
953
953
  }, { businessConnectionId: params?.businessConnectionId });
954
954
  const message = (await this.updatesToMessages(chatId, result, params?.businessConnectionId))[0];
955
955
  return assertMessageType(message, "checklist");
@@ -991,11 +991,11 @@ export class MessageManager {
991
991
  if (params?.linkPreview && params.linkPreview.type !== "input") {
992
992
  throw new InputError("Expected link preview of type input.");
993
993
  }
994
- const noWebpage = params?.linkPreview && params.linkPreview.type === "input" && params.linkPreview.isDisabled ? true : undefined;
995
- const invertMedia = params?.linkPreview?.isAboveText ? true : undefined;
994
+ const noWebpage = params?.linkPreview && params.linkPreview.type === "input" && params.linkPreview.isDisabled || undefined;
995
+ const invertMedia = params?.linkPreview?.isAboveText || undefined;
996
996
  let media = undefined;
997
997
  if (!noWebpage && params?.linkPreview?.url) {
998
- media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.mediaSize === "large" ? true : undefined, force_small_media: params.linkPreview.mediaSize === "small" ? true : undefined, optional: message.length ? undefined : true };
998
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.mediaSize === "large" || undefined, force_small_media: params.linkPreview.mediaSize === "small" || undefined, optional: !message.length || undefined };
999
999
  }
1000
1000
  const result = await this.#c.invoke({
1001
1001
  _: "messages.editMessage",
@@ -1069,11 +1069,11 @@ export class MessageManager {
1069
1069
  if (params?.linkPreview && params.linkPreview.type !== "input") {
1070
1070
  throw new InputError("Expected link preview of type input.");
1071
1071
  }
1072
- const noWebpage = params?.linkPreview && params.linkPreview.type === "input" && params.linkPreview.isDisabled ? true : undefined;
1073
- const invertMedia = params?.linkPreview?.isAboveText ? true : undefined;
1072
+ const noWebpage = params?.linkPreview && params.linkPreview.type === "input" && params.linkPreview.isDisabled || undefined;
1073
+ const invertMedia = params?.linkPreview?.isAboveText || undefined;
1074
1074
  let media = undefined;
1075
1075
  if (!noWebpage && params?.linkPreview?.url) {
1076
- media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.mediaSize === "large" ? true : undefined, force_small_media: params.linkPreview.mediaSize === "small" ? true : undefined, optional: message.length ? undefined : true };
1076
+ media = { _: "inputMediaWebPage", url: params.linkPreview.url, force_large_media: params.linkPreview.mediaSize === "large" || undefined, force_small_media: params.linkPreview.mediaSize === "small" || undefined, optional: !message.length || undefined };
1077
1077
  }
1078
1078
  await this.#c.invoke({
1079
1079
  _: "messages.editInlineBotMessage",
@@ -1094,7 +1094,7 @@ export class MessageManager {
1094
1094
  }
1095
1095
  async #resolveInputMediaInner(document, media, fileType, otherAttribs) {
1096
1096
  let media_ = null;
1097
- const spoiler = "hasSpoiler" in media && media.hasSpoiler ? true : undefined;
1097
+ const spoiler = "hasSpoiler" in media && media.hasSpoiler || undefined;
1098
1098
  if (typeof document === "string") {
1099
1099
  const fileId = this.resolveFileId(document, fileType);
1100
1100
  if (fileId !== null) {
@@ -1121,7 +1121,7 @@ export class MessageManager {
1121
1121
  if ("thumbnail" in media && media.thumbnail) {
1122
1122
  thumb = await this.#c.fileManager.upload(media.thumbnail, { chunkSize: media?.chunkSize, signal: media?.signal });
1123
1123
  }
1124
- media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType === FileType.Document ? true : undefined };
1124
+ media_ = { _: "inputMediaUploadedDocument", file, thumb, spoiler, attributes: [{ _: "documentAttributeFilename", file_name: file.name }, ...otherAttribs], mime_type: mimeType, force_file: fileType === FileType.Document || undefined };
1125
1125
  }
1126
1126
  }
1127
1127
  return media_;
@@ -1141,7 +1141,7 @@ export class MessageManager {
1141
1141
  return await this.#resolveInputMediaInner(media.document, media, FileType.Document, []);
1142
1142
  case "photo": {
1143
1143
  let media_ = null;
1144
- const spoiler = media.hasSpoiler ? true : undefined;
1144
+ const spoiler = media.hasSpoiler || undefined;
1145
1145
  const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
1146
1146
  if (typeof media.photo === "string") {
1147
1147
  const fileId = this.resolveFileId(media.photo, [FileType.Photo, FileType.ProfilePhoto]);
@@ -1163,7 +1163,7 @@ export class MessageManager {
1163
1163
  case "video": {
1164
1164
  const ttl_seconds = "selfDestruct" in media && media.selfDestruct !== undefined ? selfDestructOptionToInt(media.selfDestruct) : undefined;
1165
1165
  const media_ = await this.#resolveInputMediaInner(media.video, media, FileType.Video, [
1166
- { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming ? true : undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1166
+ { _: "documentAttributeVideo", supports_streaming: media?.supportsStreaming || undefined, w: media?.width ?? 0, h: media?.height ?? 0, duration: media?.duration ?? 0 },
1167
1167
  ]);
1168
1168
  media_.ttl_seconds = ttl_seconds;
1169
1169
  return media_;
@@ -1189,14 +1189,14 @@ export class MessageManager {
1189
1189
  access_hash: messageMedia.photo.access_hash,
1190
1190
  file_reference: messageMedia.photo.file_reference,
1191
1191
  },
1192
- spoiler: "hasSpoiler" in media && media.hasSpoiler ? true : undefined,
1192
+ spoiler: "hasSpoiler" in media && media.hasSpoiler || undefined,
1193
1193
  };
1194
1194
  }
1195
1195
  else if ("document" in messageMedia && Api.is("document", messageMedia.document)) {
1196
1196
  return {
1197
1197
  _: "inputMediaDocument",
1198
1198
  id: { _: "inputDocument", id: messageMedia.document.id, access_hash: messageMedia.document.access_hash, file_reference: messageMedia.document.file_reference },
1199
- spoiler: "hasSpoiler" in media && media.hasSpoiler ? true : undefined,
1199
+ spoiler: "hasSpoiler" in media && media.hasSpoiler || undefined,
1200
1200
  };
1201
1201
  }
1202
1202
  else {
@@ -1221,7 +1221,7 @@ export class MessageManager {
1221
1221
  }
1222
1222
  async #uploadPhoto(photo, params) {
1223
1223
  let media = null;
1224
- const spoiler = params?.hasSpoiler ? true : undefined;
1224
+ const spoiler = params?.hasSpoiler || undefined;
1225
1225
  const ttl_seconds = params && "selfDestruct" in params && params.selfDestruct !== undefined ? selfDestructOptionToInt(params.selfDestruct) : undefined;
1226
1226
  let video;
1227
1227
  if (params?.video) {
@@ -1230,7 +1230,7 @@ export class MessageManager {
1230
1230
  if (typeof photo === "string") {
1231
1231
  const fileId = this.resolveFileId(photo, [FileType.Photo, FileType.ProfilePhoto]);
1232
1232
  if (fileId !== null) {
1233
- media = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds, live_photo: video !== undefined ? true : undefined, video };
1233
+ media = { _: "inputMediaPhoto", id: { ...fileId, _: "inputPhoto" }, spoiler, ttl_seconds, live_photo: video !== undefined || undefined, video };
1234
1234
  }
1235
1235
  }
1236
1236
  if (media === null) {
@@ -1239,7 +1239,7 @@ export class MessageManager {
1239
1239
  }
1240
1240
  else {
1241
1241
  const file = await this.#c.fileManager.upload(photo, params, checkPhotoName(params), false);
1242
- media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined, live_photo: video !== undefined ? true : undefined, video };
1242
+ media = { _: "inputMediaUploadedPhoto", file, spoiler, ttl_seconds: (params && "selfDestruct" in params && params.selfDestruct !== undefined) ? selfDestructOptionToInt(params.selfDestruct) : undefined, live_photo: video !== undefined || undefined, video };
1243
1243
  }
1244
1244
  }
1245
1245
  return media;
@@ -1361,7 +1361,7 @@ export class MessageManager {
1361
1361
  await this.#c.invoke({ _: "channels.deleteMessages", channel: toInputChannel(peer), id: messageIds });
1362
1362
  }
1363
1363
  else {
1364
- await this.#c.invoke({ _: "messages.deleteMessages", id: messageIds, revoke: params?.onlyForMe ? undefined : true });
1364
+ await this.#c.invoke({ _: "messages.deleteMessages", id: messageIds, revoke: !params?.onlyForMe || undefined });
1365
1365
  }
1366
1366
  }
1367
1367
  async deleteScheduledMessages(chatId, messageIds) {
@@ -1393,7 +1393,7 @@ export class MessageManager {
1393
1393
  }
1394
1394
  async pinMessage(chatId, messageId, params) {
1395
1395
  this.#checkParams(params);
1396
- await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.isSilent ? true : undefined, pm_oneside: params?.bothSides ? undefined : true });
1396
+ await this.#c.invoke({ _: "messages.updatePinnedMessage", peer: await this.#c.getInputPeer(chatId), id: checkMessageId(messageId), silent: params?.isSilent || undefined, pm_oneside: !params?.bothSides || undefined });
1397
1397
  }
1398
1398
  async unpinMessage(chatId, messageId, params) {
1399
1399
  this.#checkParams(params);
@@ -1407,7 +1407,7 @@ export class MessageManager {
1407
1407
  });
1408
1408
  }
1409
1409
  async #sendReaction(chatId, messageId, reactions, params) {
1410
- await this.#c.invoke({ _: "messages.sendReaction", peer: await this.#c.getInputPeer(chatId), msg_id: checkMessageId(messageId), reaction: reactions.map((v) => reactionToTlObject(v)), big: params?.isBig ? true : undefined, add_to_recent: params?.addToRecents ? true : undefined });
1410
+ await this.#c.invoke({ _: "messages.sendReaction", peer: await this.#c.getInputPeer(chatId), msg_id: checkMessageId(messageId), reaction: reactions.map((v) => reactionToTlObject(v)), big: params?.isBig || undefined, add_to_recent: params?.addToRecents || undefined });
1411
1411
  }
1412
1412
  async setReactions(chatId, messageId, reactions, params) {
1413
1413
  await this.#sendReaction(chatId, messageId, reactions, params);
@@ -1656,7 +1656,7 @@ export class MessageManager {
1656
1656
  }
1657
1657
  async getBlockedUsers(params) {
1658
1658
  this.#c.storage.assertUser("getBlockedUsers");
1659
- const my_stories_from = params?.isBlockedFromViewingStories ? true : undefined;
1659
+ const my_stories_from = params?.isBlockedFromViewingStories || undefined;
1660
1660
  const offset = params?.offset ?? 0;
1661
1661
  const limit = getLimit(params?.limit);
1662
1662
  const result = await this.#c.invoke({ _: "contacts.getBlocked", my_stories_from, offset, limit });
@@ -1812,8 +1812,8 @@ export class MessageManager {
1812
1812
  multiMedia[i] = { ...media_, media: { _: "inputMediaDocument", id: { ...document, _: "inputDocument" } } };
1813
1813
  }
1814
1814
  }
1815
- const silent = params?.isSilent ? true : undefined;
1816
- const noforwards = params?.isContentProtected ? true : undefined;
1815
+ const silent = params?.isSilent || undefined;
1816
+ const noforwards = params?.isContentProtected || undefined;
1817
1817
  const sendAs = params?.sendAs ? await this.#c.getInputPeer(params.sendAs) : undefined;
1818
1818
  const result = await this.#c.invoke({
1819
1819
  _: "messages.sendMultiMedia",
@@ -1824,7 +1824,7 @@ export class MessageManager {
1824
1824
  silent,
1825
1825
  send_as: sendAs,
1826
1826
  reply_to: await this.#constructReplyTo(params),
1827
- allow_paid_floodskip: params?.isPaidBroadcast ? true : undefined,
1827
+ allow_paid_floodskip: params?.isPaidBroadcast || undefined,
1828
1828
  });
1829
1829
  return await this.updatesToMessages(chatId, result);
1830
1830
  }
@@ -1970,10 +1970,10 @@ export class MessageManager {
1970
1970
  }
1971
1971
  async openMiniApp(botId, chatId, params) {
1972
1972
  this.#c.storage.assertUser("openMiniApp");
1973
- const from_bot_menu = params?.isFromMenu ? true : undefined;
1974
- const silent = params?.isSilent ? true : undefined;
1975
- const compact = params?.mode === "compact" ? true : undefined;
1976
- const fullscreen = params?.mode === "fullscreen" ? true : undefined;
1973
+ const from_bot_menu = params?.isFromMenu || undefined;
1974
+ const silent = params?.isSilent || undefined;
1975
+ const compact = params?.mode === "compact" || undefined;
1976
+ const fullscreen = params?.mode === "fullscreen" || undefined;
1977
1977
  const peer = await this.#c.getInputPeer(chatId);
1978
1978
  const bot = await this.#c.getInputUser(botId);
1979
1979
  const url = params?.url;
@@ -2171,4 +2171,125 @@ export class MessageManager {
2171
2171
  const message = assertMessageType(await this.constructMessage(message_, false), "richText");
2172
2172
  return message.richText;
2173
2173
  }
2174
+ async getScheduledMessages(chatId) {
2175
+ this.#c.storage.assertUser("getScheduledMessages");
2176
+ const peer = await this.#c.getInputPeer(chatId);
2177
+ const result = Api.as("messages.messages", await this.#c.invoke({ _: "messages.getScheduledHistory", peer, hash: 0n }));
2178
+ return await Promise.all(result.messages.map((v) => this.constructMessage(v, false)));
2179
+ }
2180
+ async getFavoriteStickers() {
2181
+ this.#c.storage.assertUser("getFavoriteStickers");
2182
+ const result = Api.as("messages.favedStickers", await this.#c.invoke({ _: "messages.getFavedStickers", hash: 0n }));
2183
+ const stickers = await Promise.all(result.stickers.map((v) => Api.as("document", v)).map((v) => {
2184
+ const fileId = {
2185
+ type: FileType.Sticker,
2186
+ dcId: v.dc_id,
2187
+ location: {
2188
+ type: "common",
2189
+ id: v.id,
2190
+ accessHash: v.access_hash,
2191
+ },
2192
+ fileReference: v.file_reference,
2193
+ };
2194
+ return constructSticker(v, serializeFileId(fileId), toUniqueFileId(fileId), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager));
2195
+ }));
2196
+ return stickers;
2197
+ }
2198
+ async #faveSticker(fileId_, isFavorited) {
2199
+ const fileId = deserializeFileId(fileId_);
2200
+ if (fileId.type !== FileType.Sticker || fileId.location.type !== "common") {
2201
+ throw new InputError("Invalid file ID.");
2202
+ }
2203
+ const id_ = fileId.location.id;
2204
+ const access_hash = fileId.location.accessHash;
2205
+ const file_reference = fileId.fileReference ?? new Uint8Array();
2206
+ const id = { _: "inputDocument", id: id_, access_hash, file_reference };
2207
+ await this.#c.invoke({ _: "messages.faveSticker", id, unfave: !isFavorited });
2208
+ }
2209
+ async addStickerToFavorites(fileId) {
2210
+ this.#c.storage.assertUser("addStickerToFavorites");
2211
+ await this.#faveSticker(fileId, true);
2212
+ }
2213
+ async removeStickerFromFavorites(fileId) {
2214
+ this.#c.storage.assertUser("removeStickerFromFavorites");
2215
+ await this.#faveSticker(fileId, false);
2216
+ }
2217
+ async #changeStickerRecentStatus(fileId_, isSaved) {
2218
+ const fileId = deserializeFileId(fileId_);
2219
+ if (fileId.type !== FileType.Sticker || fileId.location.type !== "common") {
2220
+ throw new InputError("Invalid file ID.");
2221
+ }
2222
+ const id_ = fileId.location.id;
2223
+ const access_hash = fileId.location.accessHash;
2224
+ const file_reference = fileId.fileReference ?? new Uint8Array();
2225
+ const id = { _: "inputDocument", id: id_, access_hash, file_reference };
2226
+ await this.#c.invoke({ _: "messages.saveRecentSticker", id, unsave: !isSaved });
2227
+ }
2228
+ async addStickerToRecents(fileId) {
2229
+ this.#c.storage.assertUser("addStickerToRecents");
2230
+ await this.#changeStickerRecentStatus(fileId, true);
2231
+ }
2232
+ async removeStickerFromRecents(fileId) {
2233
+ this.#c.storage.assertUser("removeStickerFromRecents");
2234
+ await this.#changeStickerRecentStatus(fileId, false);
2235
+ }
2236
+ async clearRecentStickers() {
2237
+ this.#c.storage.assertUser("clearRecentStickers");
2238
+ await this.#c.invoke({ _: "messages.clearRecentStickers" });
2239
+ }
2240
+ async getRecentStickers() {
2241
+ this.#c.storage.assertUser("getRecentStickers");
2242
+ const result = Api.as("messages.recentStickers", await this.#c.invoke({ _: "messages.getRecentStickers", hash: 0n }));
2243
+ const stickers = await Promise.all(result.stickers.map((v) => Api.as("document", v)).map((v) => {
2244
+ const fileId = {
2245
+ type: FileType.Sticker,
2246
+ dcId: v.dc_id,
2247
+ location: {
2248
+ type: "common",
2249
+ id: v.id,
2250
+ accessHash: v.access_hash,
2251
+ },
2252
+ fileReference: v.file_reference,
2253
+ };
2254
+ return constructSticker(v, serializeFileId(fileId), toUniqueFileId(fileId), this.#c.fileManager.getStickerSetName.bind(this.#c.fileManager));
2255
+ }));
2256
+ return stickers;
2257
+ }
2258
+ async getSavedAnimations() {
2259
+ this.#c.storage.assertUser("getSavedAnimations");
2260
+ const result = Api.as("messages.savedGifs", await this.#c.invoke({ _: "messages.getSavedGifs", hash: 0n }));
2261
+ const animations = await Promise.all(result.gifs.map((v) => Api.as("document", v)).map((v) => {
2262
+ const fileId = {
2263
+ type: FileType.Sticker,
2264
+ dcId: v.dc_id,
2265
+ location: {
2266
+ type: "common",
2267
+ id: v.id,
2268
+ accessHash: v.access_hash,
2269
+ },
2270
+ fileReference: v.file_reference,
2271
+ };
2272
+ return constructAnimation(v, v.attributes.find((v) => Api.is("documentAttributeVideo", v)), v.attributes.find((v) => Api.is("documentAttributeFilename", v)), serializeFileId(fileId), toUniqueFileId(fileId));
2273
+ }));
2274
+ return animations;
2275
+ }
2276
+ async #setIsAnimationSaved(fileId_, isSaved) {
2277
+ const fileId = deserializeFileId(fileId_);
2278
+ if (fileId.type !== FileType.Animation || fileId.location.type !== "common") {
2279
+ throw new InputError("Invalid file ID.");
2280
+ }
2281
+ const id_ = fileId.location.id;
2282
+ const access_hash = fileId.location.accessHash;
2283
+ const file_reference = fileId.fileReference ?? new Uint8Array();
2284
+ const id = { _: "inputDocument", id: id_, access_hash, file_reference };
2285
+ await this.#c.invoke({ _: "messages.saveGif", id, unsave: !isSaved });
2286
+ }
2287
+ async saveAnimation(fileId) {
2288
+ this.#c.storage.assertUser("saveAnimation");
2289
+ await this.#setIsAnimationSaved(fileId, true);
2290
+ }
2291
+ async unsaveAnimation(fileId) {
2292
+ this.#c.storage.assertUser("unsaveAnimation");
2293
+ await this.#setIsAnimationSaved(fileId, false);
2294
+ }
2174
2295
  }
@@ -98,9 +98,9 @@ export class StickerSetManager {
98
98
  const thumb = params?.thumbnail ? await this.#uploadSticker(params.thumbnail, "⭐️", params, user_id) : undefined;
99
99
  const result = await this.#c.invoke({
100
100
  _: "stickers.createStickerSet",
101
- masks: params?.isMask ? true : undefined,
102
- emojis: params?.isCustomEmoji ? true : undefined,
103
- text_color: params?.isAdaptive ? true : undefined,
101
+ masks: params?.isMask || undefined,
102
+ emojis: params?.isCustomEmoji || undefined,
103
+ text_color: params?.isAdaptive || undefined,
104
104
  title: name,
105
105
  user_id,
106
106
  short_name: slug,
@@ -64,7 +64,7 @@ export class VideoChatManager {
64
64
  async joinVideoChat(id, params, params_) {
65
65
  this.#c.storage.assertUser("joinVideoChat");
66
66
  const call = await this.#getInputGroupCall(id);
67
- const { updates } = await this.#c.invoke({ _: "phone.joinGroupCall", call, join_as: params_?.joinAs ? await this.#c.getInputPeer(params_.joinAs) : { _: "inputPeerSelf" }, params: { _: "dataJSON", data: params }, invite_hash: params_?.inviteHash, muted: params_?.isAudioEnabled ? undefined : true, video_stopped: params_?.isVideoEnabled ? undefined : true }).then((v) => Api.as("updates", v));
67
+ const { updates } = await this.#c.invoke({ _: "phone.joinGroupCall", call, join_as: params_?.joinAs ? await this.#c.getInputPeer(params_.joinAs) : { _: "inputPeerSelf" }, params: { _: "dataJSON", data: params }, invite_hash: params_?.inviteHash, muted: !params_?.isAudioEnabled || undefined, video_stopped: !params_?.isVideoEnabled || undefined }).then((v) => Api.as("updates", v));
68
68
  const updateGroupCall = updates
69
69
  .find((v) => Api.is("updateGroupCallConnection", v));
70
70
  if (!updateGroupCall)
@@ -35,7 +35,7 @@ export class CallbackQueryManager {
35
35
  async answerCallbackQuery(id, params) {
36
36
  this.#c.storage.assertBot("answerCallbackQuery");
37
37
  checkCallbackQueryId(id);
38
- await this.#c.invoke({ _: "messages.setBotCallbackAnswer", query_id: BigInt(id), cache_time: params?.cacheTime ?? 0, message: params?.text, alert: params?.isAlert ? true : undefined });
38
+ await this.#c.invoke({ _: "messages.setBotCallbackAnswer", query_id: BigInt(id), cache_time: params?.cacheTime ?? 0, message: params?.text, alert: params?.isAlert || undefined });
39
39
  }
40
40
  async sendCallbackQuery(botId, messageId, question) {
41
41
  this.#c.storage.assertUser("sendCallbackQuery");
@@ -46,7 +46,7 @@ export class CallbackQueryManager {
46
46
  if (maybeAnswer !== null && !CallbackQueryManager.#isExpired(maybeAnswer[1], maybeAnswer[0].cache_time)) {
47
47
  return constructCallbackQueryAnswer(maybeAnswer[0]);
48
48
  }
49
- const answer = await this.#c.invoke({ _: "messages.getBotCallbackAnswer", peer, msg_id: messageId, data: "data" in question ? encodeText(question.data) : undefined, game: question.type === "game" ? true : undefined, password: question.type === "password" ? await this.#getPasswordCheck(question.password) : undefined });
49
+ const answer = await this.#c.invoke({ _: "messages.getBotCallbackAnswer", peer, msg_id: messageId, data: "data" in question ? encodeText(question.data) : undefined, game: question.type === "game" || undefined, password: question.type === "password" ? await this.#getPasswordCheck(question.password) : undefined });
50
50
  if (answer.cache_time >= 0) {
51
51
  await this.#c.messageStorage.setCallbackQueryAnswer(peerId, messageId, questionKey, answer);
52
52
  }
@@ -251,9 +251,9 @@ export class ChatListManager {
251
251
  title = this.#checkChatTitle(title);
252
252
  const updates = await this.#c.invoke({
253
253
  _: "channels.createChannel",
254
- broadcast: type === "channel" ? true : undefined,
255
- megagroup: type === "supergroup" ? true : undefined,
256
- forum: params && ("isForum" in params) && params.isForum ? true : undefined,
254
+ broadcast: type === "channel" || undefined,
255
+ megagroup: type === "supergroup" || undefined,
256
+ forum: params && ("isForum" in params) && params.isForum || undefined,
257
257
  title,
258
258
  about: params?.description || "",
259
259
  ttl_period: params?.messageTtl || undefined,