@mtcute/core 0.30.3 → 0.32.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.
- package/client.cjs +85 -0
- package/client.js +85 -0
- package/highlevel/client.d.cts +411 -116
- package/highlevel/client.d.ts +411 -116
- package/highlevel/methods/auth/sign-in-qr.cjs +2 -0
- package/highlevel/methods/auth/sign-in-qr.js +2 -0
- package/highlevel/methods/auth/sign-in-qr.test.d.cts +1 -0
- package/highlevel/methods/auth/sign-in-qr.test.d.ts +1 -0
- package/highlevel/methods/chats/build-peers-index.cjs +45 -0
- package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
- package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
- package/highlevel/methods/chats/build-peers-index.js +40 -0
- package/highlevel/methods/chats/join-chat.cjs +1 -1
- package/highlevel/methods/chats/join-chat.d.cts +2 -1
- package/highlevel/methods/chats/join-chat.d.ts +2 -1
- package/highlevel/methods/chats/join-chat.js +1 -1
- package/highlevel/methods/chats/transfer-chat-ownership.cjs +6 -17
- package/highlevel/methods/chats/transfer-chat-ownership.js +6 -17
- package/highlevel/methods/communities/ban-community-participant.cjs +30 -0
- package/highlevel/methods/communities/ban-community-participant.d.cts +20 -0
- package/highlevel/methods/communities/ban-community-participant.d.ts +20 -0
- package/highlevel/methods/communities/ban-community-participant.js +25 -0
- package/highlevel/methods/communities/create-community.cjs +29 -0
- package/highlevel/methods/communities/create-community.d.cts +22 -0
- package/highlevel/methods/communities/create-community.d.ts +22 -0
- package/highlevel/methods/communities/create-community.js +24 -0
- package/highlevel/methods/communities/get-community-link-requests.cjs +27 -0
- package/highlevel/methods/communities/get-community-link-requests.d.cts +17 -0
- package/highlevel/methods/communities/get-community-link-requests.d.ts +17 -0
- package/highlevel/methods/communities/get-community-link-requests.js +22 -0
- package/highlevel/methods/communities/get-community-participant-chats.cjs +24 -0
- package/highlevel/methods/communities/get-community-participant-chats.d.cts +17 -0
- package/highlevel/methods/communities/get-community-participant-chats.d.ts +17 -0
- package/highlevel/methods/communities/get-community-participant-chats.js +19 -0
- package/highlevel/methods/communities/get-joined-communities.cjs +21 -0
- package/highlevel/methods/communities/get-joined-communities.d.cts +6 -0
- package/highlevel/methods/communities/get-joined-communities.d.ts +6 -0
- package/highlevel/methods/communities/get-joined-communities.js +16 -0
- package/highlevel/methods/communities/hide-community-link-request.cjs +30 -0
- package/highlevel/methods/communities/hide-community-link-request.d.cts +22 -0
- package/highlevel/methods/communities/hide-community-link-request.d.ts +22 -0
- package/highlevel/methods/communities/hide-community-link-request.js +25 -0
- package/highlevel/methods/communities/link-community-peer.cjs +32 -0
- package/highlevel/methods/communities/link-community-peer.d.cts +22 -0
- package/highlevel/methods/communities/link-community-peer.d.ts +22 -0
- package/highlevel/methods/communities/link-community-peer.js +27 -0
- package/highlevel/methods/communities/toggle-community-collapsed.cjs +18 -0
- package/highlevel/methods/communities/toggle-community-collapsed.d.cts +16 -0
- package/highlevel/methods/communities/toggle-community-collapsed.d.ts +16 -0
- package/highlevel/methods/communities/toggle-community-collapsed.js +13 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +20 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +13 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +13 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.js +15 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +41 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +39 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +39 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.js +36 -0
- package/highlevel/methods/ephemeral/find-in-update.cjs +27 -0
- package/highlevel/methods/ephemeral/find-in-update.d.cts +8 -0
- package/highlevel/methods/ephemeral/find-in-update.d.ts +8 -0
- package/highlevel/methods/ephemeral/find-in-update.js +22 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.cjs +31 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.cts +29 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.ts +29 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.js +26 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +48 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +47 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +47 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.js +43 -0
- package/highlevel/methods/files/download-iterable.cjs +7 -2
- package/highlevel/methods/files/download-iterable.js +7 -2
- package/highlevel/methods/files/download-iterable.test.d.cts +1 -0
- package/highlevel/methods/files/download-iterable.test.d.ts +1 -0
- package/highlevel/methods/files/download-stream.cjs +5 -6
- package/highlevel/methods/files/download-stream.js +5 -6
- package/highlevel/methods/files/normalize-input-media.cjs +25 -4
- package/highlevel/methods/files/normalize-input-media.js +25 -4
- package/highlevel/methods/forums/create-forum-topic.d.cts +7 -0
- package/highlevel/methods/forums/create-forum-topic.d.ts +7 -0
- package/highlevel/methods/forums/delete-forum-topic-history.d.cts +1 -1
- package/highlevel/methods/forums/delete-forum-topic-history.d.ts +1 -1
- package/highlevel/methods/forums/edit-forum-topic.cjs +2 -2
- package/highlevel/methods/forums/edit-forum-topic.d.cts +2 -2
- package/highlevel/methods/forums/edit-forum-topic.d.ts +2 -2
- package/highlevel/methods/forums/edit-forum-topic.js +2 -2
- package/highlevel/methods/forums/get-forum-topics-by-id.cjs +5 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.d.cts +9 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.d.ts +9 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.js +5 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.test.d.cts +1 -0
- package/highlevel/methods/forums/get-forum-topics-by-id.test.d.ts +1 -0
- package/highlevel/methods/forums/get-forum-topics.cjs +1 -1
- package/highlevel/methods/forums/get-forum-topics.js +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.d.cts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.d.ts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-pinned.d.cts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-pinned.d.ts +1 -1
- package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +3 -3
- package/highlevel/methods/forums/toggle-general-topic-hidden.js +4 -4
- package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
- package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
- package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
- package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
- package/highlevel/methods/messages/forward-messages.cjs +1 -0
- package/highlevel/methods/messages/forward-messages.d.cts +2 -0
- package/highlevel/methods/messages/forward-messages.d.ts +2 -0
- package/highlevel/methods/messages/forward-messages.js +1 -0
- package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
- package/highlevel/methods/messages/normalize-rich-message.js +3 -0
- package/highlevel/methods/messages/send-common.d.cts +7 -1
- package/highlevel/methods/messages/send-common.d.ts +7 -1
- package/highlevel/methods/messages/send-text.cjs +70 -35
- package/highlevel/methods/messages/send-text.js +70 -35
- package/highlevel/methods/messages/send-typing.d.cts +3 -3
- package/highlevel/methods/messages/send-typing.d.ts +3 -3
- package/highlevel/methods/messages/set-typing.cjs +1 -1
- package/highlevel/methods/messages/set-typing.d.cts +2 -2
- package/highlevel/methods/messages/set-typing.d.ts +2 -2
- package/highlevel/methods/messages/set-typing.js +1 -1
- package/highlevel/methods/users/resolve-peer.cjs +11 -1
- package/highlevel/methods/users/resolve-peer.js +11 -1
- package/highlevel/methods.d.cts +19 -0
- package/highlevel/methods.d.ts +19 -0
- package/highlevel/storage/service/peers.cjs +25 -0
- package/highlevel/storage/service/peers.js +25 -0
- package/highlevel/storage/service/peers.test.d.cts +1 -0
- package/highlevel/storage/service/peers.test.d.ts +1 -0
- package/highlevel/types/bots/keyboards/builder.cjs +5 -5
- package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
- package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
- package/highlevel/types/bots/keyboards/builder.js +5 -5
- package/highlevel/types/bots/keyboards/factories.cjs +51 -103
- package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
- package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
- package/highlevel/types/bots/keyboards/factories.js +51 -103
- package/highlevel/types/bots/keyboards/index.d.cts +3 -3
- package/highlevel/types/bots/keyboards/index.d.ts +3 -3
- package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
- package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
- package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
- package/highlevel/types/bots/keyboards/normalize.js +126 -0
- package/highlevel/types/bots/keyboards/types.d.cts +160 -4
- package/highlevel/types/bots/keyboards/types.d.ts +160 -4
- package/highlevel/types/conversation.cjs +8 -0
- package/highlevel/types/conversation.d.cts +1 -0
- package/highlevel/types/conversation.d.ts +1 -0
- package/highlevel/types/conversation.js +10 -2
- package/highlevel/types/conversation.test.d.cts +1 -0
- package/highlevel/types/conversation.test.d.ts +1 -0
- package/highlevel/types/messages/dialog.cjs +8 -1
- package/highlevel/types/messages/dialog.d.cts +3 -0
- package/highlevel/types/messages/dialog.d.ts +3 -0
- package/highlevel/types/messages/dialog.js +8 -1
- package/highlevel/types/messages/dialog.test.d.cts +1 -0
- package/highlevel/types/messages/dialog.test.d.ts +1 -0
- package/highlevel/types/messages/ephemeral-message.cjs +135 -0
- package/highlevel/types/messages/ephemeral-message.d.cts +75 -0
- package/highlevel/types/messages/ephemeral-message.d.ts +75 -0
- package/highlevel/types/messages/ephemeral-message.js +130 -0
- package/highlevel/types/messages/index.d.cts +1 -0
- package/highlevel/types/messages/index.d.ts +1 -0
- package/highlevel/types/messages/message-action.cjs +14 -1
- package/highlevel/types/messages/message-action.d.cts +18 -1
- package/highlevel/types/messages/message-action.d.ts +18 -1
- package/highlevel/types/messages/message-action.js +14 -1
- package/highlevel/types/messages/message.cjs +7 -2
- package/highlevel/types/messages/message.d.cts +2 -2
- package/highlevel/types/messages/message.d.ts +2 -2
- package/highlevel/types/messages/message.js +8 -3
- package/highlevel/types/messages/replied-message.cjs +5 -1
- package/highlevel/types/messages/replied-message.d.cts +5 -1
- package/highlevel/types/messages/replied-message.d.ts +5 -1
- package/highlevel/types/messages/replied-message.js +5 -1
- package/highlevel/types/messages/rich/inner.cjs +37 -0
- package/highlevel/types/messages/rich/inner.d.cts +19 -0
- package/highlevel/types/messages/rich/inner.d.ts +19 -0
- package/highlevel/types/messages/rich/inner.js +37 -0
- package/highlevel/types/peers/chat.cjs +23 -3
- package/highlevel/types/peers/chat.d.cts +8 -3
- package/highlevel/types/peers/chat.d.ts +8 -3
- package/highlevel/types/peers/chat.js +24 -4
- package/highlevel/types/peers/community-peer.cjs +60 -0
- package/highlevel/types/peers/community-peer.d.cts +37 -0
- package/highlevel/types/peers/community-peer.d.ts +37 -0
- package/highlevel/types/peers/community-peer.js +55 -0
- package/highlevel/types/peers/full-chat.cjs +24 -5
- package/highlevel/types/peers/full-chat.d.cts +7 -0
- package/highlevel/types/peers/full-chat.d.ts +7 -0
- package/highlevel/types/peers/full-chat.js +24 -5
- package/highlevel/types/peers/index.d.cts +1 -0
- package/highlevel/types/peers/index.d.ts +1 -0
- package/highlevel/types/peers/peer.cjs +2 -0
- package/highlevel/types/peers/peer.js +2 -0
- package/highlevel/types/peers/typing-status.d.cts +4 -1
- package/highlevel/types/peers/typing-status.d.ts +4 -1
- package/highlevel/types/peers/user.cjs +6 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +6 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.cjs +27 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.d.cts +15 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.d.ts +15 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.js +22 -0
- package/highlevel/types/updates/ephemeral-callback-query.cjs +69 -0
- package/highlevel/types/updates/ephemeral-callback-query.d.cts +44 -0
- package/highlevel/types/updates/ephemeral-callback-query.d.ts +44 -0
- package/highlevel/types/updates/ephemeral-callback-query.js +64 -0
- package/highlevel/types/updates/index.d.cts +16 -2
- package/highlevel/types/updates/index.d.ts +16 -2
- package/highlevel/types/updates/parse-update.cjs +12 -1
- package/highlevel/types/updates/parse-update.js +12 -1
- package/highlevel/types/updates/user-typing-update.cjs +18 -0
- package/highlevel/types/updates/user-typing-update.d.cts +9 -0
- package/highlevel/types/updates/user-typing-update.d.ts +9 -0
- package/highlevel/types/updates/user-typing-update.js +18 -0
- package/highlevel/updates/manager.cjs +71 -41
- package/highlevel/updates/manager.d.cts +1 -0
- package/highlevel/updates/manager.d.ts +1 -0
- package/highlevel/updates/manager.js +71 -41
- package/highlevel/updates/manager.test.d.cts +1 -0
- package/highlevel/updates/manager.test.d.ts +1 -0
- package/highlevel/utils/stream-utils.cjs +8 -4
- package/highlevel/utils/stream-utils.js +8 -4
- package/highlevel/utils/stream-utils.test.d.cts +1 -0
- package/highlevel/utils/stream-utils.test.d.ts +1 -0
- package/highlevel/utils/walk-page-blocks.cjs +9 -0
- package/highlevel/utils/walk-page-blocks.js +9 -0
- package/index.cjs +10 -0
- package/index.js +11 -1
- package/methods.cjs +33 -0
- package/methods.js +33 -0
- package/network/client.cjs +4 -3
- package/network/client.d.cts +1 -0
- package/network/client.d.ts +1 -0
- package/network/client.js +4 -3
- package/network/middlewares/flood-waiter.cjs +2 -2
- package/network/middlewares/flood-waiter.js +2 -2
- package/network/middlewares/internal-errors.cjs +1 -1
- package/network/middlewares/internal-errors.js +1 -1
- package/network/middlewares/media-throttle.cjs +1 -1
- package/network/middlewares/media-throttle.js +1 -1
- package/network/mtproto-session.cjs +9 -2
- package/network/mtproto-session.d.cts +3 -1
- package/network/mtproto-session.d.ts +3 -1
- package/network/mtproto-session.js +9 -2
- package/network/mtproxy/index.cjs +4 -3
- package/network/mtproxy/index.d.cts +2 -2
- package/network/mtproxy/index.d.ts +2 -2
- package/network/mtproxy/index.js +4 -3
- package/network/network-manager.cjs +44 -16
- package/network/network-manager.d.cts +10 -3
- package/network/network-manager.d.ts +10 -3
- package/network/network-manager.js +45 -17
- package/network/network-manager.test.d.cts +1 -0
- package/network/network-manager.test.d.ts +1 -0
- package/network/persistent-connection.cjs +10 -2
- package/network/persistent-connection.js +10 -2
- package/network/session-connection.cjs +15 -6
- package/network/session-connection.js +15 -6
- package/network/session-connection.test.d.cts +1 -0
- package/network/session-connection.test.d.ts +1 -0
- package/network/transports/abstract.cjs +16 -0
- package/network/transports/abstract.d.cts +8 -2
- package/network/transports/abstract.d.ts +8 -2
- package/network/transports/abstract.js +17 -1
- package/network/transports/obfuscated.cjs +3 -1
- package/network/transports/obfuscated.js +3 -1
- package/package.json +6 -6
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +221 -103
- package/tl/binary/reader.js +221 -103
- package/tl/binary/writer.cjs +693 -277
- package/tl/binary/writer.js +693 -277
- package/tl/compat/reader.cjs +93 -0
- package/tl/compat/reader.js +93 -0
- package/tl/index.d.cts +12529 -4762
- package/tl/index.d.ts +12529 -4762
- package/tl/inner-tl.cjs +90 -24
- package/tl/inner-tl.js +90 -24
- package/tl/raw-errors.json +1 -1
- package/tl/rpc-error.test.d.cts +1 -0
- package/tl/rpc-error.test.d.ts +1 -0
- package/utils/abort-signal.cjs +1 -12
- package/utils/abort-signal.js +1 -12
- package/utils/abort-signal.test.d.cts +1 -0
- package/utils/abort-signal.test.d.ts +1 -0
- package/utils/binary/compat.cjs +189 -29
- package/utils/binary/compat.js +189 -29
- package/utils/early-timer.cjs +3 -11
- package/utils/early-timer.js +3 -11
- package/utils/early-timer.test.d.cts +1 -0
- package/utils/early-timer.test.d.ts +1 -0
- package/utils/function-utils.cjs +9 -4
- package/utils/function-utils.js +9 -4
- package/utils/links/bots.cjs +10 -2
- package/utils/links/bots.js +10 -2
- package/utils/peer-utils.cjs +8 -0
- package/utils/peer-utils.js +8 -0
|
@@ -7,6 +7,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const fileId = require("@mtcute/file-id");
|
|
9
9
|
const Long = require("long");
|
|
10
|
+
const errors = require("../../../types/errors.cjs");
|
|
10
11
|
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
11
12
|
const uploadedFile = require("../../types/files/uploaded-file.cjs");
|
|
12
13
|
const entities = require("../../types/misc/entities.cjs");
|
|
@@ -221,7 +222,7 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
221
222
|
title: entities.inputTextToTl(media.title),
|
|
222
223
|
list: media.items.map((it, idx) => ({
|
|
223
224
|
_: "todoItem",
|
|
224
|
-
id: idx,
|
|
225
|
+
id: idx + 1,
|
|
225
226
|
title: entities.inputTextToTl(it)
|
|
226
227
|
}))
|
|
227
228
|
}
|
|
@@ -250,11 +251,32 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
250
251
|
inputFile = uploaded.inputFile;
|
|
251
252
|
mime = uploaded.mime;
|
|
252
253
|
};
|
|
254
|
+
const uploadPeer = params.uploadPeer ?? { _: "inputPeerSelf" };
|
|
253
255
|
let videoCover;
|
|
254
256
|
if (media.type === "video" && media.cover) {
|
|
255
257
|
const inputMedia = await _normalizeInputMedia(client, media.cover, params);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
if (inputMedia._ !== "inputMediaPhoto" && inputMedia._ !== "inputMediaPhotoExternal" && inputMedia._ !== "inputMediaUploadedPhoto") {
|
|
259
|
+
throw new errors.MtArgumentError("media.cover must be a photo");
|
|
260
|
+
}
|
|
261
|
+
if (inputMedia._ === "inputMediaPhoto") {
|
|
262
|
+
videoCover = inputMedia.id;
|
|
263
|
+
} else {
|
|
264
|
+
const res = await client.call({
|
|
265
|
+
_: "messages.uploadMedia",
|
|
266
|
+
peer: uploadPeer,
|
|
267
|
+
media: inputMedia,
|
|
268
|
+
businessConnectionId: params.businessConnectionId
|
|
269
|
+
}, { abortSignal: params.abortSignal });
|
|
270
|
+
if (res._ !== "messageMediaPhoto" || res.photo?._ !== "photo") {
|
|
271
|
+
throw new errors.MtArgumentError("media.cover must be a photo");
|
|
272
|
+
}
|
|
273
|
+
videoCover = {
|
|
274
|
+
_: "inputPhoto",
|
|
275
|
+
id: res.photo.id,
|
|
276
|
+
accessHash: res.photo.accessHash,
|
|
277
|
+
fileReference: res.photo.fileReference
|
|
278
|
+
};
|
|
279
|
+
}
|
|
258
280
|
}
|
|
259
281
|
let livePhotoVideo;
|
|
260
282
|
if (media.type === "photo" && media.livePhotoVideo) {
|
|
@@ -262,7 +284,6 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
262
284
|
typeAssertions.assertTypeIs("uploadMediaIfNeeded", inputMedia, "inputMediaDocument");
|
|
263
285
|
livePhotoVideo = inputMedia.id;
|
|
264
286
|
}
|
|
265
|
-
const uploadPeer = params.uploadPeer ?? { _: "inputPeerSelf" };
|
|
266
287
|
const uploadMediaIfNeeded = async (inputMedia, photo) => {
|
|
267
288
|
if (!uploadMedia) return inputMedia;
|
|
268
289
|
const res = await client.call({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { tdFileId, parseFileId } from "@mtcute/file-id";
|
|
2
2
|
import Long from "long";
|
|
3
|
+
import { MtArgumentError } from "../../../types/errors.js";
|
|
3
4
|
import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
4
5
|
import { isUploadedFile } from "../../types/files/uploaded-file.js";
|
|
5
6
|
import { inputTextToTl } from "../../types/misc/entities.js";
|
|
@@ -214,7 +215,7 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
214
215
|
title: inputTextToTl(media.title),
|
|
215
216
|
list: media.items.map((it, idx) => ({
|
|
216
217
|
_: "todoItem",
|
|
217
|
-
id: idx,
|
|
218
|
+
id: idx + 1,
|
|
218
219
|
title: inputTextToTl(it)
|
|
219
220
|
}))
|
|
220
221
|
}
|
|
@@ -243,11 +244,32 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
243
244
|
inputFile = uploaded.inputFile;
|
|
244
245
|
mime = uploaded.mime;
|
|
245
246
|
};
|
|
247
|
+
const uploadPeer = params.uploadPeer ?? { _: "inputPeerSelf" };
|
|
246
248
|
let videoCover;
|
|
247
249
|
if (media.type === "video" && media.cover) {
|
|
248
250
|
const inputMedia = await _normalizeInputMedia(client, media.cover, params);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
if (inputMedia._ !== "inputMediaPhoto" && inputMedia._ !== "inputMediaPhotoExternal" && inputMedia._ !== "inputMediaUploadedPhoto") {
|
|
252
|
+
throw new MtArgumentError("media.cover must be a photo");
|
|
253
|
+
}
|
|
254
|
+
if (inputMedia._ === "inputMediaPhoto") {
|
|
255
|
+
videoCover = inputMedia.id;
|
|
256
|
+
} else {
|
|
257
|
+
const res = await client.call({
|
|
258
|
+
_: "messages.uploadMedia",
|
|
259
|
+
peer: uploadPeer,
|
|
260
|
+
media: inputMedia,
|
|
261
|
+
businessConnectionId: params.businessConnectionId
|
|
262
|
+
}, { abortSignal: params.abortSignal });
|
|
263
|
+
if (res._ !== "messageMediaPhoto" || res.photo?._ !== "photo") {
|
|
264
|
+
throw new MtArgumentError("media.cover must be a photo");
|
|
265
|
+
}
|
|
266
|
+
videoCover = {
|
|
267
|
+
_: "inputPhoto",
|
|
268
|
+
id: res.photo.id,
|
|
269
|
+
accessHash: res.photo.accessHash,
|
|
270
|
+
fileReference: res.photo.fileReference
|
|
271
|
+
};
|
|
272
|
+
}
|
|
251
273
|
}
|
|
252
274
|
let livePhotoVideo;
|
|
253
275
|
if (media.type === "photo" && media.livePhotoVideo) {
|
|
@@ -255,7 +277,6 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
255
277
|
assertTypeIs("uploadMediaIfNeeded", inputMedia, "inputMediaDocument");
|
|
256
278
|
livePhotoVideo = inputMedia.id;
|
|
257
279
|
}
|
|
258
|
-
const uploadPeer = params.uploadPeer ?? { _: "inputPeerSelf" };
|
|
259
280
|
const uploadMediaIfNeeded = async (inputMedia, photo) => {
|
|
260
281
|
if (!uploadMedia) return inputMedia;
|
|
261
282
|
const res = await client.call({
|
|
@@ -6,6 +6,13 @@ import { InputPeerLike, Message } from '../../types/index.js';
|
|
|
6
6
|
*
|
|
7
7
|
* Only admins with `manageTopics` permission can do this.
|
|
8
8
|
*
|
|
9
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
10
|
+
* > message IDs are separate for each side of the chat, while the
|
|
11
|
+
* > canonical topic ID is always issued in the *user's* ID space.
|
|
12
|
+
* > The `.id` of the returned service message is in the *bot's* ID space,
|
|
13
|
+
* > and is **not** a valid topic ID — use `.replyToMessage.threadId` instead,
|
|
14
|
+
* > which is what all other methods (as well as Bot API's `message_thread_id`) expect.
|
|
15
|
+
*
|
|
9
16
|
* @returns Service message for the created topic
|
|
10
17
|
*/
|
|
11
18
|
export declare function createForumTopic(client: ITelegramClient, params: {
|
|
@@ -6,6 +6,13 @@ import { InputPeerLike, Message } from '../../types/index.js';
|
|
|
6
6
|
*
|
|
7
7
|
* Only admins with `manageTopics` permission can do this.
|
|
8
8
|
*
|
|
9
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
10
|
+
* > message IDs are separate for each side of the chat, while the
|
|
11
|
+
* > canonical topic ID is always issued in the *user's* ID space.
|
|
12
|
+
* > The `.id` of the returned service message is in the *bot's* ID space,
|
|
13
|
+
* > and is **not** a valid topic ID — use `.replyToMessage.threadId` instead,
|
|
14
|
+
* > which is what all other methods (as well as Bot API's `message_thread_id`) expect.
|
|
15
|
+
*
|
|
9
16
|
* @returns Service message for the created topic
|
|
10
17
|
*/
|
|
11
18
|
export declare function createForumTopic(client: ITelegramClient, params: {
|
|
@@ -4,7 +4,7 @@ import { ForumTopic, InputPeerLike } from '../../types/index.js';
|
|
|
4
4
|
* Delete a forum topic and all its history
|
|
5
5
|
*
|
|
6
6
|
* @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
|
|
7
|
-
* @param topicId ID of the topic (i.e. its top message ID)
|
|
7
|
+
* @param topicId ID of the topic (i.e. its top message ID, see note at {@link createForumTopic})
|
|
8
8
|
*/
|
|
9
9
|
export declare function deleteForumTopicHistory(client: ITelegramClient, chat: InputPeerLike, topicId: number | ForumTopic, params?: {
|
|
10
10
|
/**
|
|
@@ -4,7 +4,7 @@ import { ForumTopic, InputPeerLike } from '../../types/index.js';
|
|
|
4
4
|
* Delete a forum topic and all its history
|
|
5
5
|
*
|
|
6
6
|
* @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
|
|
7
|
-
* @param topicId ID of the topic (i.e. its top message ID)
|
|
7
|
+
* @param topicId ID of the topic (i.e. its top message ID, see note at {@link createForumTopic})
|
|
8
8
|
*/
|
|
9
9
|
export declare function deleteForumTopicHistory(client: ITelegramClient, chat: InputPeerLike, topicId: number | ForumTopic, params?: {
|
|
10
10
|
/**
|
|
@@ -15,10 +15,10 @@ async function editForumTopic(client, params) {
|
|
|
15
15
|
peer: await resolvePeer.resolvePeer(client, chatId),
|
|
16
16
|
topicId: typeof topicId === "number" ? topicId : topicId.id,
|
|
17
17
|
title,
|
|
18
|
-
iconEmojiId: icon
|
|
18
|
+
iconEmojiId: icon === null ? Long.ZERO : icon,
|
|
19
19
|
closed,
|
|
20
20
|
hidden
|
|
21
21
|
});
|
|
22
|
-
return findInUpdate._findMessageInUpdate(client, res, false, shouldDispatch);
|
|
22
|
+
return findInUpdate._findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
23
23
|
}
|
|
24
24
|
exports.editForumTopic = editForumTopic;
|
|
@@ -7,13 +7,13 @@ import { ForumTopic, InputPeerLike, Message } from '../../types/index.js';
|
|
|
7
7
|
* Only admins with `manageTopics` permission can do this.
|
|
8
8
|
*
|
|
9
9
|
* @param chatId Chat ID or username
|
|
10
|
-
* @param topicId ID of the topic (i.e. its top message ID)
|
|
10
|
+
* @param topicId ID of the topic (i.e. its top message ID, see note at {@link createForumTopic})
|
|
11
11
|
* @returns Service message about the modification
|
|
12
12
|
*/
|
|
13
13
|
export declare function editForumTopic(client: ITelegramClient, params: {
|
|
14
14
|
/** Chat ID or username */
|
|
15
15
|
chatId: InputPeerLike;
|
|
16
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
16
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
17
17
|
topicId: number | ForumTopic;
|
|
18
18
|
/**
|
|
19
19
|
* New topic title
|
|
@@ -7,13 +7,13 @@ import { ForumTopic, InputPeerLike, Message } from '../../types/index.js';
|
|
|
7
7
|
* Only admins with `manageTopics` permission can do this.
|
|
8
8
|
*
|
|
9
9
|
* @param chatId Chat ID or username
|
|
10
|
-
* @param topicId ID of the topic (i.e. its top message ID)
|
|
10
|
+
* @param topicId ID of the topic (i.e. its top message ID, see note at {@link createForumTopic})
|
|
11
11
|
* @returns Service message about the modification
|
|
12
12
|
*/
|
|
13
13
|
export declare function editForumTopic(client: ITelegramClient, params: {
|
|
14
14
|
/** Chat ID or username */
|
|
15
15
|
chatId: InputPeerLike;
|
|
16
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
16
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
17
17
|
topicId: number | ForumTopic;
|
|
18
18
|
/**
|
|
19
19
|
* New topic title
|
|
@@ -8,11 +8,11 @@ async function editForumTopic(client, params) {
|
|
|
8
8
|
peer: await resolvePeer(client, chatId),
|
|
9
9
|
topicId: typeof topicId === "number" ? topicId : topicId.id,
|
|
10
10
|
title,
|
|
11
|
-
iconEmojiId: icon
|
|
11
|
+
iconEmojiId: icon === null ? Long.ZERO : icon,
|
|
12
12
|
closed,
|
|
13
13
|
hidden
|
|
14
14
|
});
|
|
15
|
-
return _findMessageInUpdate(client, res, false, shouldDispatch);
|
|
15
|
+
return _findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
18
|
editForumTopic
|
|
@@ -14,6 +14,10 @@ async function getForumTopicsById(client, chatId, ids) {
|
|
|
14
14
|
peer: await resolvePeer.resolvePeer(client, chatId),
|
|
15
15
|
topics: ids
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
const index = /* @__PURE__ */ new Map();
|
|
18
|
+
for (const topic of forumTopic.ForumTopic.parseTlForumTopics(res)) {
|
|
19
|
+
index.set(topic.id, topic);
|
|
20
|
+
}
|
|
21
|
+
return ids.map((id) => index.get(id) ?? null);
|
|
18
22
|
}
|
|
19
23
|
exports.getForumTopicsById = getForumTopicsById;
|
|
@@ -4,6 +4,14 @@ import { InputPeerLike, ForumTopic } from '../../types/index.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Get forum topics by their IDs
|
|
6
6
|
*
|
|
7
|
+
* The returned array is aligned with the input IDs.
|
|
8
|
+
* For topics that were deleted (or never existed),
|
|
9
|
+
* `null` will be returned at that position.
|
|
10
|
+
*
|
|
11
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
12
|
+
* > only canonical (user-space) topic IDs are accepted —
|
|
13
|
+
* > see the note at {@link createForumTopic}
|
|
14
|
+
*
|
|
7
15
|
* @param chatId Chat ID or username
|
|
8
16
|
*/
|
|
9
|
-
export declare function getForumTopicsById(client: ITelegramClient, chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
|
|
17
|
+
export declare function getForumTopicsById(client: ITelegramClient, chatId: InputPeerLike, ids: MaybeArray<number>): Promise<(ForumTopic | null)[]>;
|
|
@@ -4,6 +4,14 @@ import { InputPeerLike, ForumTopic } from '../../types/index.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Get forum topics by their IDs
|
|
6
6
|
*
|
|
7
|
+
* The returned array is aligned with the input IDs.
|
|
8
|
+
* For topics that were deleted (or never existed),
|
|
9
|
+
* `null` will be returned at that position.
|
|
10
|
+
*
|
|
11
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
12
|
+
* > only canonical (user-space) topic IDs are accepted —
|
|
13
|
+
* > see the note at {@link createForumTopic}
|
|
14
|
+
*
|
|
7
15
|
* @param chatId Chat ID or username
|
|
8
16
|
*/
|
|
9
|
-
export declare function getForumTopicsById(client: ITelegramClient, chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
|
|
17
|
+
export declare function getForumTopicsById(client: ITelegramClient, chatId: InputPeerLike, ids: MaybeArray<number>): Promise<(ForumTopic | null)[]>;
|
|
@@ -7,7 +7,11 @@ async function getForumTopicsById(client, chatId, ids) {
|
|
|
7
7
|
peer: await resolvePeer(client, chatId),
|
|
8
8
|
topics: ids
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
const index = /* @__PURE__ */ new Map();
|
|
11
|
+
for (const topic of ForumTopic$2.parseTlForumTopics(res)) {
|
|
12
|
+
index.set(topic.id, topic);
|
|
13
|
+
}
|
|
14
|
+
return ids.map((id) => index.get(id) ?? null);
|
|
11
15
|
}
|
|
12
16
|
export {
|
|
13
17
|
getForumTopicsById
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,8 +6,8 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
9
|
-
const miscUtils = require("../../utils/misc-utils.cjs");
|
|
10
9
|
const forumTopic = require("../../types/peers/forum-topic.cjs");
|
|
10
|
+
const miscUtils = require("../../utils/misc-utils.cjs");
|
|
11
11
|
const defaultOffset = {
|
|
12
12
|
date: 0,
|
|
13
13
|
id: 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolvePeer } from "../users/resolve-peer.js";
|
|
2
|
-
import { makeArrayPaginated } from "../../utils/misc-utils.js";
|
|
3
2
|
import { ForumTopic as ForumTopic$2 } from "../../types/peers/forum-topic.js";
|
|
3
|
+
import { makeArrayPaginated } from "../../utils/misc-utils.js";
|
|
4
4
|
const defaultOffset = {
|
|
5
5
|
date: 0,
|
|
6
6
|
id: 0,
|
|
@@ -15,6 +15,6 @@ async function toggleForumTopicClosed(client, parmas) {
|
|
|
15
15
|
topicId: typeof topicId === "number" ? topicId : topicId.id,
|
|
16
16
|
closed
|
|
17
17
|
});
|
|
18
|
-
return findInUpdate._findMessageInUpdate(client, res, false, shouldDispatch);
|
|
18
|
+
return findInUpdate._findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
19
19
|
}
|
|
20
20
|
exports.toggleForumTopicClosed = toggleForumTopicClosed;
|
|
@@ -10,7 +10,7 @@ import { ForumTopic, InputPeerLike, Message } from '../../types/index.js';
|
|
|
10
10
|
export declare function toggleForumTopicClosed(client: ITelegramClient, parmas: {
|
|
11
11
|
/** Chat ID or username */
|
|
12
12
|
chatId: InputPeerLike;
|
|
13
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
13
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
14
14
|
topicId: number | ForumTopic;
|
|
15
15
|
/** Whether the topic should be closed */
|
|
16
16
|
closed: boolean;
|
|
@@ -10,7 +10,7 @@ import { ForumTopic, InputPeerLike, Message } from '../../types/index.js';
|
|
|
10
10
|
export declare function toggleForumTopicClosed(client: ITelegramClient, parmas: {
|
|
11
11
|
/** Chat ID or username */
|
|
12
12
|
chatId: InputPeerLike;
|
|
13
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
13
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
14
14
|
topicId: number | ForumTopic;
|
|
15
15
|
/** Whether the topic should be closed */
|
|
16
16
|
closed: boolean;
|
|
@@ -8,7 +8,7 @@ async function toggleForumTopicClosed(client, parmas) {
|
|
|
8
8
|
topicId: typeof topicId === "number" ? topicId : topicId.id,
|
|
9
9
|
closed
|
|
10
10
|
});
|
|
11
|
-
return _findMessageInUpdate(client, res, false, shouldDispatch);
|
|
11
|
+
return _findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
14
|
toggleForumTopicClosed
|
|
@@ -8,7 +8,7 @@ import { ForumTopic, InputPeerLike } from '../../types/index.js';
|
|
|
8
8
|
export declare function toggleForumTopicPinned(client: ITelegramClient, params: {
|
|
9
9
|
/** Chat ID or username */
|
|
10
10
|
chatId: InputPeerLike;
|
|
11
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
11
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
12
12
|
topicId: number | ForumTopic;
|
|
13
13
|
/** Whether the topic should be pinned */
|
|
14
14
|
pinned: boolean;
|
|
@@ -8,7 +8,7 @@ import { ForumTopic, InputPeerLike } from '../../types/index.js';
|
|
|
8
8
|
export declare function toggleForumTopicPinned(client: ITelegramClient, params: {
|
|
9
9
|
/** Chat ID or username */
|
|
10
10
|
chatId: InputPeerLike;
|
|
11
|
-
/** ID of the topic (i.e. its top message ID) */
|
|
11
|
+
/** ID of the topic (i.e. its top message ID, see note at {@link createForumTopic}) */
|
|
12
12
|
topicId: number | ForumTopic;
|
|
13
13
|
/** Whether the topic should be pinned */
|
|
14
14
|
pinned: boolean;
|
|
@@ -10,11 +10,11 @@ const resolvePeer = require("../users/resolve-peer.cjs");
|
|
|
10
10
|
async function toggleGeneralTopicHidden(client, params) {
|
|
11
11
|
const { chatId, hidden, shouldDispatch } = params;
|
|
12
12
|
const res = await client.call({
|
|
13
|
-
_: "
|
|
14
|
-
|
|
13
|
+
_: "messages.editForumTopic",
|
|
14
|
+
peer: await resolvePeer.resolvePeer(client, chatId),
|
|
15
15
|
topicId: 1,
|
|
16
16
|
hidden
|
|
17
17
|
});
|
|
18
|
-
return findInUpdate._findMessageInUpdate(client, res, false, shouldDispatch);
|
|
18
|
+
return findInUpdate._findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
19
19
|
}
|
|
20
20
|
exports.toggleGeneralTopicHidden = toggleGeneralTopicHidden;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { _findMessageInUpdate } from "../messages/find-in-update.js";
|
|
2
|
-
import {
|
|
2
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
3
3
|
async function toggleGeneralTopicHidden(client, params) {
|
|
4
4
|
const { chatId, hidden, shouldDispatch } = params;
|
|
5
5
|
const res = await client.call({
|
|
6
|
-
_: "
|
|
7
|
-
|
|
6
|
+
_: "messages.editForumTopic",
|
|
7
|
+
peer: await resolvePeer(client, chatId),
|
|
8
8
|
topicId: 1,
|
|
9
9
|
hidden
|
|
10
10
|
});
|
|
11
|
-
return _findMessageInUpdate(client, res, false, shouldDispatch);
|
|
11
|
+
return _findMessageInUpdate(client, res, false, !shouldDispatch);
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
14
|
toggleGeneralTopicHidden
|
|
@@ -6,15 +6,18 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
9
|
+
const entities = require("../../types/misc/entities.cjs");
|
|
9
10
|
const findInUpdate = require("../messages/find-in-update.cjs");
|
|
10
11
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
12
|
async function buyResaleGift(client, params) {
|
|
12
|
-
const { slug, recipient, shouldDispatch, ton } = params;
|
|
13
|
+
const { slug, recipient, shouldDispatch, ton, anonymous, message } = params;
|
|
13
14
|
const invoice = {
|
|
14
15
|
_: "inputInvoiceStarGiftResale",
|
|
15
16
|
slug,
|
|
16
17
|
toId: await resolvePeer.resolvePeer(client, recipient),
|
|
17
|
-
ton
|
|
18
|
+
ton,
|
|
19
|
+
showName: anonymous === false,
|
|
20
|
+
message: message ? entities.inputTextToTl(message) : void 0
|
|
18
21
|
};
|
|
19
22
|
const form = await client.call({
|
|
20
23
|
_: "payments.getPaymentForm",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Message } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, InputText, Message } from '../../types/index.js';
|
|
3
3
|
export declare function buyResaleGift(client: ITelegramClient, params: {
|
|
4
4
|
/** Slug of the star gift to buy */
|
|
5
5
|
slug: string;
|
|
@@ -12,4 +12,14 @@ export declare function buyResaleGift(client: ITelegramClient, params: {
|
|
|
12
12
|
shouldDispatch?: true;
|
|
13
13
|
/** Whether to use TON currency for payment */
|
|
14
14
|
ton?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to buy the gift anonymously
|
|
17
|
+
* (i.e. if the recipient chooses to display the gift
|
|
18
|
+
* on their profile, your name won't be visible)
|
|
19
|
+
*
|
|
20
|
+
* @default `true`
|
|
21
|
+
*/
|
|
22
|
+
anonymous?: boolean;
|
|
23
|
+
/** Message to send along with the gift */
|
|
24
|
+
message?: InputText;
|
|
15
25
|
}): Promise<Message | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputPeerLike, Message } from '../../types/index.js';
|
|
2
|
+
import { InputPeerLike, InputText, Message } from '../../types/index.js';
|
|
3
3
|
export declare function buyResaleGift(client: ITelegramClient, params: {
|
|
4
4
|
/** Slug of the star gift to buy */
|
|
5
5
|
slug: string;
|
|
@@ -12,4 +12,14 @@ export declare function buyResaleGift(client: ITelegramClient, params: {
|
|
|
12
12
|
shouldDispatch?: true;
|
|
13
13
|
/** Whether to use TON currency for payment */
|
|
14
14
|
ton?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to buy the gift anonymously
|
|
17
|
+
* (i.e. if the recipient chooses to display the gift
|
|
18
|
+
* on their profile, your name won't be visible)
|
|
19
|
+
*
|
|
20
|
+
* @default `true`
|
|
21
|
+
*/
|
|
22
|
+
anonymous?: boolean;
|
|
23
|
+
/** Message to send along with the gift */
|
|
24
|
+
message?: InputText;
|
|
15
25
|
}): Promise<Message | null>;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
2
|
+
import { inputTextToTl } from "../../types/misc/entities.js";
|
|
2
3
|
import { _findMessageInUpdate } from "../messages/find-in-update.js";
|
|
3
4
|
import { resolvePeer } from "../users/resolve-peer.js";
|
|
4
5
|
async function buyResaleGift(client, params) {
|
|
5
|
-
const { slug, recipient, shouldDispatch, ton } = params;
|
|
6
|
+
const { slug, recipient, shouldDispatch, ton, anonymous, message } = params;
|
|
6
7
|
const invoice = {
|
|
7
8
|
_: "inputInvoiceStarGiftResale",
|
|
8
9
|
slug,
|
|
9
10
|
toId: await resolvePeer(client, recipient),
|
|
10
|
-
ton
|
|
11
|
+
ton,
|
|
12
|
+
showName: anonymous === false,
|
|
13
|
+
message: message ? inputTextToTl(message) : void 0
|
|
11
14
|
};
|
|
12
15
|
const form = await client.call({
|
|
13
16
|
_: "payments.getPaymentForm",
|
|
@@ -51,6 +51,7 @@ async function forwardMessagesById(client, params) {
|
|
|
51
51
|
allowPaidFloodskip,
|
|
52
52
|
videoTimestamp,
|
|
53
53
|
allowPaidStars: params.allowPaidMessages,
|
|
54
|
+
fromEphemeral: params.fromEphemeral,
|
|
54
55
|
topMsgId: toThreadId,
|
|
55
56
|
replyTo: toMonoforumPeer ? {
|
|
56
57
|
_: "inputReplyToMonoForum",
|
|
@@ -72,6 +72,8 @@ export interface ForwardMessageOptions {
|
|
|
72
72
|
allowPaidMessages?: tl.Long;
|
|
73
73
|
/** Video timestamp to use for the forwarded video */
|
|
74
74
|
videoTimestamp?: number;
|
|
75
|
+
/** Whether the messages being forwarded are ephemeral messages */
|
|
76
|
+
fromEphemeral?: boolean;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Forward one or more messages by their IDs.
|
|
@@ -72,6 +72,8 @@ export interface ForwardMessageOptions {
|
|
|
72
72
|
allowPaidMessages?: tl.Long;
|
|
73
73
|
/** Video timestamp to use for the forwarded video */
|
|
74
74
|
videoTimestamp?: number;
|
|
75
|
+
/** Whether the messages being forwarded are ephemeral messages */
|
|
76
|
+
fromEphemeral?: boolean;
|
|
75
77
|
}
|
|
76
78
|
/**
|
|
77
79
|
* Forward one or more messages by their IDs.
|
|
@@ -44,6 +44,7 @@ async function forwardMessagesById(client, params) {
|
|
|
44
44
|
allowPaidFloodskip,
|
|
45
45
|
videoTimestamp,
|
|
46
46
|
allowPaidStars: params.allowPaidMessages,
|
|
47
|
+
fromEphemeral: params.fromEphemeral,
|
|
47
48
|
topMsgId: toThreadId,
|
|
48
49
|
replyTo: toMonoforumPeer ? {
|
|
49
50
|
_: "inputReplyToMonoForum",
|
|
@@ -150,6 +150,9 @@ async function _normalizeInputRichMessage(client, peer, input, params) {
|
|
|
150
150
|
case "pageBlockAudio":
|
|
151
151
|
block.audioId = document.id;
|
|
152
152
|
break;
|
|
153
|
+
case "pageBlockDocument":
|
|
154
|
+
block.documentId = document.id;
|
|
155
|
+
break;
|
|
153
156
|
default:
|
|
154
157
|
throw new errors.MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
|
|
155
158
|
}
|
|
@@ -143,6 +143,9 @@ async function _normalizeInputRichMessage(client, peer, input, params) {
|
|
|
143
143
|
case "pageBlockAudio":
|
|
144
144
|
block.audioId = document.id;
|
|
145
145
|
break;
|
|
146
|
+
case "pageBlockDocument":
|
|
147
|
+
block.documentId = document.id;
|
|
148
|
+
break;
|
|
146
149
|
default:
|
|
147
150
|
throw new MtArgumentError(`sendRichMessage: expected document ${document.id} to be used in a document block, but got ${block._}`);
|
|
148
151
|
}
|
|
@@ -13,7 +13,13 @@ export interface CommonSendParams {
|
|
|
13
13
|
* Can also be a message from another chat, in which case a quote will be sent.
|
|
14
14
|
*/
|
|
15
15
|
replyTo?: number | Message;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* ID of the thread (topic) to reply to
|
|
18
|
+
*
|
|
19
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
20
|
+
* > this must be the canonical (user-space) topic ID —
|
|
21
|
+
* > see the note at {@link createForumTopic}
|
|
22
|
+
*/
|
|
17
23
|
threadId?: number;
|
|
18
24
|
/**
|
|
19
25
|
* If this is a reply to a specific todo item, ID of that item
|
|
@@ -13,7 +13,13 @@ export interface CommonSendParams {
|
|
|
13
13
|
* Can also be a message from another chat, in which case a quote will be sent.
|
|
14
14
|
*/
|
|
15
15
|
replyTo?: number | Message;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* ID of the thread (topic) to reply to
|
|
18
|
+
*
|
|
19
|
+
* > **Note**: for bots in private chats with "threaded mode" enabled,
|
|
20
|
+
* > this must be the canonical (user-space) topic ID —
|
|
21
|
+
* > see the note at {@link createForumTopic}
|
|
22
|
+
*/
|
|
17
23
|
threadId?: number;
|
|
18
24
|
/**
|
|
19
25
|
* If this is a reply to a specific todo item, ID of that item
|