@mtcute/core 0.31.0 → 0.32.1

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 (154) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +79 -10
  4. package/highlevel/client.d.ts +79 -10
  5. package/highlevel/methods/chats/build-peers-index.cjs +45 -0
  6. package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
  7. package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
  8. package/highlevel/methods/chats/build-peers-index.js +40 -0
  9. package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
  10. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
  11. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
  12. package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
  13. package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +1 -1
  14. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +2 -2
  15. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +2 -2
  16. package/highlevel/methods/ephemeral/delete-ephemeral-message.js +1 -1
  17. package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
  18. package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
  19. package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
  20. package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
  21. package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +11 -3
  22. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +16 -2
  23. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +16 -2
  24. package/highlevel/methods/ephemeral/edit-ephemeral-message.js +11 -3
  25. package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
  26. package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
  27. package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
  28. package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
  29. package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +13 -3
  30. package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +20 -2
  31. package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +20 -2
  32. package/highlevel/methods/ephemeral/send-ephemeral-message.js +13 -3
  33. package/highlevel/methods/files/download-iterable.cjs +3 -0
  34. package/highlevel/methods/files/download-iterable.js +3 -0
  35. package/highlevel/methods/files/normalize-input-media.cjs +25 -4
  36. package/highlevel/methods/files/normalize-input-media.js +25 -4
  37. package/highlevel/methods/forums/edit-forum-topic.cjs +1 -1
  38. package/highlevel/methods/forums/edit-forum-topic.js +1 -1
  39. package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
  40. package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
  41. package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +1 -1
  42. package/highlevel/methods/forums/toggle-general-topic-hidden.js +1 -1
  43. package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
  44. package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
  45. package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
  46. package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
  47. package/highlevel/methods/messages/edit-message.cjs +7 -1
  48. package/highlevel/methods/messages/edit-message.d.cts +6 -2
  49. package/highlevel/methods/messages/edit-message.d.ts +6 -2
  50. package/highlevel/methods/messages/edit-message.js +7 -1
  51. package/highlevel/methods/messages/edit-message.test.d.cts +1 -0
  52. package/highlevel/methods/messages/edit-message.test.d.ts +1 -0
  53. package/highlevel/methods/messages/forward-messages.cjs +1 -0
  54. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  55. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  56. package/highlevel/methods/messages/forward-messages.js +1 -0
  57. package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
  58. package/highlevel/methods/messages/normalize-rich-message.js +3 -0
  59. package/highlevel/methods/messages/send-text.cjs +2 -33
  60. package/highlevel/methods/messages/send-text.js +2 -33
  61. package/highlevel/methods/messages/send-typing.d.cts +3 -3
  62. package/highlevel/methods/messages/send-typing.d.ts +3 -3
  63. package/highlevel/methods/messages/set-typing.cjs +1 -1
  64. package/highlevel/methods/messages/set-typing.d.cts +2 -2
  65. package/highlevel/methods/messages/set-typing.d.ts +2 -2
  66. package/highlevel/methods/messages/set-typing.js +1 -1
  67. package/highlevel/methods.d.cts +3 -0
  68. package/highlevel/methods.d.ts +3 -0
  69. package/highlevel/types/bots/keyboards/builder.cjs +5 -5
  70. package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
  71. package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
  72. package/highlevel/types/bots/keyboards/builder.js +5 -5
  73. package/highlevel/types/bots/keyboards/factories.cjs +51 -103
  74. package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
  75. package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
  76. package/highlevel/types/bots/keyboards/factories.js +51 -103
  77. package/highlevel/types/bots/keyboards/index.d.cts +3 -3
  78. package/highlevel/types/bots/keyboards/index.d.ts +3 -3
  79. package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
  80. package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
  81. package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
  82. package/highlevel/types/bots/keyboards/normalize.js +126 -0
  83. package/highlevel/types/bots/keyboards/types.d.cts +160 -4
  84. package/highlevel/types/bots/keyboards/types.d.ts +160 -4
  85. package/highlevel/types/messages/dialog.cjs +8 -1
  86. package/highlevel/types/messages/dialog.d.cts +3 -0
  87. package/highlevel/types/messages/dialog.d.ts +3 -0
  88. package/highlevel/types/messages/dialog.js +8 -1
  89. package/highlevel/types/messages/dialog.test.d.cts +1 -0
  90. package/highlevel/types/messages/dialog.test.d.ts +1 -0
  91. package/highlevel/types/messages/ephemeral-message.cjs +35 -3
  92. package/highlevel/types/messages/ephemeral-message.d.cts +22 -2
  93. package/highlevel/types/messages/ephemeral-message.d.ts +22 -2
  94. package/highlevel/types/messages/ephemeral-message.js +35 -3
  95. package/highlevel/types/messages/message-action.cjs +8 -1
  96. package/highlevel/types/messages/message-action.d.cts +11 -1
  97. package/highlevel/types/messages/message-action.d.ts +11 -1
  98. package/highlevel/types/messages/message-action.js +8 -1
  99. package/highlevel/types/messages/message.cjs +7 -2
  100. package/highlevel/types/messages/message.d.cts +2 -2
  101. package/highlevel/types/messages/message.d.ts +2 -2
  102. package/highlevel/types/messages/message.js +8 -3
  103. package/highlevel/types/messages/rich/inner.cjs +37 -0
  104. package/highlevel/types/messages/rich/inner.d.cts +19 -0
  105. package/highlevel/types/messages/rich/inner.d.ts +19 -0
  106. package/highlevel/types/messages/rich/inner.js +37 -0
  107. package/highlevel/types/peers/full-chat.cjs +4 -0
  108. package/highlevel/types/peers/full-chat.d.cts +2 -0
  109. package/highlevel/types/peers/full-chat.d.ts +2 -0
  110. package/highlevel/types/peers/full-chat.js +4 -0
  111. package/highlevel/types/peers/typing-status.d.cts +4 -1
  112. package/highlevel/types/peers/typing-status.d.ts +4 -1
  113. package/highlevel/types/updates/ephemeral-callback-query.cjs +10 -2
  114. package/highlevel/types/updates/ephemeral-callback-query.d.cts +8 -2
  115. package/highlevel/types/updates/ephemeral-callback-query.d.ts +8 -2
  116. package/highlevel/types/updates/ephemeral-callback-query.js +10 -2
  117. package/highlevel/types/updates/user-typing-update.cjs +18 -0
  118. package/highlevel/types/updates/user-typing-update.d.cts +9 -0
  119. package/highlevel/types/updates/user-typing-update.d.ts +9 -0
  120. package/highlevel/types/updates/user-typing-update.js +18 -0
  121. package/highlevel/updates/manager.cjs +40 -28
  122. package/highlevel/updates/manager.js +40 -28
  123. package/highlevel/utils/walk-page-blocks.cjs +5 -0
  124. package/highlevel/utils/walk-page-blocks.js +5 -0
  125. package/methods.cjs +6 -0
  126. package/methods.js +6 -0
  127. package/network/mtproto-session.cjs +9 -2
  128. package/network/mtproto-session.d.cts +3 -1
  129. package/network/mtproto-session.d.ts +3 -1
  130. package/network/mtproto-session.js +9 -2
  131. package/network/network-manager.cjs +1 -1
  132. package/network/network-manager.js +1 -1
  133. package/network/session-connection.cjs +12 -6
  134. package/network/session-connection.js +12 -6
  135. package/network/session-connection.test.d.cts +1 -0
  136. package/network/session-connection.test.d.ts +1 -0
  137. package/package.json +3 -3
  138. package/tl/api-schema.json +1 -1
  139. package/tl/binary/reader.cjs +136 -93
  140. package/tl/binary/reader.js +136 -93
  141. package/tl/binary/writer.cjs +318 -207
  142. package/tl/binary/writer.js +318 -207
  143. package/tl/compat/reader.cjs +82 -0
  144. package/tl/compat/reader.js +82 -0
  145. package/tl/index.d.cts +377 -718
  146. package/tl/index.d.ts +377 -718
  147. package/tl/inner-tl.cjs +23 -7
  148. package/tl/inner-tl.js +23 -7
  149. package/tl/rpc-error.test.d.cts +1 -0
  150. package/tl/rpc-error.test.d.ts +1 -0
  151. package/utils/binary/compat.cjs +175 -29
  152. package/utils/binary/compat.js +175 -29
  153. package/utils/links/bots.cjs +9 -4
  154. package/utils/links/bots.js +9 -4
package/client.cjs CHANGED
@@ -114,9 +114,12 @@ const getPeerDialogs = require("./highlevel/methods/dialogs/get-peer-dialogs.cjs
114
114
  const iterDialogs = require("./highlevel/methods/dialogs/iter-dialogs.cjs");
115
115
  const joinChatlist = require("./highlevel/methods/dialogs/join-chatlist.cjs");
116
116
  const setFoldersOrder = require("./highlevel/methods/dialogs/set-folders-order.cjs");
117
+ const deleteAllWelcomeMessages = require("./highlevel/methods/ephemeral/delete-all-welcome-messages.cjs");
117
118
  const deleteEphemeralMessage = require("./highlevel/methods/ephemeral/delete-ephemeral-message.cjs");
119
+ const deleteWelcomeMessage = require("./highlevel/methods/ephemeral/delete-welcome-message.cjs");
118
120
  const editEphemeralMessage = require("./highlevel/methods/ephemeral/edit-ephemeral-message.cjs");
119
121
  const getEphemeralCallbackAnswer = require("./highlevel/methods/ephemeral/get-ephemeral-callback-answer.cjs");
122
+ const getWelcomeMessages = require("./highlevel/methods/ephemeral/get-welcome-messages.cjs");
120
123
  const sendEphemeralMessage = require("./highlevel/methods/ephemeral/send-ephemeral-message.cjs");
121
124
  const downloadBuffer = require("./highlevel/methods/files/download-buffer.cjs");
122
125
  const downloadChunk = require("./highlevel/methods/files/download-chunk.cjs");
@@ -832,15 +835,24 @@ TelegramClient.prototype.joinChatlist = function(...args) {
832
835
  TelegramClient.prototype.setFoldersOrder = function(...args) {
833
836
  return setFoldersOrder.setFoldersOrder(this._client, ...args);
834
837
  };
838
+ TelegramClient.prototype.deleteAllWelcomeMessages = function(...args) {
839
+ return deleteAllWelcomeMessages.deleteAllWelcomeMessages(this._client, ...args);
840
+ };
835
841
  TelegramClient.prototype.deleteEphemeralMessage = function(...args) {
836
842
  return deleteEphemeralMessage.deleteEphemeralMessage(this._client, ...args);
837
843
  };
844
+ TelegramClient.prototype.deleteWelcomeMessage = function(...args) {
845
+ return deleteWelcomeMessage.deleteWelcomeMessage(this._client, ...args);
846
+ };
838
847
  TelegramClient.prototype.editEphemeralMessage = function(...args) {
839
848
  return editEphemeralMessage.editEphemeralMessage(this._client, ...args);
840
849
  };
841
850
  TelegramClient.prototype.getEphemeralCallbackAnswer = function(...args) {
842
851
  return getEphemeralCallbackAnswer.getEphemeralCallbackAnswer(this._client, ...args);
843
852
  };
853
+ TelegramClient.prototype.getWelcomeMessages = function(...args) {
854
+ return getWelcomeMessages.getWelcomeMessages(this._client, ...args);
855
+ };
844
856
  TelegramClient.prototype.sendEphemeralMessage = function(...args) {
845
857
  return sendEphemeralMessage.sendEphemeralMessage(this._client, ...args);
846
858
  };
package/client.js CHANGED
@@ -107,9 +107,12 @@ import { getPeerDialogs } from "./highlevel/methods/dialogs/get-peer-dialogs.js"
107
107
  import { iterDialogs } from "./highlevel/methods/dialogs/iter-dialogs.js";
108
108
  import { joinChatlist } from "./highlevel/methods/dialogs/join-chatlist.js";
109
109
  import { setFoldersOrder } from "./highlevel/methods/dialogs/set-folders-order.js";
110
+ import { deleteAllWelcomeMessages } from "./highlevel/methods/ephemeral/delete-all-welcome-messages.js";
110
111
  import { deleteEphemeralMessage } from "./highlevel/methods/ephemeral/delete-ephemeral-message.js";
112
+ import { deleteWelcomeMessage } from "./highlevel/methods/ephemeral/delete-welcome-message.js";
111
113
  import { editEphemeralMessage } from "./highlevel/methods/ephemeral/edit-ephemeral-message.js";
112
114
  import { getEphemeralCallbackAnswer } from "./highlevel/methods/ephemeral/get-ephemeral-callback-answer.js";
115
+ import { getWelcomeMessages } from "./highlevel/methods/ephemeral/get-welcome-messages.js";
113
116
  import { sendEphemeralMessage } from "./highlevel/methods/ephemeral/send-ephemeral-message.js";
114
117
  import { downloadAsBuffer } from "./highlevel/methods/files/download-buffer.js";
115
118
  import { downloadChunk } from "./highlevel/methods/files/download-chunk.js";
@@ -825,15 +828,24 @@ TelegramClient.prototype.joinChatlist = function(...args) {
825
828
  TelegramClient.prototype.setFoldersOrder = function(...args) {
826
829
  return setFoldersOrder(this._client, ...args);
827
830
  };
831
+ TelegramClient.prototype.deleteAllWelcomeMessages = function(...args) {
832
+ return deleteAllWelcomeMessages(this._client, ...args);
833
+ };
828
834
  TelegramClient.prototype.deleteEphemeralMessage = function(...args) {
829
835
  return deleteEphemeralMessage(this._client, ...args);
830
836
  };
837
+ TelegramClient.prototype.deleteWelcomeMessage = function(...args) {
838
+ return deleteWelcomeMessage(this._client, ...args);
839
+ };
831
840
  TelegramClient.prototype.editEphemeralMessage = function(...args) {
832
841
  return editEphemeralMessage(this._client, ...args);
833
842
  };
834
843
  TelegramClient.prototype.getEphemeralCallbackAnswer = function(...args) {
835
844
  return getEphemeralCallbackAnswer(this._client, ...args);
836
845
  };
846
+ TelegramClient.prototype.getWelcomeMessages = function(...args) {
847
+ return getWelcomeMessages(this._client, ...args);
848
+ };
837
849
  TelegramClient.prototype.sendEphemeralMessage = function(...args) {
838
850
  return sendEphemeralMessage(this._client, ...args);
839
851
  };
@@ -31,7 +31,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
31
31
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
32
32
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
33
33
  import { ITelegramStorageProvider } from './storage/provider.js';
34
- import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, CommunityPeerRequest, DeleteBusinessMessageUpdate, DeleteEphemeralMessagesUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, EphemeralCallbackQuery, EphemeralMessage, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
34
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, CommunityPeerRequest, DeleteBusinessMessageUpdate, DeleteEphemeralMessagesUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, EphemeralCallbackQuery, EphemeralMessage, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SendableTypingStatus, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
35
35
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
36
36
  import { RawUpdateInfo } from './updates/types.js';
37
37
  import { InputStringSessionData } from './utils/string-session.js';
@@ -2163,23 +2163,40 @@ export interface TelegramClient extends ITelegramClient {
2163
2163
  * @param order New order of folders (folder IDs, where default = 0)
2164
2164
  */
2165
2165
  setFoldersOrder(order: number[]): Promise<void>;
2166
+ /**
2167
+ * Delete all welcome messages configured for a chat
2168
+ *
2169
+ * **Available**: 👤 users only
2170
+ *
2171
+ * @param chatId Chat to delete the welcome messages for
2172
+ */
2173
+ deleteAllWelcomeMessages(chatId: InputPeerLike): Promise<void>;
2166
2174
  /**
2167
2175
  * Delete a previously sent ephemeral message
2168
2176
  */
2169
2177
  deleteEphemeralMessage(params: {
2170
- /** Chat where the message was sent */
2171
- chatId: InputPeerLike;
2178
+ /** Chat where the message was sent (`null` for guest chats) */
2179
+ chatId: InputPeerLike | null;
2172
2180
  /** User the message is visible to */
2173
2181
  receiverId: InputPeerLike;
2174
2182
  /** ID of the message to delete */
2175
2183
  messageId: number;
2176
2184
  }): Promise<void>;
2185
+ /**
2186
+ * Delete a welcome message configured for a chat
2187
+ *
2188
+ * **Available**: 👤 users only
2189
+ *
2190
+ * @param chatId Chat where the welcome message is configured
2191
+ * @param messageId ID of the welcome message to delete
2192
+ */
2193
+ deleteWelcomeMessage(chatId: InputPeerLike, messageId: number): Promise<void>;
2177
2194
  /**
2178
2195
  * Edit a previously sent ephemeral message
2179
2196
  */
2180
2197
  editEphemeralMessage(params: {
2181
- /** Chat where the message was sent */
2182
- chatId: InputPeerLike;
2198
+ /** Chat where the message was sent (`null` for guest chats) */
2199
+ chatId: InputPeerLike | null;
2183
2200
  /** User the message is visible to */
2184
2201
  receiverId: InputPeerLike;
2185
2202
  /** ID of the message to edit */
@@ -2188,8 +2205,21 @@ export interface TelegramClient extends ITelegramClient {
2188
2205
  text?: InputText;
2189
2206
  /** New media of the message */
2190
2207
  media?: InputMediaLike;
2208
+ /** New rich message content of the message */
2209
+ richMessage?: InputRichMessage;
2191
2210
  /** New reply markup of the message */
2192
2211
  replyMarkup?: ReplyMarkup;
2212
+ /** Whether this message is a welcome message template for the chat */
2213
+ welcome?: boolean;
2214
+ /**
2215
+ * Whether to invert the media position.
2216
+ *
2217
+ * Currently only supported for web previews and makes the
2218
+ * client render the preview above the caption and not below.
2219
+ */
2220
+ invertMedia?: boolean;
2221
+ /** Cache for the uploaded rich message media, see {@link createRichStreamingDraft} */
2222
+ uploadCache?: RichMediaUploadCache;
2193
2223
  /**
2194
2224
  * Whether to dispatch the returned updates
2195
2225
  * to the client's update handler.
@@ -2222,17 +2252,27 @@ export interface TelegramClient extends ITelegramClient {
2222
2252
  */
2223
2253
  fireAndForget?: boolean;
2224
2254
  }): Promise<tl.messages.TypeBotCallbackAnswer>;
2255
+ /**
2256
+ * Get the welcome messages configured for a chat
2257
+ *
2258
+ * **Available**: 👤 users only
2259
+ *
2260
+ * @param chatId Chat to get the welcome messages for
2261
+ */
2262
+ getWelcomeMessages(chatId: InputPeerLike): Promise<EphemeralMessage[]>;
2225
2263
  /**
2226
2264
  * Send an ephemeral message — a message that is only visible
2227
2265
  * to a single user in a chat and is not persisted in the chat history.
2228
2266
  *
2229
- * @param chatId ID of the chat to send the message to
2267
+ * @param chatId ID of the chat to send the message to (`null` for guest chats, where `queryId` is used instead)
2230
2268
  * @param receiverId ID of the user the message should be visible to
2231
2269
  * @param text Text of the message
2232
2270
  */
2233
- sendEphemeralMessage(chatId: InputPeerLike, receiverId: InputPeerLike, text: InputText, params?: {
2271
+ sendEphemeralMessage(chatId: InputPeerLike | null, receiverId: InputPeerLike, text: InputText, params?: {
2234
2272
  /** Media to be attached to the message */
2235
2273
  media?: InputMediaLike;
2274
+ /** Rich message content to be sent instead of the plain text */
2275
+ richMessage?: InputRichMessage;
2236
2276
  /** Message to reply to */
2237
2277
  replyTo?: number;
2238
2278
  /** Ephemeral message to reply to */
@@ -2241,6 +2281,21 @@ export interface TelegramClient extends ITelegramClient {
2241
2281
  replyMarkup?: ReplyMarkup;
2242
2282
  /** For guest chat bots, ID of the query that this message is sent in response to */
2243
2283
  queryId?: tl.Long;
2284
+ /** Whether to send this message as a welcome message template for the chat */
2285
+ welcome?: boolean;
2286
+ /** Whether to anchor this message to the message it replies to */
2287
+ anchor?: boolean;
2288
+ /**
2289
+ * Whether to invert the media position.
2290
+ *
2291
+ * Currently only supported for web previews and makes the
2292
+ * client render the preview above the caption and not below.
2293
+ */
2294
+ invertMedia?: boolean;
2295
+ /** Whether to forbid forwarding this message */
2296
+ forbidForwards?: boolean;
2297
+ /** Cache for the uploaded rich message media, see {@link createRichStreamingDraft} */
2298
+ uploadCache?: RichMediaUploadCache;
2244
2299
  /**
2245
2300
  * Whether to dispatch the returned updates
2246
2301
  * to the client's update handler.
@@ -2738,6 +2793,16 @@ export interface TelegramClient extends ITelegramClient {
2738
2793
  shouldDispatch?: true;
2739
2794
  /** Whether to use TON currency for payment */
2740
2795
  ton?: boolean;
2796
+ /**
2797
+ * Whether to buy the gift anonymously
2798
+ * (i.e. if the recipient chooses to display the gift
2799
+ * on their profile, your name won't be visible)
2800
+ *
2801
+ * @default `true`
2802
+ */
2803
+ anonymous?: boolean;
2804
+ /** Message to send along with the gift */
2805
+ message?: InputText;
2741
2806
  }): Promise<Message | null>;
2742
2807
  /**
2743
2808
  * Get a list of star gifts up for resale
@@ -3474,6 +3539,8 @@ export interface TelegramClient extends ITelegramClient {
3474
3539
  * New message media
3475
3540
  */
3476
3541
  media?: InputMediaLike;
3542
+ /** New rich message content */
3543
+ richMessage?: InputRichMessage;
3477
3544
  /**
3478
3545
  * Whether to disable links preview in this message
3479
3546
  */
@@ -3489,12 +3556,14 @@ export interface TelegramClient extends ITelegramClient {
3489
3556
  */
3490
3557
  scheduleDate?: Date | number;
3491
3558
  /**
3492
- * For media, upload progress callback.
3559
+ * For media and rich message attachments, upload progress callback.
3493
3560
  *
3494
3561
  * @param uploaded Number of bytes uploaded
3495
3562
  * @param total Total file size in bytes
3496
3563
  */
3497
3564
  progressCallback?: (uploaded: number, total: number) => void;
3565
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
3566
+ uploadCache?: RichMediaUploadCache;
3498
3567
  /**
3499
3568
  * Whether to dispatch the edit message event
3500
3569
  * to the client's update handler.
@@ -4443,7 +4512,7 @@ export interface TelegramClient extends ITelegramClient {
4443
4512
  * @param [status='typing'] Typing status
4444
4513
  * @param params
4445
4514
  */
4446
- sendTyping(chatId: InputPeerLike, status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction, params?: {
4515
+ sendTyping(chatId: InputPeerLike, status?: SendableTypingStatus | tl.TypeSendMessageAction, params?: {
4447
4516
  /**
4448
4517
  * For `upload_*` and history import actions, progress of the upload
4449
4518
  */
@@ -4487,7 +4556,7 @@ export interface TelegramClient extends ITelegramClient {
4487
4556
  *
4488
4557
  * @default `typing`
4489
4558
  */
4490
- status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction;
4559
+ status?: SendableTypingStatus | tl.TypeSendMessageAction;
4491
4560
  /**
4492
4561
  * For `upload_*` and history import actions, progress of the upload
4493
4562
  */
@@ -31,7 +31,7 @@ import { InputStarsAmount } from './methods/premium/_normalize-stars-amount.js';
31
31
  import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
32
32
  import { CanSendStoryResult } from './methods/stories/can-send-story.js';
33
33
  import { ITelegramStorageProvider } from './storage/provider.js';
34
- import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, CommunityPeerRequest, DeleteBusinessMessageUpdate, DeleteEphemeralMessagesUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, EphemeralCallbackQuery, EphemeralMessage, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
34
+ import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Audio, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, CommunityPeerRequest, DeleteBusinessMessageUpdate, DeleteEphemeralMessagesUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, EphemeralCallbackQuery, EphemeralMessage, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputDocumentId, InputFileLike, InputInlineMessage, InputInlineResult, InputMediaAudio, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputRichMessage, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, RichMediaUploadCache, SavedStarGift, SendableTypingStatus, SentCode, StarGift, StarGiftUnique, StarGiftValue, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
35
35
  import { ParsedUpdateHandlerParams } from './updates/parsed.js';
36
36
  import { RawUpdateInfo } from './updates/types.js';
37
37
  import { InputStringSessionData } from './utils/string-session.js';
@@ -2163,23 +2163,40 @@ export interface TelegramClient extends ITelegramClient {
2163
2163
  * @param order New order of folders (folder IDs, where default = 0)
2164
2164
  */
2165
2165
  setFoldersOrder(order: number[]): Promise<void>;
2166
+ /**
2167
+ * Delete all welcome messages configured for a chat
2168
+ *
2169
+ * **Available**: 👤 users only
2170
+ *
2171
+ * @param chatId Chat to delete the welcome messages for
2172
+ */
2173
+ deleteAllWelcomeMessages(chatId: InputPeerLike): Promise<void>;
2166
2174
  /**
2167
2175
  * Delete a previously sent ephemeral message
2168
2176
  */
2169
2177
  deleteEphemeralMessage(params: {
2170
- /** Chat where the message was sent */
2171
- chatId: InputPeerLike;
2178
+ /** Chat where the message was sent (`null` for guest chats) */
2179
+ chatId: InputPeerLike | null;
2172
2180
  /** User the message is visible to */
2173
2181
  receiverId: InputPeerLike;
2174
2182
  /** ID of the message to delete */
2175
2183
  messageId: number;
2176
2184
  }): Promise<void>;
2185
+ /**
2186
+ * Delete a welcome message configured for a chat
2187
+ *
2188
+ * **Available**: 👤 users only
2189
+ *
2190
+ * @param chatId Chat where the welcome message is configured
2191
+ * @param messageId ID of the welcome message to delete
2192
+ */
2193
+ deleteWelcomeMessage(chatId: InputPeerLike, messageId: number): Promise<void>;
2177
2194
  /**
2178
2195
  * Edit a previously sent ephemeral message
2179
2196
  */
2180
2197
  editEphemeralMessage(params: {
2181
- /** Chat where the message was sent */
2182
- chatId: InputPeerLike;
2198
+ /** Chat where the message was sent (`null` for guest chats) */
2199
+ chatId: InputPeerLike | null;
2183
2200
  /** User the message is visible to */
2184
2201
  receiverId: InputPeerLike;
2185
2202
  /** ID of the message to edit */
@@ -2188,8 +2205,21 @@ export interface TelegramClient extends ITelegramClient {
2188
2205
  text?: InputText;
2189
2206
  /** New media of the message */
2190
2207
  media?: InputMediaLike;
2208
+ /** New rich message content of the message */
2209
+ richMessage?: InputRichMessage;
2191
2210
  /** New reply markup of the message */
2192
2211
  replyMarkup?: ReplyMarkup;
2212
+ /** Whether this message is a welcome message template for the chat */
2213
+ welcome?: boolean;
2214
+ /**
2215
+ * Whether to invert the media position.
2216
+ *
2217
+ * Currently only supported for web previews and makes the
2218
+ * client render the preview above the caption and not below.
2219
+ */
2220
+ invertMedia?: boolean;
2221
+ /** Cache for the uploaded rich message media, see {@link createRichStreamingDraft} */
2222
+ uploadCache?: RichMediaUploadCache;
2193
2223
  /**
2194
2224
  * Whether to dispatch the returned updates
2195
2225
  * to the client's update handler.
@@ -2222,17 +2252,27 @@ export interface TelegramClient extends ITelegramClient {
2222
2252
  */
2223
2253
  fireAndForget?: boolean;
2224
2254
  }): Promise<tl.messages.TypeBotCallbackAnswer>;
2255
+ /**
2256
+ * Get the welcome messages configured for a chat
2257
+ *
2258
+ * **Available**: 👤 users only
2259
+ *
2260
+ * @param chatId Chat to get the welcome messages for
2261
+ */
2262
+ getWelcomeMessages(chatId: InputPeerLike): Promise<EphemeralMessage[]>;
2225
2263
  /**
2226
2264
  * Send an ephemeral message — a message that is only visible
2227
2265
  * to a single user in a chat and is not persisted in the chat history.
2228
2266
  *
2229
- * @param chatId ID of the chat to send the message to
2267
+ * @param chatId ID of the chat to send the message to (`null` for guest chats, where `queryId` is used instead)
2230
2268
  * @param receiverId ID of the user the message should be visible to
2231
2269
  * @param text Text of the message
2232
2270
  */
2233
- sendEphemeralMessage(chatId: InputPeerLike, receiverId: InputPeerLike, text: InputText, params?: {
2271
+ sendEphemeralMessage(chatId: InputPeerLike | null, receiverId: InputPeerLike, text: InputText, params?: {
2234
2272
  /** Media to be attached to the message */
2235
2273
  media?: InputMediaLike;
2274
+ /** Rich message content to be sent instead of the plain text */
2275
+ richMessage?: InputRichMessage;
2236
2276
  /** Message to reply to */
2237
2277
  replyTo?: number;
2238
2278
  /** Ephemeral message to reply to */
@@ -2241,6 +2281,21 @@ export interface TelegramClient extends ITelegramClient {
2241
2281
  replyMarkup?: ReplyMarkup;
2242
2282
  /** For guest chat bots, ID of the query that this message is sent in response to */
2243
2283
  queryId?: tl.Long;
2284
+ /** Whether to send this message as a welcome message template for the chat */
2285
+ welcome?: boolean;
2286
+ /** Whether to anchor this message to the message it replies to */
2287
+ anchor?: boolean;
2288
+ /**
2289
+ * Whether to invert the media position.
2290
+ *
2291
+ * Currently only supported for web previews and makes the
2292
+ * client render the preview above the caption and not below.
2293
+ */
2294
+ invertMedia?: boolean;
2295
+ /** Whether to forbid forwarding this message */
2296
+ forbidForwards?: boolean;
2297
+ /** Cache for the uploaded rich message media, see {@link createRichStreamingDraft} */
2298
+ uploadCache?: RichMediaUploadCache;
2244
2299
  /**
2245
2300
  * Whether to dispatch the returned updates
2246
2301
  * to the client's update handler.
@@ -2738,6 +2793,16 @@ export interface TelegramClient extends ITelegramClient {
2738
2793
  shouldDispatch?: true;
2739
2794
  /** Whether to use TON currency for payment */
2740
2795
  ton?: boolean;
2796
+ /**
2797
+ * Whether to buy the gift anonymously
2798
+ * (i.e. if the recipient chooses to display the gift
2799
+ * on their profile, your name won't be visible)
2800
+ *
2801
+ * @default `true`
2802
+ */
2803
+ anonymous?: boolean;
2804
+ /** Message to send along with the gift */
2805
+ message?: InputText;
2741
2806
  }): Promise<Message | null>;
2742
2807
  /**
2743
2808
  * Get a list of star gifts up for resale
@@ -3474,6 +3539,8 @@ export interface TelegramClient extends ITelegramClient {
3474
3539
  * New message media
3475
3540
  */
3476
3541
  media?: InputMediaLike;
3542
+ /** New rich message content */
3543
+ richMessage?: InputRichMessage;
3477
3544
  /**
3478
3545
  * Whether to disable links preview in this message
3479
3546
  */
@@ -3489,12 +3556,14 @@ export interface TelegramClient extends ITelegramClient {
3489
3556
  */
3490
3557
  scheduleDate?: Date | number;
3491
3558
  /**
3492
- * For media, upload progress callback.
3559
+ * For media and rich message attachments, upload progress callback.
3493
3560
  *
3494
3561
  * @param uploaded Number of bytes uploaded
3495
3562
  * @param total Total file size in bytes
3496
3563
  */
3497
3564
  progressCallback?: (uploaded: number, total: number) => void;
3565
+ /** Cache for uploaded rich message media, see {@link createRichStreamingDraft} */
3566
+ uploadCache?: RichMediaUploadCache;
3498
3567
  /**
3499
3568
  * Whether to dispatch the edit message event
3500
3569
  * to the client's update handler.
@@ -4443,7 +4512,7 @@ export interface TelegramClient extends ITelegramClient {
4443
4512
  * @param [status='typing'] Typing status
4444
4513
  * @param params
4445
4514
  */
4446
- sendTyping(chatId: InputPeerLike, status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction, params?: {
4515
+ sendTyping(chatId: InputPeerLike, status?: SendableTypingStatus | tl.TypeSendMessageAction, params?: {
4447
4516
  /**
4448
4517
  * For `upload_*` and history import actions, progress of the upload
4449
4518
  */
@@ -4487,7 +4556,7 @@ export interface TelegramClient extends ITelegramClient {
4487
4556
  *
4488
4557
  * @default `typing`
4489
4558
  */
4490
- status?: Exclude<TypingStatus, 'interaction' | 'interaction_seen'> | tl.TypeSendMessageAction;
4559
+ status?: SendableTypingStatus | tl.TypeSendMessageAction;
4491
4560
  /**
4492
4561
  * For `upload_*` and history import actions, progress of the upload
4493
4562
  */
@@ -0,0 +1,45 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const errors = require("../../../types/errors.cjs");
9
+ const peerUtils = require("../../../utils/peer-utils.cjs");
10
+ const peersIndex = require("../../types/peers/peers-index.cjs");
11
+ const resolvePeer = require("../users/resolve-peer.cjs");
12
+ const batchedQueries = require("./batched-queries.cjs");
13
+ async function _buildPeersIndex(client, context, peersToFetch) {
14
+ const peers = new peersIndex.PeersIndex();
15
+ await Promise.all(peersToFetch.map(async (peer) => {
16
+ const id = peerUtils.getMarkedPeerId(peer);
17
+ let cached = await client.storage.peers.getCompleteById(id);
18
+ if (!cached) {
19
+ cached = await batchedQueries._getRawPeerBatched(client, await resolvePeer.resolvePeer(client, peer));
20
+ }
21
+ if (!cached) {
22
+ throw new errors.MtTypeAssertionError(`${context} (@ getCompleteById)`, "user | chat", "null");
23
+ }
24
+ switch (cached._) {
25
+ case "user":
26
+ peers.users.set(cached.id, cached);
27
+ break;
28
+ case "chat":
29
+ case "chatForbidden":
30
+ case "channel":
31
+ case "channelForbidden":
32
+ peers.chats.set(cached.id, cached);
33
+ break;
34
+ default:
35
+ throw new errors.MtTypeAssertionError(
36
+ `${context} (@ getCompleteById)`,
37
+ "user | chat | channel",
38
+ // not very accurate, but good enough
39
+ cached._
40
+ );
41
+ }
42
+ }));
43
+ return peers;
44
+ }
45
+ exports._buildPeersIndex = _buildPeersIndex;
@@ -0,0 +1,13 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { PeersIndex } from '../../types/peers/peers-index.js';
4
+ /**
5
+ * Build a {@link PeersIndex} for the given peers, using the local storage
6
+ * and falling back to fetching them from the server.
7
+ *
8
+ * Useful for responses that reference peers without including them.
9
+ *
10
+ * @internal
11
+ * @noemit
12
+ */
13
+ export declare function _buildPeersIndex(client: ITelegramClient, context: string, peersToFetch: (tl.TypePeer | tl.TypeInputPeer)[]): Promise<PeersIndex>;
@@ -0,0 +1,13 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { PeersIndex } from '../../types/peers/peers-index.js';
4
+ /**
5
+ * Build a {@link PeersIndex} for the given peers, using the local storage
6
+ * and falling back to fetching them from the server.
7
+ *
8
+ * Useful for responses that reference peers without including them.
9
+ *
10
+ * @internal
11
+ * @noemit
12
+ */
13
+ export declare function _buildPeersIndex(client: ITelegramClient, context: string, peersToFetch: (tl.TypePeer | tl.TypeInputPeer)[]): Promise<PeersIndex>;
@@ -0,0 +1,40 @@
1
+ import { MtTypeAssertionError } from "../../../types/errors.js";
2
+ import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
+ import { PeersIndex } from "../../types/peers/peers-index.js";
4
+ import { resolvePeer } from "../users/resolve-peer.js";
5
+ import { _getRawPeerBatched } from "./batched-queries.js";
6
+ async function _buildPeersIndex(client, context, peersToFetch) {
7
+ const peers = new PeersIndex();
8
+ await Promise.all(peersToFetch.map(async (peer) => {
9
+ const id = getMarkedPeerId(peer);
10
+ let cached = await client.storage.peers.getCompleteById(id);
11
+ if (!cached) {
12
+ cached = await _getRawPeerBatched(client, await resolvePeer(client, peer));
13
+ }
14
+ if (!cached) {
15
+ throw new MtTypeAssertionError(`${context} (@ getCompleteById)`, "user | chat", "null");
16
+ }
17
+ switch (cached._) {
18
+ case "user":
19
+ peers.users.set(cached.id, cached);
20
+ break;
21
+ case "chat":
22
+ case "chatForbidden":
23
+ case "channel":
24
+ case "channelForbidden":
25
+ peers.chats.set(cached.id, cached);
26
+ break;
27
+ default:
28
+ throw new MtTypeAssertionError(
29
+ `${context} (@ getCompleteById)`,
30
+ "user | chat | channel",
31
+ // not very accurate, but good enough
32
+ cached._
33
+ );
34
+ }
35
+ }));
36
+ return peers;
37
+ }
38
+ export {
39
+ _buildPeersIndex
40
+ };
@@ -0,0 +1,17 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const typeAssertions = require("../../../utils/type-assertions.cjs");
9
+ const resolvePeer = require("../users/resolve-peer.cjs");
10
+ async function deleteAllWelcomeMessages(client, chatId) {
11
+ const r = await client.call({
12
+ _: "ephemeral.deleteAllWelcomeMessages",
13
+ peer: await resolvePeer.resolvePeer(client, chatId)
14
+ });
15
+ typeAssertions.assertTrue("ephemeral.deleteAllWelcomeMessages", r);
16
+ }
17
+ exports.deleteAllWelcomeMessages = deleteAllWelcomeMessages;
@@ -0,0 +1,8 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ /**
4
+ * Delete all welcome messages configured for a chat
5
+ *
6
+ * @param chatId Chat to delete the welcome messages for
7
+ */
8
+ export declare function deleteAllWelcomeMessages(client: ITelegramClient, chatId: InputPeerLike): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/index.js';
3
+ /**
4
+ * Delete all welcome messages configured for a chat
5
+ *
6
+ * @param chatId Chat to delete the welcome messages for
7
+ */
8
+ export declare function deleteAllWelcomeMessages(client: ITelegramClient, chatId: InputPeerLike): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import { assertTrue } from "../../../utils/type-assertions.js";
2
+ import { resolvePeer } from "../users/resolve-peer.js";
3
+ async function deleteAllWelcomeMessages(client, chatId) {
4
+ const r = await client.call({
5
+ _: "ephemeral.deleteAllWelcomeMessages",
6
+ peer: await resolvePeer(client, chatId)
7
+ });
8
+ assertTrue("ephemeral.deleteAllWelcomeMessages", r);
9
+ }
10
+ export {
11
+ deleteAllWelcomeMessages
12
+ };
@@ -11,7 +11,7 @@ async function deleteEphemeralMessage(client, params) {
11
11
  const { chatId, receiverId, messageId } = params;
12
12
  const r = await client.call({
13
13
  _: "ephemeral.deleteMessage",
14
- peer: await resolvePeer.resolvePeer(client, chatId),
14
+ peer: chatId !== null ? await resolvePeer.resolvePeer(client, chatId) : void 0,
15
15
  receiverId: await resolvePeer.resolveUser(client, receiverId),
16
16
  id: messageId
17
17
  });
@@ -4,8 +4,8 @@ import { InputPeerLike } from '../../types/index.js';
4
4
  * Delete a previously sent ephemeral message
5
5
  */
6
6
  export declare function deleteEphemeralMessage(client: ITelegramClient, params: {
7
- /** Chat where the message was sent */
8
- chatId: InputPeerLike;
7
+ /** Chat where the message was sent (`null` for guest chats) */
8
+ chatId: InputPeerLike | null;
9
9
  /** User the message is visible to */
10
10
  receiverId: InputPeerLike;
11
11
  /** ID of the message to delete */