@mtcute/core 0.28.0 → 0.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/client.cjs +16 -0
  2. package/client.js +16 -0
  3. package/highlevel/base.cjs +2 -0
  4. package/highlevel/base.js +2 -0
  5. package/highlevel/client.d.cts +74 -5
  6. package/highlevel/client.d.ts +74 -5
  7. package/highlevel/methods/chats/batched-queries.cjs +2 -4
  8. package/highlevel/methods/chats/batched-queries.d.cts +1 -1
  9. package/highlevel/methods/chats/batched-queries.d.ts +1 -1
  10. package/highlevel/methods/chats/batched-queries.js +2 -4
  11. package/highlevel/methods/chats/edit-chat-member-rank.cjs +19 -0
  12. package/highlevel/methods/chats/edit-chat-member-rank.d.cts +13 -0
  13. package/highlevel/methods/chats/edit-chat-member-rank.d.ts +13 -0
  14. package/highlevel/methods/chats/edit-chat-member-rank.js +14 -0
  15. package/highlevel/methods/chats/get-chats.cjs +27 -0
  16. package/highlevel/methods/chats/get-chats.d.cts +9 -0
  17. package/highlevel/methods/chats/get-chats.d.ts +9 -0
  18. package/highlevel/methods/chats/get-chats.js +22 -0
  19. package/highlevel/methods/chats/get-chats.test.d.cts +1 -0
  20. package/highlevel/methods/chats/get-chats.test.d.ts +1 -0
  21. package/highlevel/methods/chats/get-creator-after-leave.cjs +20 -4
  22. package/highlevel/methods/chats/get-creator-after-leave.d.cts +2 -2
  23. package/highlevel/methods/chats/get-creator-after-leave.d.ts +2 -2
  24. package/highlevel/methods/chats/get-creator-after-leave.js +21 -5
  25. package/highlevel/methods/chats/get-peers.cjs +16 -0
  26. package/highlevel/methods/chats/get-peers.d.cts +9 -0
  27. package/highlevel/methods/chats/get-peers.d.ts +9 -0
  28. package/highlevel/methods/chats/get-peers.js +11 -0
  29. package/highlevel/methods/chats/get-peers.test.d.cts +1 -0
  30. package/highlevel/methods/chats/get-peers.test.d.ts +1 -0
  31. package/highlevel/methods/chats/toggle-content-protection.cjs +3 -2
  32. package/highlevel/methods/chats/toggle-content-protection.d.cts +4 -1
  33. package/highlevel/methods/chats/toggle-content-protection.d.ts +4 -1
  34. package/highlevel/methods/chats/toggle-content-protection.js +3 -2
  35. package/highlevel/methods/chats/transfer-chat-ownership.cjs +36 -0
  36. package/highlevel/methods/chats/transfer-chat-ownership.d.cts +16 -0
  37. package/highlevel/methods/chats/transfer-chat-ownership.d.ts +16 -0
  38. package/highlevel/methods/chats/transfer-chat-ownership.js +31 -0
  39. package/highlevel/methods/contacts/set-contact-note.cjs +2 -0
  40. package/highlevel/methods/contacts/set-contact-note.js +2 -0
  41. package/highlevel/methods/files/upload-file.cjs +2 -2
  42. package/highlevel/methods/files/upload-file.js +2 -2
  43. package/highlevel/methods/users/get-users.d.cts +1 -2
  44. package/highlevel/methods/users/get-users.d.ts +1 -2
  45. package/highlevel/methods/users/resolve-peer.cjs +4 -4
  46. package/highlevel/methods/users/resolve-peer.js +4 -4
  47. package/highlevel/methods.d.cts +4 -0
  48. package/highlevel/methods.d.ts +4 -0
  49. package/highlevel/types/messages/message-action.cjs +13 -0
  50. package/highlevel/types/messages/message-action.d.cts +19 -1
  51. package/highlevel/types/messages/message-action.d.ts +19 -1
  52. package/highlevel/types/messages/message-action.js +13 -0
  53. package/highlevel/types/messages/message.cjs +4 -0
  54. package/highlevel/types/messages/message.d.cts +2 -0
  55. package/highlevel/types/messages/message.d.ts +2 -0
  56. package/highlevel/types/messages/message.js +4 -0
  57. package/highlevel/types/peers/chat-event/actions.cjs +7 -0
  58. package/highlevel/types/peers/chat-event/actions.d.cts +11 -1
  59. package/highlevel/types/peers/chat-event/actions.d.ts +11 -1
  60. package/highlevel/types/peers/chat-event/actions.js +7 -0
  61. package/highlevel/types/peers/chat-event/filters.cjs +1 -0
  62. package/highlevel/types/peers/chat-event/filters.js +1 -0
  63. package/highlevel/types/peers/chat-member.cjs +5 -8
  64. package/highlevel/types/peers/chat-member.d.cts +2 -2
  65. package/highlevel/types/peers/chat-member.d.ts +2 -2
  66. package/highlevel/types/peers/chat-member.js +5 -8
  67. package/highlevel/types/peers/full-user.cjs +14 -0
  68. package/highlevel/types/peers/full-user.d.cts +10 -0
  69. package/highlevel/types/peers/full-user.d.ts +10 -0
  70. package/highlevel/types/peers/full-user.js +14 -0
  71. package/highlevel/types/peers/peer.cjs +13 -3
  72. package/highlevel/types/peers/peer.d.cts +4 -0
  73. package/highlevel/types/peers/peer.d.ts +4 -0
  74. package/highlevel/types/peers/peer.js +13 -3
  75. package/highlevel/updates/manager.cjs +2 -0
  76. package/highlevel/updates/manager.js +2 -0
  77. package/highlevel/utils/file-utils.cjs +2 -2
  78. package/highlevel/utils/file-utils.d.cts +1 -1
  79. package/highlevel/utils/file-utils.d.ts +1 -1
  80. package/highlevel/utils/file-utils.js +2 -2
  81. package/methods.cjs +8 -0
  82. package/methods.js +8 -0
  83. package/network/mtproto-session.cjs +2 -0
  84. package/network/mtproto-session.js +2 -0
  85. package/network/network-manager.cjs +1 -1
  86. package/network/network-manager.js +1 -1
  87. package/network/server-salt.cjs +4 -8
  88. package/network/server-salt.js +4 -8
  89. package/network/session-connection.cjs +2 -0
  90. package/network/session-connection.js +2 -0
  91. package/network/transports/intermediate.cjs +2 -0
  92. package/network/transports/intermediate.js +2 -0
  93. package/package.json +3 -3
  94. package/storage/storage.cjs +2 -0
  95. package/storage/storage.js +2 -0
  96. package/utils/binary/compat.cjs +9 -0
  97. package/utils/binary/compat.d.cts +3 -0
  98. package/utils/binary/compat.d.ts +3 -0
  99. package/utils/binary/compat.js +10 -1
  100. package/utils/date-entity-format.cjs +48 -0
  101. package/utils/date-entity-format.d.cts +24 -0
  102. package/utils/date-entity-format.d.ts +24 -0
  103. package/utils/date-entity-format.js +43 -0
  104. package/utils/date-entity-format.test.d.cts +1 -0
  105. package/utils/date-entity-format.test.d.ts +1 -0
  106. package/utils/index.d.cts +3 -0
  107. package/utils/index.d.ts +3 -0
  108. package/utils/links/bots.cjs +3 -0
  109. package/utils/links/bots.js +3 -0
  110. package/utils.cjs +14 -0
  111. package/utils.js +9 -1
@@ -0,0 +1,13 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/peers/peer.js';
3
+ /**
4
+ * Edit the custom rank (title) of a group chat participant.
5
+ */
6
+ export declare function editChatMemberRank(client: ITelegramClient, params: {
7
+ /** Chat ID */
8
+ chatId: InputPeerLike;
9
+ /** ID of the user to edit the rank of */
10
+ participantId: InputPeerLike;
11
+ /** New rank, or `null` to remove it */
12
+ rank: string | null;
13
+ }): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import { resolvePeer } from "../users/resolve-peer.js";
2
+ async function editChatMemberRank(client, params) {
3
+ const { chatId, participantId, rank } = params;
4
+ const res = await client.call({
5
+ _: "messages.editChatParticipantRank",
6
+ peer: await resolvePeer(client, chatId),
7
+ participant: await resolvePeer(client, participantId),
8
+ rank: rank ?? ""
9
+ });
10
+ client.handleClientUpdate(res);
11
+ }
12
+ export {
13
+ editChatMemberRank
14
+ };
@@ -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 peerUtils = require("../../utils/peer-utils.cjs");
9
+ const resolvePeerMany = require("../users/resolve-peer-many.cjs");
10
+ const batchedQueries = require("./batched-queries.cjs");
11
+ const errors = require("../../types/errors.cjs");
12
+ const chat = require("../../types/peers/chat.cjs");
13
+ async function getChats(client, chatIds) {
14
+ const inputPeers = await resolvePeerMany.resolvePeerMany(client, chatIds);
15
+ const res = await Promise.all(inputPeers.map((peer) => {
16
+ if (!peer) return null;
17
+ if (peerUtils.isInputPeerChannel(peer)) {
18
+ return batchedQueries._getChannelsBatched(client, peerUtils.toInputChannel(peer));
19
+ } else if (peerUtils.isInputPeerChat(peer)) {
20
+ return batchedQueries._getChatsBatched(client, peer.chatId);
21
+ } else {
22
+ throw new errors.MtInvalidPeerTypeError(peer, "chat or channel");
23
+ }
24
+ }));
25
+ return res.map((it) => it ? new chat.Chat(it) : null);
26
+ }
27
+ exports.getChats = getChats;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ /**
4
+ * Get basic information about multiple chats.
5
+ *
6
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
7
+ * @returns The list of chats in the same order as the input
8
+ */
9
+ export declare function getChats(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Chat } from '../../types/index.js';
3
+ /**
4
+ * Get basic information about multiple chats.
5
+ *
6
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
7
+ * @returns The list of chats in the same order as the input
8
+ */
9
+ export declare function getChats(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
@@ -0,0 +1,22 @@
1
+ import { isInputPeerChannel, toInputChannel, isInputPeerChat } from "../../utils/peer-utils.js";
2
+ import { resolvePeerMany } from "../users/resolve-peer-many.js";
3
+ import { _getChannelsBatched, _getChatsBatched } from "./batched-queries.js";
4
+ import { MtInvalidPeerTypeError } from "../../types/errors.js";
5
+ import { Chat as Chat$2 } from "../../types/peers/chat.js";
6
+ async function getChats(client, chatIds) {
7
+ const inputPeers = await resolvePeerMany(client, chatIds);
8
+ const res = await Promise.all(inputPeers.map((peer) => {
9
+ if (!peer) return null;
10
+ if (isInputPeerChannel(peer)) {
11
+ return _getChannelsBatched(client, toInputChannel(peer));
12
+ } else if (isInputPeerChat(peer)) {
13
+ return _getChatsBatched(client, peer.chatId);
14
+ } else {
15
+ throw new MtInvalidPeerTypeError(peer, "chat or channel");
16
+ }
17
+ }));
18
+ return res.map((it) => it ? new Chat$2(it) : null);
19
+ }
20
+ export {
21
+ getChats
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -5,13 +5,29 @@ 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 errors = require("../../types/errors.cjs");
8
9
  const user = require("../../types/peers/user.cjs");
10
+ const peerUtils = require("../../utils/peer-utils.cjs");
9
11
  const resolvePeer = require("../users/resolve-peer.cjs");
10
12
  async function getCreatorAfterLeave(client, chatId) {
11
- const res = await client.call({
12
- _: "channels.getFutureCreatorAfterLeave",
13
- channel: await resolvePeer.resolveChannel(client, chatId)
14
- });
13
+ const peer = await resolvePeer.resolvePeer(client, chatId);
14
+ if (peerUtils.isInputPeerUser(peer)) {
15
+ throw new errors.MtInvalidPeerTypeError(chatId, "chat or channel");
16
+ }
17
+ let res;
18
+ if (peerUtils.isInputPeerChannel(peer)) {
19
+ res = await client.call({
20
+ _: "channels.getFutureCreatorAfterLeave",
21
+ channel: peerUtils.toInputChannel(peer)
22
+ });
23
+ } else if (peerUtils.isInputPeerChat(peer)) {
24
+ res = await client.call({
25
+ _: "messages.getFutureChatCreatorAfterLeave",
26
+ peer
27
+ });
28
+ } else {
29
+ throw new errors.MtInvalidPeerTypeError(chatId, "chat or channel");
30
+ }
15
31
  if (res._ === "userEmpty") return null;
16
32
  return new user.User(res);
17
33
  }
@@ -2,8 +2,8 @@ import { ITelegramClient } from '../../client.types.js';
2
2
  import { InputPeerLike } from '../../types/peers/peer.js';
3
3
  import { User } from '../../types/peers/user.js';
4
4
  /**
5
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
5
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
6
6
  *
7
- * You must be the creator of the channel/supergroup to use this method.
7
+ * You must be the creator of the chat/channel/supergroup to use this method.
8
8
  */
9
9
  export declare function getCreatorAfterLeave(client: ITelegramClient, chatId: InputPeerLike): Promise<User | null>;
@@ -2,8 +2,8 @@ import { ITelegramClient } from '../../client.types.js';
2
2
  import { InputPeerLike } from '../../types/peers/peer.js';
3
3
  import { User } from '../../types/peers/user.js';
4
4
  /**
5
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
5
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
6
6
  *
7
- * You must be the creator of the channel/supergroup to use this method.
7
+ * You must be the creator of the chat/channel/supergroup to use this method.
8
8
  */
9
9
  export declare function getCreatorAfterLeave(client: ITelegramClient, chatId: InputPeerLike): Promise<User | null>;
@@ -1,10 +1,26 @@
1
+ import { MtInvalidPeerTypeError } from "../../types/errors.js";
1
2
  import { User as User$2 } from "../../types/peers/user.js";
2
- import { resolveChannel } from "../users/resolve-peer.js";
3
+ import { isInputPeerUser, isInputPeerChannel, toInputChannel, isInputPeerChat } from "../../utils/peer-utils.js";
4
+ import { resolvePeer } from "../users/resolve-peer.js";
3
5
  async function getCreatorAfterLeave(client, chatId) {
4
- const res = await client.call({
5
- _: "channels.getFutureCreatorAfterLeave",
6
- channel: await resolveChannel(client, chatId)
7
- });
6
+ const peer = await resolvePeer(client, chatId);
7
+ if (isInputPeerUser(peer)) {
8
+ throw new MtInvalidPeerTypeError(chatId, "chat or channel");
9
+ }
10
+ let res;
11
+ if (isInputPeerChannel(peer)) {
12
+ res = await client.call({
13
+ _: "channels.getFutureCreatorAfterLeave",
14
+ channel: toInputChannel(peer)
15
+ });
16
+ } else if (isInputPeerChat(peer)) {
17
+ res = await client.call({
18
+ _: "messages.getFutureChatCreatorAfterLeave",
19
+ peer
20
+ });
21
+ } else {
22
+ throw new MtInvalidPeerTypeError(chatId, "chat or channel");
23
+ }
8
24
  if (res._ === "userEmpty") return null;
9
25
  return new User$2(res);
10
26
  }
@@ -0,0 +1,16 @@
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 resolvePeerMany = require("../users/resolve-peer-many.cjs");
9
+ const batchedQueries = require("./batched-queries.cjs");
10
+ const peer = require("../../types/peers/peer.cjs");
11
+ async function getPeers(client, chatIds) {
12
+ const inputPeers = await resolvePeerMany.resolvePeerMany(client, chatIds);
13
+ const res = await Promise.all(inputPeers.map((peer2) => peer2 ? batchedQueries._getRawPeerBatched(client, peer2) : null));
14
+ return res.map((it) => it ? peer.parsePeer(it) : null);
15
+ }
16
+ exports.getPeers = getPeers;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Peer } from '../../types/index.js';
3
+ /**
4
+ * Get basic information about multiple peers.
5
+ *
6
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
7
+ * @returns The list of peers in the same order as the input
8
+ */
9
+ export declare function getPeers(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, Peer } from '../../types/index.js';
3
+ /**
4
+ * Get basic information about multiple peers.
5
+ *
6
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
7
+ * @returns The list of peers in the same order as the input
8
+ */
9
+ export declare function getPeers(client: ITelegramClient, chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
@@ -0,0 +1,11 @@
1
+ import { resolvePeerMany } from "../users/resolve-peer-many.js";
2
+ import { _getRawPeerBatched } from "./batched-queries.js";
3
+ import { parsePeer } from "../../types/peers/peer.js";
4
+ async function getPeers(client, chatIds) {
5
+ const inputPeers = await resolvePeerMany(client, chatIds);
6
+ const res = await Promise.all(inputPeers.map((peer) => peer ? _getRawPeerBatched(client, peer) : null));
7
+ return res.map((it) => it ? parsePeer(it) : null);
8
+ }
9
+ export {
10
+ getPeers
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -6,11 +6,12 @@ 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
- async function toggleContentProtection(client, chatId, enabled = false) {
9
+ async function toggleContentProtection(client, chatId, enabled = false, params) {
10
10
  const res = await client.call({
11
11
  _: "messages.toggleNoForwards",
12
12
  peer: await resolvePeer.resolvePeer(client, chatId),
13
- enabled
13
+ enabled,
14
+ requestMsgId: params?.requestMsgId
14
15
  });
15
16
  client.handleClientUpdate(res);
16
17
  }
@@ -6,4 +6,7 @@ import { InputPeerLike } from '../../types/index.js';
6
6
  * @param chatId Chat ID or username
7
7
  * @param enabled Whether content protection should be enabled
8
8
  */
9
- export declare function toggleContentProtection(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean): Promise<void>;
9
+ export declare function toggleContentProtection(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean, params?: {
10
+ /** If this method was called in response to the other party enabling content protection, ID of that message */
11
+ requestMsgId?: number;
12
+ }): Promise<void>;
@@ -6,4 +6,7 @@ import { InputPeerLike } from '../../types/index.js';
6
6
  * @param chatId Chat ID or username
7
7
  * @param enabled Whether content protection should be enabled
8
8
  */
9
- export declare function toggleContentProtection(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean): Promise<void>;
9
+ export declare function toggleContentProtection(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean, params?: {
10
+ /** If this method was called in response to the other party enabling content protection, ID of that message */
11
+ requestMsgId?: number;
12
+ }): Promise<void>;
@@ -1,9 +1,10 @@
1
1
  import { resolvePeer } from "../users/resolve-peer.js";
2
- async function toggleContentProtection(client, chatId, enabled = false) {
2
+ async function toggleContentProtection(client, chatId, enabled = false, params) {
3
3
  const res = await client.call({
4
4
  _: "messages.toggleNoForwards",
5
5
  peer: await resolvePeer(client, chatId),
6
- enabled
6
+ enabled,
7
+ requestMsgId: params?.requestMsgId
7
8
  });
8
9
  client.handleClientUpdate(res);
9
10
  }
@@ -0,0 +1,36 @@
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 peerUtils = require("../../utils/peer-utils.cjs");
9
+ const resolvePeer = require("../users/resolve-peer.cjs");
10
+ async function transferChatOwnership(client, params) {
11
+ const { chatId, userId } = params;
12
+ const peer = await resolvePeer.resolvePeer(client, chatId);
13
+ const user = await resolvePeer.resolveUser(client, userId);
14
+ const password = await client.computeSrpParams(
15
+ await client.call({ _: "account.getPassword" }),
16
+ params.password
17
+ );
18
+ let res;
19
+ if (peerUtils.isInputPeerChannel(peer)) {
20
+ res = await client.call({
21
+ _: "channels.editCreator",
22
+ channel: peerUtils.toInputChannel(peer),
23
+ userId: user,
24
+ password
25
+ });
26
+ } else {
27
+ res = await client.call({
28
+ _: "messages.editChatCreator",
29
+ peer,
30
+ userId: user,
31
+ password
32
+ });
33
+ }
34
+ client.handleClientUpdate(res);
35
+ }
36
+ exports.transferChatOwnership = transferChatOwnership;
@@ -0,0 +1,16 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/peers/peer.js';
3
+ /**
4
+ * Transfer ownership of a chat/channel/supergroup to another user.
5
+ *
6
+ * You must be the creator of the chat to use this method,
7
+ * and your account must have 2FA enabled.
8
+ */
9
+ export declare function transferChatOwnership(client: ITelegramClient, params: {
10
+ /** ID of the chat/channel/supergroup to transfer */
11
+ chatId: InputPeerLike;
12
+ /** ID of the user to transfer ownership to */
13
+ userId: InputPeerLike;
14
+ /** Your 2FA password */
15
+ password: string;
16
+ }): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/peers/peer.js';
3
+ /**
4
+ * Transfer ownership of a chat/channel/supergroup to another user.
5
+ *
6
+ * You must be the creator of the chat to use this method,
7
+ * and your account must have 2FA enabled.
8
+ */
9
+ export declare function transferChatOwnership(client: ITelegramClient, params: {
10
+ /** ID of the chat/channel/supergroup to transfer */
11
+ chatId: InputPeerLike;
12
+ /** ID of the user to transfer ownership to */
13
+ userId: InputPeerLike;
14
+ /** Your 2FA password */
15
+ password: string;
16
+ }): Promise<void>;
@@ -0,0 +1,31 @@
1
+ import { isInputPeerChannel, toInputChannel } from "../../utils/peer-utils.js";
2
+ import { resolvePeer, resolveUser } from "../users/resolve-peer.js";
3
+ async function transferChatOwnership(client, params) {
4
+ const { chatId, userId } = params;
5
+ const peer = await resolvePeer(client, chatId);
6
+ const user = await resolveUser(client, userId);
7
+ const password = await client.computeSrpParams(
8
+ await client.call({ _: "account.getPassword" }),
9
+ params.password
10
+ );
11
+ let res;
12
+ if (isInputPeerChannel(peer)) {
13
+ res = await client.call({
14
+ _: "channels.editCreator",
15
+ channel: toInputChannel(peer),
16
+ userId: user,
17
+ password
18
+ });
19
+ } else {
20
+ res = await client.call({
21
+ _: "messages.editChatCreator",
22
+ peer,
23
+ userId: user,
24
+ password
25
+ });
26
+ }
27
+ client.handleClientUpdate(res);
28
+ }
29
+ export {
30
+ transferChatOwnership
31
+ };
@@ -7,6 +7,8 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const typeAssertions = require("../../../utils/type-assertions.cjs");
9
9
  require("@mtcute/tl-runtime");
10
+ require("@mtcute/tl/binary/reader.js");
11
+ require("@mtcute/tl/binary/writer.js");
10
12
  const resolvePeer = require("../users/resolve-peer.cjs");
11
13
  const entities = require("../../types/misc/entities.cjs");
12
14
  async function setContactNote(client, userId, note) {
@@ -1,5 +1,7 @@
1
1
  import { assertTrue } from "../../../utils/type-assertions.js";
2
2
  import "@mtcute/tl-runtime";
3
+ import "@mtcute/tl/binary/reader.js";
4
+ import "@mtcute/tl/binary/writer.js";
3
5
  import { resolveUser } from "../users/resolve-peer.js";
4
6
  import { inputTextToTl } from "../../types/misc/entities.js";
5
7
  async function setContactNote(client, userId, note) {
@@ -95,9 +95,9 @@ async function uploadFile(client, params) {
95
95
  let partSizeKb = params.partSize;
96
96
  if (!partSizeKb) {
97
97
  if (fileSize === -1) {
98
- partSizeKb = params.estimatedSize ? fileUtils.determinePartSize(params.estimatedSize) : 64;
98
+ partSizeKb = params.estimatedSize ? fileUtils.determinePartSize(params.estimatedSize, true) : 64;
99
99
  } else {
100
- partSizeKb = fileUtils.determinePartSize(fileSize);
100
+ partSizeKb = fileUtils.determinePartSize(fileSize, true);
101
101
  }
102
102
  }
103
103
  if (partSizeKb > 512) {
@@ -88,9 +88,9 @@ async function uploadFile(client, params) {
88
88
  let partSizeKb = params.partSize;
89
89
  if (!partSizeKb) {
90
90
  if (fileSize === -1) {
91
- partSizeKb = params.estimatedSize ? determinePartSize(params.estimatedSize) : 64;
91
+ partSizeKb = params.estimatedSize ? determinePartSize(params.estimatedSize, true) : 64;
92
92
  } else {
93
- partSizeKb = determinePartSize(fileSize);
93
+ partSizeKb = determinePartSize(fileSize, true);
94
94
  }
95
95
  }
96
96
  if (partSizeKb > 512) {
@@ -5,8 +5,7 @@ import { InputPeerLike, User } from '../../types/index.js';
5
5
  * Get information about multiple users.
6
6
  * You can retrieve up to 200 users at once.
7
7
  *
8
- * Note that order is not guaranteed.
9
- *
10
8
  * @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
9
+ * @returns The list of users in the same order as the input
11
10
  */
12
11
  export declare function getUsers(client: ITelegramClient, ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
@@ -5,8 +5,7 @@ import { InputPeerLike, User } from '../../types/index.js';
5
5
  * Get information about multiple users.
6
6
  * You can retrieve up to 200 users at once.
7
7
  *
8
- * Note that order is not guaranteed.
9
- *
10
8
  * @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
9
+ * @returns The list of users in the same order as the input
11
10
  */
12
11
  export declare function getUsers(client: ITelegramClient, ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
@@ -119,14 +119,14 @@ async function resolvePeer(client, peerId, force = false) {
119
119
  if (cached && (cached._ === "channel" || cached._ === "user")) {
120
120
  const [username] = peerUtils$1.extractUsernames(cached);
121
121
  if (username) {
122
- const resolved = await resolvePeer(client, username, true);
123
- if (peerUtils.getMarkedPeerId(resolved) === peerId) {
122
+ const resolved = await resolvePeer(client, username, true).catch(() => null);
123
+ if (resolved && peerUtils.getMarkedPeerId(resolved) === peerId) {
124
124
  return resolved;
125
125
  }
126
126
  }
127
127
  if (cached._ === "user" && cached.phone) {
128
- const resolved = await resolvePhoneNumber.resolvePhoneNumber(client, cached.phone, true);
129
- if (peerUtils.getMarkedPeerId(resolved) === peerId) {
128
+ const resolved = await resolvePhoneNumber.resolvePhoneNumber(client, cached.phone, true).catch(() => null);
129
+ if (resolved && peerUtils.getMarkedPeerId(resolved) === peerId) {
130
130
  return resolved;
131
131
  }
132
132
  }
@@ -112,14 +112,14 @@ async function resolvePeer(client, peerId, force = false) {
112
112
  if (cached && (cached._ === "channel" || cached._ === "user")) {
113
113
  const [username] = extractUsernames(cached);
114
114
  if (username) {
115
- const resolved = await resolvePeer(client, username, true);
116
- if (getMarkedPeerId(resolved) === peerId) {
115
+ const resolved = await resolvePeer(client, username, true).catch(() => null);
116
+ if (resolved && getMarkedPeerId(resolved) === peerId) {
117
117
  return resolved;
118
118
  }
119
119
  }
120
120
  if (cached._ === "user" && cached.phone) {
121
- const resolved = await resolvePhoneNumber(client, cached.phone, true);
122
- if (getMarkedPeerId(resolved) === peerId) {
121
+ const resolved = await resolvePhoneNumber(client, cached.phone, true).catch(() => null);
122
+ if (resolved && getMarkedPeerId(resolved) === peerId) {
123
123
  return resolved;
124
124
  }
125
125
  }
@@ -45,17 +45,20 @@ export { deleteGroup } from './methods/chats/delete-group.js';
45
45
  export { deleteHistory } from './methods/chats/delete-history.js';
46
46
  export { deleteUserHistory } from './methods/chats/delete-user-history.js';
47
47
  export { editAdminRights } from './methods/chats/edit-admin-rights.js';
48
+ export { editChatMemberRank } from './methods/chats/edit-chat-member-rank.js';
48
49
  export { getChatEventLog } from './methods/chats/get-chat-event-log.js';
49
50
  export { getChatMember } from './methods/chats/get-chat-member.js';
50
51
  export { getChatMembers } from './methods/chats/get-chat-members.js';
51
52
  export { getChatPreview } from './methods/chats/get-chat-preview.js';
52
53
  export { getChat } from './methods/chats/get-chat.js';
54
+ export { getChats } from './methods/chats/get-chats.js';
53
55
  export { getCreatorAfterLeave } from './methods/chats/get-creator-after-leave.js';
54
56
  export { getFullChat } from './methods/chats/get-full-chat.js';
55
57
  export { getFullUser } from './methods/chats/get-full-user.js';
56
58
  export { getMessageAuthor } from './methods/chats/get-message-author.js';
57
59
  export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
58
60
  export { getPeer } from './methods/chats/get-peer.js';
61
+ export { getPeers } from './methods/chats/get-peers.js';
59
62
  export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
60
63
  export { getUser } from './methods/chats/get-user.js';
61
64
  export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
@@ -81,6 +84,7 @@ export { toggleContentProtection } from './methods/chats/toggle-content-protecti
81
84
  export { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js';
82
85
  export { toggleJoinRequests } from './methods/chats/toggle-join-requests.js';
83
86
  export { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js';
87
+ export { transferChatOwnership } from './methods/chats/transfer-chat-ownership.js';
84
88
  export { unarchiveChats } from './methods/chats/unarchive-chats.js';
85
89
  export { unbanChatMember } from './methods/chats/unban-chat-member.js';
86
90
  export { addContact } from './methods/contacts/add-contact.js';
@@ -45,17 +45,20 @@ export { deleteGroup } from './methods/chats/delete-group.js';
45
45
  export { deleteHistory } from './methods/chats/delete-history.js';
46
46
  export { deleteUserHistory } from './methods/chats/delete-user-history.js';
47
47
  export { editAdminRights } from './methods/chats/edit-admin-rights.js';
48
+ export { editChatMemberRank } from './methods/chats/edit-chat-member-rank.js';
48
49
  export { getChatEventLog } from './methods/chats/get-chat-event-log.js';
49
50
  export { getChatMember } from './methods/chats/get-chat-member.js';
50
51
  export { getChatMembers } from './methods/chats/get-chat-members.js';
51
52
  export { getChatPreview } from './methods/chats/get-chat-preview.js';
52
53
  export { getChat } from './methods/chats/get-chat.js';
54
+ export { getChats } from './methods/chats/get-chats.js';
53
55
  export { getCreatorAfterLeave } from './methods/chats/get-creator-after-leave.js';
54
56
  export { getFullChat } from './methods/chats/get-full-chat.js';
55
57
  export { getFullUser } from './methods/chats/get-full-user.js';
56
58
  export { getMessageAuthor } from './methods/chats/get-message-author.js';
57
59
  export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
58
60
  export { getPeer } from './methods/chats/get-peer.js';
61
+ export { getPeers } from './methods/chats/get-peers.js';
59
62
  export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
60
63
  export { getUser } from './methods/chats/get-user.js';
61
64
  export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
@@ -81,6 +84,7 @@ export { toggleContentProtection } from './methods/chats/toggle-content-protecti
81
84
  export { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js';
82
85
  export { toggleJoinRequests } from './methods/chats/toggle-join-requests.js';
83
86
  export { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js';
87
+ export { transferChatOwnership } from './methods/chats/transfer-chat-ownership.js';
84
88
  export { unarchiveChats } from './methods/chats/unarchive-chats.js';
85
89
  export { unbanChatMember } from './methods/chats/unban-chat-member.js';
86
90
  export { addContact } from './methods/contacts/add-contact.js';
@@ -436,6 +436,19 @@ function _messageActionFromTl(act) {
436
436
  type: "change_creator",
437
437
  newCreator: new user.User(this._peers.user(act.newCreatorId))
438
438
  };
439
+ case "messageActionNoForwardsToggle":
440
+ return {
441
+ type: "no_forwards_toggle",
442
+ prevValue: act.prevValue,
443
+ newValue: act.newValue
444
+ };
445
+ case "messageActionNoForwardsRequest":
446
+ return {
447
+ type: "no_forwards_request",
448
+ expired: act.expired,
449
+ prevValue: act.prevValue,
450
+ newValue: act.newValue
451
+ };
439
452
  default:
440
453
  return null;
441
454
  }