@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
package/client.cjs CHANGED
@@ -49,17 +49,20 @@ const deleteGroup = require("./highlevel/methods/chats/delete-group.cjs");
49
49
  const deleteHistory = require("./highlevel/methods/chats/delete-history.cjs");
50
50
  const deleteUserHistory = require("./highlevel/methods/chats/delete-user-history.cjs");
51
51
  const editAdminRights = require("./highlevel/methods/chats/edit-admin-rights.cjs");
52
+ const editChatMemberRank = require("./highlevel/methods/chats/edit-chat-member-rank.cjs");
52
53
  const getChatEventLog = require("./highlevel/methods/chats/get-chat-event-log.cjs");
53
54
  const getChatMember = require("./highlevel/methods/chats/get-chat-member.cjs");
54
55
  const getChatMembers = require("./highlevel/methods/chats/get-chat-members.cjs");
55
56
  const getChatPreview = require("./highlevel/methods/chats/get-chat-preview.cjs");
56
57
  const getChat = require("./highlevel/methods/chats/get-chat.cjs");
58
+ const getChats = require("./highlevel/methods/chats/get-chats.cjs");
57
59
  const getCreatorAfterLeave = require("./highlevel/methods/chats/get-creator-after-leave.cjs");
58
60
  const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
59
61
  const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
60
62
  const getMessageAuthor = require("./highlevel/methods/chats/get-message-author.cjs");
61
63
  const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
62
64
  const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
65
+ const getPeers = require("./highlevel/methods/chats/get-peers.cjs");
63
66
  const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
64
67
  const getUser = require("./highlevel/methods/chats/get-user.cjs");
65
68
  const iterChatEventLog = require("./highlevel/methods/chats/iter-chat-event-log.cjs");
@@ -84,6 +87,7 @@ const toggleContentProtection = require("./highlevel/methods/chats/toggle-conten
84
87
  const toggleFragmentUsername = require("./highlevel/methods/chats/toggle-fragment-username.cjs");
85
88
  const toggleJoinRequests = require("./highlevel/methods/chats/toggle-join-requests.cjs");
86
89
  const toggleJoinToSend = require("./highlevel/methods/chats/toggle-join-to-send.cjs");
90
+ const transferChatOwnership = require("./highlevel/methods/chats/transfer-chat-ownership.cjs");
87
91
  const unarchiveChats = require("./highlevel/methods/chats/unarchive-chats.cjs");
88
92
  const unbanChatMember = require("./highlevel/methods/chats/unban-chat-member.cjs");
89
93
  const addContact = require("./highlevel/methods/contacts/add-contact.cjs");
@@ -583,6 +587,9 @@ TelegramClient.prototype.deleteUserHistory = function(...args) {
583
587
  TelegramClient.prototype.editAdminRights = function(...args) {
584
588
  return editAdminRights.editAdminRights(this._client, ...args);
585
589
  };
590
+ TelegramClient.prototype.editChatMemberRank = function(...args) {
591
+ return editChatMemberRank.editChatMemberRank(this._client, ...args);
592
+ };
586
593
  TelegramClient.prototype.getChatEventLog = function(...args) {
587
594
  return getChatEventLog.getChatEventLog(this._client, ...args);
588
595
  };
@@ -598,6 +605,9 @@ TelegramClient.prototype.getChatPreview = function(...args) {
598
605
  TelegramClient.prototype.getChat = function(...args) {
599
606
  return getChat.getChat(this._client, ...args);
600
607
  };
608
+ TelegramClient.prototype.getChats = function(...args) {
609
+ return getChats.getChats(this._client, ...args);
610
+ };
601
611
  TelegramClient.prototype.getCreatorAfterLeave = function(...args) {
602
612
  return getCreatorAfterLeave.getCreatorAfterLeave(this._client, ...args);
603
613
  };
@@ -616,6 +626,9 @@ TelegramClient.prototype.getNearbyChats = function(...args) {
616
626
  TelegramClient.prototype.getPeer = function(...args) {
617
627
  return getPeer.getPeer(this._client, ...args);
618
628
  };
629
+ TelegramClient.prototype.getPeers = function(...args) {
630
+ return getPeers.getPeers(this._client, ...args);
631
+ };
619
632
  TelegramClient.prototype.getSimilarChannels = function(...args) {
620
633
  return getSimilarChannels.getSimilarChannels(this._client, ...args);
621
634
  };
@@ -691,6 +704,9 @@ TelegramClient.prototype.toggleJoinRequests = function(...args) {
691
704
  TelegramClient.prototype.toggleJoinToSend = function(...args) {
692
705
  return toggleJoinToSend.toggleJoinToSend(this._client, ...args);
693
706
  };
707
+ TelegramClient.prototype.transferChatOwnership = function(...args) {
708
+ return transferChatOwnership.transferChatOwnership(this._client, ...args);
709
+ };
694
710
  TelegramClient.prototype.unarchiveChats = function(...args) {
695
711
  return unarchiveChats.unarchiveChats(this._client, ...args);
696
712
  };
package/client.js CHANGED
@@ -42,17 +42,20 @@ import { deleteGroup } from "./highlevel/methods/chats/delete-group.js";
42
42
  import { deleteHistory } from "./highlevel/methods/chats/delete-history.js";
43
43
  import { deleteUserHistory } from "./highlevel/methods/chats/delete-user-history.js";
44
44
  import { editAdminRights } from "./highlevel/methods/chats/edit-admin-rights.js";
45
+ import { editChatMemberRank } from "./highlevel/methods/chats/edit-chat-member-rank.js";
45
46
  import { getChatEventLog } from "./highlevel/methods/chats/get-chat-event-log.js";
46
47
  import { getChatMember } from "./highlevel/methods/chats/get-chat-member.js";
47
48
  import { getChatMembers } from "./highlevel/methods/chats/get-chat-members.js";
48
49
  import { getChatPreview } from "./highlevel/methods/chats/get-chat-preview.js";
49
50
  import { getChat } from "./highlevel/methods/chats/get-chat.js";
51
+ import { getChats } from "./highlevel/methods/chats/get-chats.js";
50
52
  import { getCreatorAfterLeave } from "./highlevel/methods/chats/get-creator-after-leave.js";
51
53
  import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
52
54
  import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
53
55
  import { getMessageAuthor } from "./highlevel/methods/chats/get-message-author.js";
54
56
  import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
55
57
  import { getPeer } from "./highlevel/methods/chats/get-peer.js";
58
+ import { getPeers } from "./highlevel/methods/chats/get-peers.js";
56
59
  import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
57
60
  import { getUser } from "./highlevel/methods/chats/get-user.js";
58
61
  import { iterChatEventLog } from "./highlevel/methods/chats/iter-chat-event-log.js";
@@ -77,6 +80,7 @@ import { toggleContentProtection } from "./highlevel/methods/chats/toggle-conten
77
80
  import { toggleFragmentUsername } from "./highlevel/methods/chats/toggle-fragment-username.js";
78
81
  import { toggleJoinRequests } from "./highlevel/methods/chats/toggle-join-requests.js";
79
82
  import { toggleJoinToSend } from "./highlevel/methods/chats/toggle-join-to-send.js";
83
+ import { transferChatOwnership } from "./highlevel/methods/chats/transfer-chat-ownership.js";
80
84
  import { unarchiveChats } from "./highlevel/methods/chats/unarchive-chats.js";
81
85
  import { unbanChatMember } from "./highlevel/methods/chats/unban-chat-member.js";
82
86
  import { addContact } from "./highlevel/methods/contacts/add-contact.js";
@@ -576,6 +580,9 @@ TelegramClient.prototype.deleteUserHistory = function(...args) {
576
580
  TelegramClient.prototype.editAdminRights = function(...args) {
577
581
  return editAdminRights(this._client, ...args);
578
582
  };
583
+ TelegramClient.prototype.editChatMemberRank = function(...args) {
584
+ return editChatMemberRank(this._client, ...args);
585
+ };
579
586
  TelegramClient.prototype.getChatEventLog = function(...args) {
580
587
  return getChatEventLog(this._client, ...args);
581
588
  };
@@ -591,6 +598,9 @@ TelegramClient.prototype.getChatPreview = function(...args) {
591
598
  TelegramClient.prototype.getChat = function(...args) {
592
599
  return getChat(this._client, ...args);
593
600
  };
601
+ TelegramClient.prototype.getChats = function(...args) {
602
+ return getChats(this._client, ...args);
603
+ };
594
604
  TelegramClient.prototype.getCreatorAfterLeave = function(...args) {
595
605
  return getCreatorAfterLeave(this._client, ...args);
596
606
  };
@@ -609,6 +619,9 @@ TelegramClient.prototype.getNearbyChats = function(...args) {
609
619
  TelegramClient.prototype.getPeer = function(...args) {
610
620
  return getPeer(this._client, ...args);
611
621
  };
622
+ TelegramClient.prototype.getPeers = function(...args) {
623
+ return getPeers(this._client, ...args);
624
+ };
612
625
  TelegramClient.prototype.getSimilarChannels = function(...args) {
613
626
  return getSimilarChannels(this._client, ...args);
614
627
  };
@@ -684,6 +697,9 @@ TelegramClient.prototype.toggleJoinRequests = function(...args) {
684
697
  TelegramClient.prototype.toggleJoinToSend = function(...args) {
685
698
  return toggleJoinToSend(this._client, ...args);
686
699
  };
700
+ TelegramClient.prototype.transferChatOwnership = function(...args) {
701
+ return transferChatOwnership(this._client, ...args);
702
+ };
687
703
  TelegramClient.prototype.unarchiveChats = function(...args) {
688
704
  return unarchiveChats(this._client, ...args);
689
705
  };
@@ -13,6 +13,8 @@ const functionUtils = require("../utils/function-utils.cjs");
13
13
  const logger = require("../utils/logger.cjs");
14
14
  const typeAssertions = require("../utils/type-assertions.cjs");
15
15
  require("@mtcute/tl-runtime");
16
+ require("@mtcute/tl/binary/reader.js");
17
+ require("@mtcute/tl/binary/writer.js");
16
18
  const appConfigManager = require("./managers/app-config-manager.cjs");
17
19
  const timers = require("./managers/timers.cjs");
18
20
  const storage = require("./storage/storage.cjs");
package/highlevel/base.js CHANGED
@@ -6,6 +6,8 @@ import { asyncResettable } from "../utils/function-utils.js";
6
6
  import { LogManager } from "../utils/logger.js";
7
7
  import { isTlRpcError } from "../utils/type-assertions.js";
8
8
  import "@mtcute/tl-runtime";
9
+ import "@mtcute/tl/binary/reader.js";
10
+ import "@mtcute/tl/binary/writer.js";
9
11
  import { AppConfigManager } from "./managers/app-config-manager.js";
10
12
  import { TimersManager } from "./managers/timers.js";
11
13
  import { TelegramStorageManager } from "./storage/storage.js";
@@ -1110,6 +1110,17 @@ export interface TelegramClient extends ITelegramClient {
1110
1110
  /** Custom admin rank */
1111
1111
  rank?: string;
1112
1112
  }): Promise<void>;
1113
+ /**
1114
+ * Edit the custom rank (title) of a group chat participant.
1115
+ */
1116
+ editChatMemberRank(params: {
1117
+ /** Chat ID */
1118
+ chatId: InputPeerLike;
1119
+ /** ID of the user to edit the rank of */
1120
+ participantId: InputPeerLike;
1121
+ /** New rank, or `null` to remove it */
1122
+ rank: string | null;
1123
+ }): Promise<void>;
1113
1124
  /**
1114
1125
  * Get chat event log ("Recent actions" in official clients).
1115
1126
  *
@@ -1259,9 +1270,18 @@ export interface TelegramClient extends ITelegramClient {
1259
1270
  */
1260
1271
  getChat(chatId: InputPeerLike): Promise<Chat>;
1261
1272
  /**
1262
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
1273
+ * Get basic information about multiple chats.
1263
1274
  *
1264
- * You must be the creator of the channel/supergroup to use this method.
1275
+ * **Available**: both users and bots
1276
+ *
1277
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
1278
+ * @returns The list of chats in the same order as the input
1279
+ */
1280
+ getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
1281
+ /**
1282
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
1283
+ *
1284
+ * You must be the creator of the chat/channel/supergroup to use this method.
1265
1285
  */
1266
1286
  getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
1267
1287
  /**
@@ -1295,6 +1315,15 @@ export interface TelegramClient extends ITelegramClient {
1295
1315
  getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
1296
1316
  /** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
1297
1317
  getPeer(peer: InputPeerLike): Promise<Peer>;
1318
+ /**
1319
+ * Get basic information about multiple peers.
1320
+ *
1321
+ * **Available**: ✅ both users and bots
1322
+ *
1323
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
1324
+ * @returns The list of peers in the same order as the input
1325
+ */
1326
+ getPeers(chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
1298
1327
  /**
1299
1328
  * Get channels that are similar to a given channel
1300
1329
  *
@@ -1615,7 +1644,10 @@ export interface TelegramClient extends ITelegramClient {
1615
1644
  * @param chatId Chat ID or username
1616
1645
  * @param [enabled=false] Whether content protection should be enabled
1617
1646
  */
1618
- toggleContentProtection(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
1647
+ toggleContentProtection(chatId: InputPeerLike, enabled?: boolean, params?: {
1648
+ /** If this method was called in response to the other party enabling content protection, ID of that message */
1649
+ requestMsgId?: number;
1650
+ }): Promise<void>;
1619
1651
  /**
1620
1652
  * Toggle a collectible (Fragment) username
1621
1653
  *
@@ -1660,6 +1692,20 @@ export interface TelegramClient extends ITelegramClient {
1660
1692
  * @param [enabled=false] Whether join-to-send setting should be enabled
1661
1693
  */
1662
1694
  toggleJoinToSend(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
1695
+ /**
1696
+ * Transfer ownership of a chat/channel/supergroup to another user.
1697
+ *
1698
+ * You must be the creator of the chat to use this method,
1699
+ * and your account must have 2FA enabled.
1700
+ */
1701
+ transferChatOwnership(params: {
1702
+ /** ID of the chat/channel/supergroup to transfer */
1703
+ chatId: InputPeerLike;
1704
+ /** ID of the user to transfer ownership to */
1705
+ userId: InputPeerLike;
1706
+ /** Your 2FA password */
1707
+ password: string;
1708
+ }): Promise<void>;
1663
1709
  /**
1664
1710
  * Unarchive one or more chats
1665
1711
  *
@@ -1760,6 +1806,8 @@ export interface TelegramClient extends ITelegramClient {
1760
1806
  /**
1761
1807
  * Set a note for a contact
1762
1808
  *
1809
+ * **Available**: 👤 users only
1810
+ *
1763
1811
  * @param userId ID of the user to set the note for
1764
1812
  * @param note Note text
1765
1813
  */
@@ -2199,6 +2247,8 @@ export interface TelegramClient extends ITelegramClient {
2199
2247
  *
2200
2248
  * Only admins with `manageTopics` permission can do this.
2201
2249
  *
2250
+ * **Available**: 👤 users only
2251
+ *
2202
2252
  * @returns Service message for the created topic
2203
2253
  */
2204
2254
  createForumTopic(params: {
@@ -2230,6 +2280,8 @@ export interface TelegramClient extends ITelegramClient {
2230
2280
  /**
2231
2281
  * Delete a forum topic and all its history
2232
2282
  *
2283
+ * **Available**: 👤 users only
2284
+ *
2233
2285
  * @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
2234
2286
  * @param topicId ID of the topic (i.e. its top message ID)
2235
2287
  */
@@ -2245,6 +2297,8 @@ export interface TelegramClient extends ITelegramClient {
2245
2297
  *
2246
2298
  * Only admins with `manageTopics` permission can do this.
2247
2299
  *
2300
+ * **Available**: 👤 users only
2301
+ *
2248
2302
  * @param chatId Chat ID or username
2249
2303
  * @param topicId ID of the topic (i.e. its top message ID)
2250
2304
  * @returns Service message about the modification
@@ -2278,12 +2332,16 @@ export interface TelegramClient extends ITelegramClient {
2278
2332
  /**
2279
2333
  * Get forum topics by their IDs
2280
2334
  *
2335
+ * **Available**: 👤 users only
2336
+ *
2281
2337
  * @param chatId Chat ID or username
2282
2338
  */
2283
2339
  getForumTopicsById(chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
2284
2340
  /**
2285
2341
  * Get forum topics
2286
2342
  *
2343
+ * **Available**: 👤 users only
2344
+ *
2287
2345
  * @param chatId Chat ID or username
2288
2346
  */
2289
2347
  getForumTopics(chatId: InputPeerLike, params?: {
@@ -2325,6 +2383,8 @@ export interface TelegramClient extends ITelegramClient {
2325
2383
  * Reorder pinned forum topics
2326
2384
  *
2327
2385
  * Only admins with `manageTopics` permission can do this.
2386
+ * **Available**: 👤 users only
2387
+ *
2328
2388
  */
2329
2389
  reorderPinnedForumTopics(params: {
2330
2390
  /** Chat ID or username */
@@ -2343,6 +2403,8 @@ export interface TelegramClient extends ITelegramClient {
2343
2403
  *
2344
2404
  * Only admins with `manageTopics` permission can do this.
2345
2405
  *
2406
+ * **Available**: 👤 users only
2407
+ *
2346
2408
  * @returns Service message about the modification
2347
2409
  */
2348
2410
  toggleForumTopicClosed(parmas: {
@@ -2362,6 +2424,8 @@ export interface TelegramClient extends ITelegramClient {
2362
2424
  * Toggle whether a topic in a forum is pinned
2363
2425
  *
2364
2426
  * Only admins with `manageTopics` permission can do this.
2427
+ * **Available**: 👤 users only
2428
+ *
2365
2429
  */
2366
2430
  toggleForumTopicPinned(params: {
2367
2431
  /** Chat ID or username */
@@ -2511,6 +2575,8 @@ export interface TelegramClient extends ITelegramClient {
2511
2575
  getStarGiftOptions(): Promise<StarGift[]>;
2512
2576
  /**
2513
2577
  * Get a list of all possible attributes when upgrading a given star gift
2578
+ * **Available**: 👤 users only
2579
+ *
2514
2580
  */
2515
2581
  getStarGiftUpgradeOptions(giftId: tl.Long): Promise<StarGiftUpgradeOptions>;
2516
2582
  /**
@@ -2590,6 +2656,8 @@ export interface TelegramClient extends ITelegramClient {
2590
2656
  /**
2591
2657
  * Accept or decline a purchase offer for a star gift
2592
2658
  *
2659
+ * **Available**: 👤 users only
2660
+ *
2593
2661
  * @returns The generated service message
2594
2662
  */
2595
2663
  resolveStarGiftOffer(options: {
@@ -2605,6 +2673,8 @@ export interface TelegramClient extends ITelegramClient {
2605
2673
  }): Promise<Message>;
2606
2674
  /**
2607
2675
  * Create a purchase offer for a unique star gift
2676
+ * **Available**: 👤 users only
2677
+ *
2608
2678
  * @param client
2609
2679
  * @param params
2610
2680
  */
@@ -5175,11 +5245,10 @@ export interface TelegramClient extends ITelegramClient {
5175
5245
  * Get information about multiple users.
5176
5246
  * You can retrieve up to 200 users at once.
5177
5247
  *
5178
- * Note that order is not guaranteed.
5179
- *
5180
5248
  * **Available**: ✅ both users and bots
5181
5249
  *
5182
5250
  * @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
5251
+ * @returns The list of users in the same order as the input
5183
5252
  */
5184
5253
  getUsers(ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
5185
5254
  /**
@@ -1110,6 +1110,17 @@ export interface TelegramClient extends ITelegramClient {
1110
1110
  /** Custom admin rank */
1111
1111
  rank?: string;
1112
1112
  }): Promise<void>;
1113
+ /**
1114
+ * Edit the custom rank (title) of a group chat participant.
1115
+ */
1116
+ editChatMemberRank(params: {
1117
+ /** Chat ID */
1118
+ chatId: InputPeerLike;
1119
+ /** ID of the user to edit the rank of */
1120
+ participantId: InputPeerLike;
1121
+ /** New rank, or `null` to remove it */
1122
+ rank: string | null;
1123
+ }): Promise<void>;
1113
1124
  /**
1114
1125
  * Get chat event log ("Recent actions" in official clients).
1115
1126
  *
@@ -1259,9 +1270,18 @@ export interface TelegramClient extends ITelegramClient {
1259
1270
  */
1260
1271
  getChat(chatId: InputPeerLike): Promise<Chat>;
1261
1272
  /**
1262
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
1273
+ * Get basic information about multiple chats.
1263
1274
  *
1264
- * You must be the creator of the channel/supergroup to use this method.
1275
+ * **Available**: both users and bots
1276
+ *
1277
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
1278
+ * @returns The list of chats in the same order as the input
1279
+ */
1280
+ getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
1281
+ /**
1282
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
1283
+ *
1284
+ * You must be the creator of the chat/channel/supergroup to use this method.
1265
1285
  */
1266
1286
  getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
1267
1287
  /**
@@ -1295,6 +1315,15 @@ export interface TelegramClient extends ITelegramClient {
1295
1315
  getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
1296
1316
  /** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
1297
1317
  getPeer(peer: InputPeerLike): Promise<Peer>;
1318
+ /**
1319
+ * Get basic information about multiple peers.
1320
+ *
1321
+ * **Available**: ✅ both users and bots
1322
+ *
1323
+ * @param chatIds Chat identifiers. Can be ID, username or TL object
1324
+ * @returns The list of peers in the same order as the input
1325
+ */
1326
+ getPeers(chatIds: InputPeerLike[]): Promise<(Peer | null)[]>;
1298
1327
  /**
1299
1328
  * Get channels that are similar to a given channel
1300
1329
  *
@@ -1615,7 +1644,10 @@ export interface TelegramClient extends ITelegramClient {
1615
1644
  * @param chatId Chat ID or username
1616
1645
  * @param [enabled=false] Whether content protection should be enabled
1617
1646
  */
1618
- toggleContentProtection(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
1647
+ toggleContentProtection(chatId: InputPeerLike, enabled?: boolean, params?: {
1648
+ /** If this method was called in response to the other party enabling content protection, ID of that message */
1649
+ requestMsgId?: number;
1650
+ }): Promise<void>;
1619
1651
  /**
1620
1652
  * Toggle a collectible (Fragment) username
1621
1653
  *
@@ -1660,6 +1692,20 @@ export interface TelegramClient extends ITelegramClient {
1660
1692
  * @param [enabled=false] Whether join-to-send setting should be enabled
1661
1693
  */
1662
1694
  toggleJoinToSend(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
1695
+ /**
1696
+ * Transfer ownership of a chat/channel/supergroup to another user.
1697
+ *
1698
+ * You must be the creator of the chat to use this method,
1699
+ * and your account must have 2FA enabled.
1700
+ */
1701
+ transferChatOwnership(params: {
1702
+ /** ID of the chat/channel/supergroup to transfer */
1703
+ chatId: InputPeerLike;
1704
+ /** ID of the user to transfer ownership to */
1705
+ userId: InputPeerLike;
1706
+ /** Your 2FA password */
1707
+ password: string;
1708
+ }): Promise<void>;
1663
1709
  /**
1664
1710
  * Unarchive one or more chats
1665
1711
  *
@@ -1760,6 +1806,8 @@ export interface TelegramClient extends ITelegramClient {
1760
1806
  /**
1761
1807
  * Set a note for a contact
1762
1808
  *
1809
+ * **Available**: 👤 users only
1810
+ *
1763
1811
  * @param userId ID of the user to set the note for
1764
1812
  * @param note Note text
1765
1813
  */
@@ -2199,6 +2247,8 @@ export interface TelegramClient extends ITelegramClient {
2199
2247
  *
2200
2248
  * Only admins with `manageTopics` permission can do this.
2201
2249
  *
2250
+ * **Available**: 👤 users only
2251
+ *
2202
2252
  * @returns Service message for the created topic
2203
2253
  */
2204
2254
  createForumTopic(params: {
@@ -2230,6 +2280,8 @@ export interface TelegramClient extends ITelegramClient {
2230
2280
  /**
2231
2281
  * Delete a forum topic and all its history
2232
2282
  *
2283
+ * **Available**: 👤 users only
2284
+ *
2233
2285
  * @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
2234
2286
  * @param topicId ID of the topic (i.e. its top message ID)
2235
2287
  */
@@ -2245,6 +2297,8 @@ export interface TelegramClient extends ITelegramClient {
2245
2297
  *
2246
2298
  * Only admins with `manageTopics` permission can do this.
2247
2299
  *
2300
+ * **Available**: 👤 users only
2301
+ *
2248
2302
  * @param chatId Chat ID or username
2249
2303
  * @param topicId ID of the topic (i.e. its top message ID)
2250
2304
  * @returns Service message about the modification
@@ -2278,12 +2332,16 @@ export interface TelegramClient extends ITelegramClient {
2278
2332
  /**
2279
2333
  * Get forum topics by their IDs
2280
2334
  *
2335
+ * **Available**: 👤 users only
2336
+ *
2281
2337
  * @param chatId Chat ID or username
2282
2338
  */
2283
2339
  getForumTopicsById(chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
2284
2340
  /**
2285
2341
  * Get forum topics
2286
2342
  *
2343
+ * **Available**: 👤 users only
2344
+ *
2287
2345
  * @param chatId Chat ID or username
2288
2346
  */
2289
2347
  getForumTopics(chatId: InputPeerLike, params?: {
@@ -2325,6 +2383,8 @@ export interface TelegramClient extends ITelegramClient {
2325
2383
  * Reorder pinned forum topics
2326
2384
  *
2327
2385
  * Only admins with `manageTopics` permission can do this.
2386
+ * **Available**: 👤 users only
2387
+ *
2328
2388
  */
2329
2389
  reorderPinnedForumTopics(params: {
2330
2390
  /** Chat ID or username */
@@ -2343,6 +2403,8 @@ export interface TelegramClient extends ITelegramClient {
2343
2403
  *
2344
2404
  * Only admins with `manageTopics` permission can do this.
2345
2405
  *
2406
+ * **Available**: 👤 users only
2407
+ *
2346
2408
  * @returns Service message about the modification
2347
2409
  */
2348
2410
  toggleForumTopicClosed(parmas: {
@@ -2362,6 +2424,8 @@ export interface TelegramClient extends ITelegramClient {
2362
2424
  * Toggle whether a topic in a forum is pinned
2363
2425
  *
2364
2426
  * Only admins with `manageTopics` permission can do this.
2427
+ * **Available**: 👤 users only
2428
+ *
2365
2429
  */
2366
2430
  toggleForumTopicPinned(params: {
2367
2431
  /** Chat ID or username */
@@ -2511,6 +2575,8 @@ export interface TelegramClient extends ITelegramClient {
2511
2575
  getStarGiftOptions(): Promise<StarGift[]>;
2512
2576
  /**
2513
2577
  * Get a list of all possible attributes when upgrading a given star gift
2578
+ * **Available**: 👤 users only
2579
+ *
2514
2580
  */
2515
2581
  getStarGiftUpgradeOptions(giftId: tl.Long): Promise<StarGiftUpgradeOptions>;
2516
2582
  /**
@@ -2590,6 +2656,8 @@ export interface TelegramClient extends ITelegramClient {
2590
2656
  /**
2591
2657
  * Accept or decline a purchase offer for a star gift
2592
2658
  *
2659
+ * **Available**: 👤 users only
2660
+ *
2593
2661
  * @returns The generated service message
2594
2662
  */
2595
2663
  resolveStarGiftOffer(options: {
@@ -2605,6 +2673,8 @@ export interface TelegramClient extends ITelegramClient {
2605
2673
  }): Promise<Message>;
2606
2674
  /**
2607
2675
  * Create a purchase offer for a unique star gift
2676
+ * **Available**: 👤 users only
2677
+ *
2608
2678
  * @param client
2609
2679
  * @param params
2610
2680
  */
@@ -5175,11 +5245,10 @@ export interface TelegramClient extends ITelegramClient {
5175
5245
  * Get information about multiple users.
5176
5246
  * You can retrieve up to 200 users at once.
5177
5247
  *
5178
- * Note that order is not guaranteed.
5179
- *
5180
5248
  * **Available**: ✅ both users and bots
5181
5249
  *
5182
5250
  * @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
5251
+ * @returns The list of users in the same order as the input
5183
5252
  */
5184
5253
  getUsers(ids: MaybeArray<InputPeerLike>): Promise<(User | null)[]>;
5185
5254
  /**
@@ -54,7 +54,7 @@ const _getChatsBatched = queryBatcher.batchedQuery({
54
54
  fetch: (client, items) => client.call({
55
55
  _: "messages.getChats",
56
56
  id: items
57
- }).then((res) => res.chats.filter((it) => it._ === "chat")),
57
+ }).then((res) => res.chats.filter((it) => it._ === "chat" || it._ === "chatForbidden")),
58
58
  inputKey: (id) => id,
59
59
  outputKey: (item) => item.id,
60
60
  maxBatchSize: 50,
@@ -65,9 +65,7 @@ const _getChannelsBatched = queryBatcher.batchedQuery({
65
65
  _: "channels.getChannels",
66
66
  id: items
67
67
  }).then(
68
- (res) => res.chats.filter(
69
- (it) => it._ === "channel" || it._ === "channelForbidden"
70
- )
68
+ (res) => res.chats.filter((it) => it._ === "channel" || it._ === "channelForbidden")
71
69
  ),
72
70
  inputKey: (id) => {
73
71
  switch (id._) {
@@ -4,7 +4,7 @@ import { tl } from '@mtcute/tl';
4
4
  /** @internal */
5
5
  export declare const _getUsersBatched: BatchedQuery<tl.TypeInputUser, tl.TypeUser>;
6
6
  /** @internal */
7
- export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat>;
7
+ export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat | tl.RawChatForbidden>;
8
8
  /** @internal */
9
9
  export declare const _getChannelsBatched: BatchedQuery<tl.TypeInputChannel, tl.RawChannel | tl.RawChannelForbidden>;
10
10
  /** @internal */
@@ -4,7 +4,7 @@ import { tl } from '@mtcute/tl';
4
4
  /** @internal */
5
5
  export declare const _getUsersBatched: BatchedQuery<tl.TypeInputUser, tl.TypeUser>;
6
6
  /** @internal */
7
- export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat>;
7
+ export declare const _getChatsBatched: BatchedQuery<number, tl.RawChat | tl.RawChatForbidden>;
8
8
  /** @internal */
9
9
  export declare const _getChannelsBatched: BatchedQuery<tl.TypeInputChannel, tl.RawChannel | tl.RawChannelForbidden>;
10
10
  /** @internal */
@@ -47,7 +47,7 @@ const _getChatsBatched = batchedQuery({
47
47
  fetch: (client, items) => client.call({
48
48
  _: "messages.getChats",
49
49
  id: items
50
- }).then((res) => res.chats.filter((it) => it._ === "chat")),
50
+ }).then((res) => res.chats.filter((it) => it._ === "chat" || it._ === "chatForbidden")),
51
51
  inputKey: (id) => id,
52
52
  outputKey: (item) => item.id,
53
53
  maxBatchSize: 50,
@@ -58,9 +58,7 @@ const _getChannelsBatched = batchedQuery({
58
58
  _: "channels.getChannels",
59
59
  id: items
60
60
  }).then(
61
- (res) => res.chats.filter(
62
- (it) => it._ === "channel" || it._ === "channelForbidden"
63
- )
61
+ (res) => res.chats.filter((it) => it._ === "channel" || it._ === "channelForbidden")
64
62
  ),
65
63
  inputKey: (id) => {
66
64
  switch (id._) {
@@ -0,0 +1,19 @@
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
+ async function editChatMemberRank(client, params) {
10
+ const { chatId, participantId, rank } = params;
11
+ const res = await client.call({
12
+ _: "messages.editChatParticipantRank",
13
+ peer: await resolvePeer.resolvePeer(client, chatId),
14
+ participant: await resolvePeer.resolvePeer(client, participantId),
15
+ rank: rank ?? ""
16
+ });
17
+ client.handleClientUpdate(res);
18
+ }
19
+ exports.editChatMemberRank = editChatMemberRank;
@@ -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>;