@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
|
@@ -85,7 +85,9 @@ async function signInQr(client, params) {
|
|
|
85
85
|
]);
|
|
86
86
|
break;
|
|
87
87
|
case "auth.loginTokenMigrateTo": {
|
|
88
|
+
abortSignal?.throwIfAborted();
|
|
88
89
|
await client.changePrimaryDc(res.dcId);
|
|
90
|
+
abortSignal?.throwIfAborted();
|
|
89
91
|
let res2;
|
|
90
92
|
try {
|
|
91
93
|
res2 = await client.call(
|
|
@@ -78,7 +78,9 @@ async function signInQr(client, params) {
|
|
|
78
78
|
]);
|
|
79
79
|
break;
|
|
80
80
|
case "auth.loginTokenMigrateTo": {
|
|
81
|
+
abortSignal?.throwIfAborted();
|
|
81
82
|
await client.changePrimaryDc(res.dcId);
|
|
83
|
+
abortSignal?.throwIfAborted();
|
|
82
84
|
let res2;
|
|
83
85
|
try {
|
|
84
86
|
res2 = await client.call(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
};
|
|
@@ -7,6 +7,7 @@ import { tl } from '../../../tl/index.js';
|
|
|
7
7
|
* - `status: 'ok'` - the chat was joined successfully
|
|
8
8
|
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
9
|
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
* (use `messages.requestChatJoinWebView` with `queryId` to obtain the webview url)
|
|
10
11
|
*/
|
|
11
12
|
export type JoinChatResult = {
|
|
12
13
|
status: 'ok';
|
|
@@ -16,7 +17,7 @@ export type JoinChatResult = {
|
|
|
16
17
|
} | {
|
|
17
18
|
status: 'webview';
|
|
18
19
|
bot: User;
|
|
19
|
-
|
|
20
|
+
queryId: tl.Long;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* Join a channel or supergroup
|
|
@@ -7,6 +7,7 @@ import { tl } from '../../../tl/index.js';
|
|
|
7
7
|
* - `status: 'ok'` - the chat was joined successfully
|
|
8
8
|
* - `status: 'request_sent'` - a join request was sent and needs to be approved by the chat admin
|
|
9
9
|
* - `status: 'webview'` - a guard bot requested you to open a webview before joining the chat
|
|
10
|
+
* (use `messages.requestChatJoinWebView` with `queryId` to obtain the webview url)
|
|
10
11
|
*/
|
|
11
12
|
export type JoinChatResult = {
|
|
12
13
|
status: 'ok';
|
|
@@ -16,7 +17,7 @@ export type JoinChatResult = {
|
|
|
16
17
|
} | {
|
|
17
18
|
status: 'webview';
|
|
18
19
|
bot: User;
|
|
19
|
-
|
|
20
|
+
queryId: tl.Long;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
22
23
|
* Join a channel or supergroup
|
|
@@ -5,7 +5,6 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
5
5
|
}
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
const peerUtils = require("../../utils/peer-utils.cjs");
|
|
9
8
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
10
9
|
async function transferChatOwnership(client, params) {
|
|
11
10
|
const { chatId, userId } = params;
|
|
@@ -15,22 +14,12 @@ async function transferChatOwnership(client, params) {
|
|
|
15
14
|
await client.call({ _: "account.getPassword" }),
|
|
16
15
|
params.password
|
|
17
16
|
);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
password
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
res = await client.call({
|
|
28
|
-
_: "messages.editChatCreator",
|
|
29
|
-
peer,
|
|
30
|
-
userId: user,
|
|
31
|
-
password
|
|
32
|
-
});
|
|
33
|
-
}
|
|
17
|
+
const res = await client.call({
|
|
18
|
+
_: "messages.editChatCreator",
|
|
19
|
+
peer,
|
|
20
|
+
userId: user,
|
|
21
|
+
password
|
|
22
|
+
});
|
|
34
23
|
client.handleClientUpdate(res);
|
|
35
24
|
}
|
|
36
25
|
exports.transferChatOwnership = transferChatOwnership;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isInputPeerChannel, toInputChannel } from "../../utils/peer-utils.js";
|
|
2
1
|
import { resolvePeer, resolveUser } from "../users/resolve-peer.js";
|
|
3
2
|
async function transferChatOwnership(client, params) {
|
|
4
3
|
const { chatId, userId } = params;
|
|
@@ -8,22 +7,12 @@ async function transferChatOwnership(client, params) {
|
|
|
8
7
|
await client.call({ _: "account.getPassword" }),
|
|
9
8
|
params.password
|
|
10
9
|
);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
password
|
|
18
|
-
});
|
|
19
|
-
} else {
|
|
20
|
-
res = await client.call({
|
|
21
|
-
_: "messages.editChatCreator",
|
|
22
|
-
peer,
|
|
23
|
-
userId: user,
|
|
24
|
-
password
|
|
25
|
-
});
|
|
26
|
-
}
|
|
10
|
+
const res = await client.call({
|
|
11
|
+
_: "messages.editChatCreator",
|
|
12
|
+
peer,
|
|
13
|
+
userId: user,
|
|
14
|
+
password
|
|
15
|
+
});
|
|
27
16
|
client.handleClientUpdate(res);
|
|
28
17
|
}
|
|
29
18
|
export {
|
|
@@ -0,0 +1,30 @@
|
|
|
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 banCommunityParticipant(client, params) {
|
|
11
|
+
const { communityId, participantId } = params;
|
|
12
|
+
const r = await client.call({
|
|
13
|
+
_: "communities.toggleParticipantBanned",
|
|
14
|
+
community: await resolvePeer.resolveChannel(client, communityId),
|
|
15
|
+
participant: await resolvePeer.resolvePeer(client, participantId)
|
|
16
|
+
});
|
|
17
|
+
typeAssertions.assertTrue("communities.toggleParticipantBanned", r);
|
|
18
|
+
}
|
|
19
|
+
async function unbanCommunityParticipant(client, params) {
|
|
20
|
+
const { communityId, participantId } = params;
|
|
21
|
+
const r = await client.call({
|
|
22
|
+
_: "communities.toggleParticipantBanned",
|
|
23
|
+
community: await resolvePeer.resolveChannel(client, communityId),
|
|
24
|
+
participant: await resolvePeer.resolvePeer(client, participantId),
|
|
25
|
+
unban: true
|
|
26
|
+
});
|
|
27
|
+
typeAssertions.assertTrue("communities.toggleParticipantBanned", r);
|
|
28
|
+
}
|
|
29
|
+
exports.banCommunityParticipant = banCommunityParticipant;
|
|
30
|
+
exports.unbanCommunityParticipant = unbanCommunityParticipant;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ban a participant from a community
|
|
5
|
+
*/
|
|
6
|
+
export declare function banCommunityParticipant(client: ITelegramClient, params: {
|
|
7
|
+
/** Community ID */
|
|
8
|
+
communityId: InputPeerLike;
|
|
9
|
+
/** Participant to ban */
|
|
10
|
+
participantId: InputPeerLike;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Unban a participant from a community
|
|
14
|
+
*/
|
|
15
|
+
export declare function unbanCommunityParticipant(client: ITelegramClient, params: {
|
|
16
|
+
/** Community ID */
|
|
17
|
+
communityId: InputPeerLike;
|
|
18
|
+
/** Participant to unban */
|
|
19
|
+
participantId: InputPeerLike;
|
|
20
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ban a participant from a community
|
|
5
|
+
*/
|
|
6
|
+
export declare function banCommunityParticipant(client: ITelegramClient, params: {
|
|
7
|
+
/** Community ID */
|
|
8
|
+
communityId: InputPeerLike;
|
|
9
|
+
/** Participant to ban */
|
|
10
|
+
participantId: InputPeerLike;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Unban a participant from a community
|
|
14
|
+
*/
|
|
15
|
+
export declare function unbanCommunityParticipant(client: ITelegramClient, params: {
|
|
16
|
+
/** Community ID */
|
|
17
|
+
communityId: InputPeerLike;
|
|
18
|
+
/** Participant to unban */
|
|
19
|
+
participantId: InputPeerLike;
|
|
20
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { assertTrue } from "../../../utils/type-assertions.js";
|
|
2
|
+
import { resolvePeer, resolveChannel } from "../users/resolve-peer.js";
|
|
3
|
+
async function banCommunityParticipant(client, params) {
|
|
4
|
+
const { communityId, participantId } = params;
|
|
5
|
+
const r = await client.call({
|
|
6
|
+
_: "communities.toggleParticipantBanned",
|
|
7
|
+
community: await resolveChannel(client, communityId),
|
|
8
|
+
participant: await resolvePeer(client, participantId)
|
|
9
|
+
});
|
|
10
|
+
assertTrue("communities.toggleParticipantBanned", r);
|
|
11
|
+
}
|
|
12
|
+
async function unbanCommunityParticipant(client, params) {
|
|
13
|
+
const { communityId, participantId } = params;
|
|
14
|
+
const r = await client.call({
|
|
15
|
+
_: "communities.toggleParticipantBanned",
|
|
16
|
+
community: await resolveChannel(client, communityId),
|
|
17
|
+
participant: await resolvePeer(client, participantId),
|
|
18
|
+
unban: true
|
|
19
|
+
});
|
|
20
|
+
assertTrue("communities.toggleParticipantBanned", r);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
banCommunityParticipant,
|
|
24
|
+
unbanCommunityParticipant
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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 utils = require("../../updates/utils.cjs");
|
|
10
|
+
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
|
+
const chat = require("../../types/peers/chat.cjs");
|
|
12
|
+
async function createCommunity(client, params) {
|
|
13
|
+
const { title, chatId, about, hidden, shouldDispatch } = params;
|
|
14
|
+
const res = await client.call({
|
|
15
|
+
_: "communities.create",
|
|
16
|
+
title,
|
|
17
|
+
about,
|
|
18
|
+
hidden,
|
|
19
|
+
peer: await resolvePeer.resolvePeer(client, chatId)
|
|
20
|
+
});
|
|
21
|
+
utils.assertIsUpdatesGroup("communities.create", res);
|
|
22
|
+
client.handleClientUpdate(res, !shouldDispatch);
|
|
23
|
+
const community = res.chats.find((it) => it._ === "community");
|
|
24
|
+
if (!community) {
|
|
25
|
+
throw new errors.MtTypeAssertionError("communities.create (@ .chats)", "community", "none");
|
|
26
|
+
}
|
|
27
|
+
return new chat.Chat(community);
|
|
28
|
+
}
|
|
29
|
+
exports.createCommunity = createCommunity;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new community
|
|
5
|
+
*
|
|
6
|
+
* @returns Newly created community
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCommunity(client: ITelegramClient, params: {
|
|
9
|
+
/** Community title */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Chat to link to the community */
|
|
12
|
+
chatId: InputPeerLike;
|
|
13
|
+
/** Community description */
|
|
14
|
+
about?: string;
|
|
15
|
+
/** Whether the community should be hidden */
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to dispatch the returned updates
|
|
19
|
+
* to the client's update handler.
|
|
20
|
+
*/
|
|
21
|
+
shouldDispatch?: true;
|
|
22
|
+
}): Promise<Chat>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new community
|
|
5
|
+
*
|
|
6
|
+
* @returns Newly created community
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCommunity(client: ITelegramClient, params: {
|
|
9
|
+
/** Community title */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Chat to link to the community */
|
|
12
|
+
chatId: InputPeerLike;
|
|
13
|
+
/** Community description */
|
|
14
|
+
about?: string;
|
|
15
|
+
/** Whether the community should be hidden */
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to dispatch the returned updates
|
|
19
|
+
* to the client's update handler.
|
|
20
|
+
*/
|
|
21
|
+
shouldDispatch?: true;
|
|
22
|
+
}): Promise<Chat>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MtTypeAssertionError } from "../../../types/errors.js";
|
|
2
|
+
import { assertIsUpdatesGroup } from "../../updates/utils.js";
|
|
3
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
4
|
+
import { Chat as Chat$2 } from "../../types/peers/chat.js";
|
|
5
|
+
async function createCommunity(client, params) {
|
|
6
|
+
const { title, chatId, about, hidden, shouldDispatch } = params;
|
|
7
|
+
const res = await client.call({
|
|
8
|
+
_: "communities.create",
|
|
9
|
+
title,
|
|
10
|
+
about,
|
|
11
|
+
hidden,
|
|
12
|
+
peer: await resolvePeer(client, chatId)
|
|
13
|
+
});
|
|
14
|
+
assertIsUpdatesGroup("communities.create", res);
|
|
15
|
+
client.handleClientUpdate(res, !shouldDispatch);
|
|
16
|
+
const community = res.chats.find((it) => it._ === "community");
|
|
17
|
+
if (!community) {
|
|
18
|
+
throw new MtTypeAssertionError("communities.create (@ .chats)", "community", "none");
|
|
19
|
+
}
|
|
20
|
+
return new Chat$2(community);
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
createCommunity
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 resolvePeer = require("../users/resolve-peer.cjs");
|
|
9
|
+
const miscUtils = require("../../utils/misc-utils.cjs");
|
|
10
|
+
const communityPeer = require("../../types/peers/community-peer.cjs");
|
|
11
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
12
|
+
async function getCommunityLinkRequests(client, communityId, params) {
|
|
13
|
+
const { offset = "", limit = 100 } = params ?? {};
|
|
14
|
+
const res = await client.call({
|
|
15
|
+
_: "communities.getPeerLinkRequests",
|
|
16
|
+
community: await resolvePeer.resolveChannel(client, communityId),
|
|
17
|
+
offset,
|
|
18
|
+
limit
|
|
19
|
+
});
|
|
20
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
21
|
+
return miscUtils.makeArrayPaginated(
|
|
22
|
+
res.requests.map((it) => new communityPeer.CommunityPeerRequest(it, peers)),
|
|
23
|
+
res.totalCount,
|
|
24
|
+
res.nextOffset
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
exports.getCommunityLinkRequests = getCommunityLinkRequests;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { ArrayPaginated, InputPeerLike, CommunityPeerRequest } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get pending peer link requests for a community
|
|
5
|
+
*
|
|
6
|
+
* @param communityId Community ID
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCommunityLinkRequests(client: ITelegramClient, communityId: InputPeerLike, params?: {
|
|
9
|
+
/** Offset for pagination */
|
|
10
|
+
offset?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum number of requests to fetch
|
|
13
|
+
*
|
|
14
|
+
* @default 100
|
|
15
|
+
*/
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): Promise<ArrayPaginated<CommunityPeerRequest, string>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { ArrayPaginated, InputPeerLike, CommunityPeerRequest } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get pending peer link requests for a community
|
|
5
|
+
*
|
|
6
|
+
* @param communityId Community ID
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCommunityLinkRequests(client: ITelegramClient, communityId: InputPeerLike, params?: {
|
|
9
|
+
/** Offset for pagination */
|
|
10
|
+
offset?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum number of requests to fetch
|
|
13
|
+
*
|
|
14
|
+
* @default 100
|
|
15
|
+
*/
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): Promise<ArrayPaginated<CommunityPeerRequest, string>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { resolveChannel } from "../users/resolve-peer.js";
|
|
2
|
+
import { makeArrayPaginated } from "../../utils/misc-utils.js";
|
|
3
|
+
import { CommunityPeerRequest as CommunityPeerRequest$2 } from "../../types/peers/community-peer.js";
|
|
4
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
5
|
+
async function getCommunityLinkRequests(client, communityId, params) {
|
|
6
|
+
const { offset = "", limit = 100 } = params ?? {};
|
|
7
|
+
const res = await client.call({
|
|
8
|
+
_: "communities.getPeerLinkRequests",
|
|
9
|
+
community: await resolveChannel(client, communityId),
|
|
10
|
+
offset,
|
|
11
|
+
limit
|
|
12
|
+
});
|
|
13
|
+
const peers = PeersIndex.from(res);
|
|
14
|
+
return makeArrayPaginated(
|
|
15
|
+
res.requests.map((it) => new CommunityPeerRequest$2(it, peers)),
|
|
16
|
+
res.totalCount,
|
|
17
|
+
res.nextOffset
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
getCommunityLinkRequests
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 resolvePeer = require("../users/resolve-peer.cjs");
|
|
9
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
10
|
+
const chat = require("../../types/peers/chat.cjs");
|
|
11
|
+
async function getCommunityParticipantChats(client, params) {
|
|
12
|
+
const { communityId, participantId } = params;
|
|
13
|
+
const res = await client.call({
|
|
14
|
+
_: "communities.getParticipantJoinedChats",
|
|
15
|
+
community: await resolvePeer.resolveChannel(client, communityId),
|
|
16
|
+
participant: await resolvePeer.resolvePeer(client, participantId)
|
|
17
|
+
});
|
|
18
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
19
|
+
return {
|
|
20
|
+
creatorChats: res.creatorChatIds.map((it) => new chat.Chat(peers.chat(it))),
|
|
21
|
+
joinedChats: res.joinedChatIds.map((it) => new chat.Chat(peers.chat(it)))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.getCommunityParticipantChats = getCommunityParticipantChats;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
export interface CommunityParticipantChats {
|
|
4
|
+
/** Chats linked to the community that the participant has created */
|
|
5
|
+
creatorChats: Chat[];
|
|
6
|
+
/** Chats linked to the community that the participant has joined */
|
|
7
|
+
joinedChats: Chat[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get chats linked to a community that the given participant has joined or created
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCommunityParticipantChats(client: ITelegramClient, params: {
|
|
13
|
+
/** Community ID */
|
|
14
|
+
communityId: InputPeerLike;
|
|
15
|
+
/** Participant to fetch the chats for */
|
|
16
|
+
participantId: InputPeerLike;
|
|
17
|
+
}): Promise<CommunityParticipantChats>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Chat } from '../../types/index.js';
|
|
3
|
+
export interface CommunityParticipantChats {
|
|
4
|
+
/** Chats linked to the community that the participant has created */
|
|
5
|
+
creatorChats: Chat[];
|
|
6
|
+
/** Chats linked to the community that the participant has joined */
|
|
7
|
+
joinedChats: Chat[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get chats linked to a community that the given participant has joined or created
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCommunityParticipantChats(client: ITelegramClient, params: {
|
|
13
|
+
/** Community ID */
|
|
14
|
+
communityId: InputPeerLike;
|
|
15
|
+
/** Participant to fetch the chats for */
|
|
16
|
+
participantId: InputPeerLike;
|
|
17
|
+
}): Promise<CommunityParticipantChats>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { resolvePeer, resolveChannel } from "../users/resolve-peer.js";
|
|
2
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
3
|
+
import { Chat as Chat$2 } from "../../types/peers/chat.js";
|
|
4
|
+
async function getCommunityParticipantChats(client, params) {
|
|
5
|
+
const { communityId, participantId } = params;
|
|
6
|
+
const res = await client.call({
|
|
7
|
+
_: "communities.getParticipantJoinedChats",
|
|
8
|
+
community: await resolveChannel(client, communityId),
|
|
9
|
+
participant: await resolvePeer(client, participantId)
|
|
10
|
+
});
|
|
11
|
+
const peers = PeersIndex.from(res);
|
|
12
|
+
return {
|
|
13
|
+
creatorChats: res.creatorChatIds.map((it) => new Chat$2(peers.chat(it))),
|
|
14
|
+
joinedChats: res.joinedChatIds.map((it) => new Chat$2(peers.chat(it)))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
getCommunityParticipantChats
|
|
19
|
+
};
|