@mtcute/core 0.28.1 → 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 (73) hide show
  1. package/client.cjs +8 -0
  2. package/client.js +8 -0
  3. package/highlevel/client.d.cts +55 -3
  4. package/highlevel/client.d.ts +55 -3
  5. package/highlevel/methods/chats/edit-chat-member-rank.cjs +19 -0
  6. package/highlevel/methods/chats/edit-chat-member-rank.d.cts +13 -0
  7. package/highlevel/methods/chats/edit-chat-member-rank.d.ts +13 -0
  8. package/highlevel/methods/chats/edit-chat-member-rank.js +14 -0
  9. package/highlevel/methods/chats/get-creator-after-leave.cjs +20 -4
  10. package/highlevel/methods/chats/get-creator-after-leave.d.cts +2 -2
  11. package/highlevel/methods/chats/get-creator-after-leave.d.ts +2 -2
  12. package/highlevel/methods/chats/get-creator-after-leave.js +21 -5
  13. package/highlevel/methods/chats/toggle-content-protection.cjs +3 -2
  14. package/highlevel/methods/chats/toggle-content-protection.d.cts +4 -1
  15. package/highlevel/methods/chats/toggle-content-protection.d.ts +4 -1
  16. package/highlevel/methods/chats/toggle-content-protection.js +3 -2
  17. package/highlevel/methods/chats/transfer-chat-ownership.cjs +36 -0
  18. package/highlevel/methods/chats/transfer-chat-ownership.d.cts +16 -0
  19. package/highlevel/methods/chats/transfer-chat-ownership.d.ts +16 -0
  20. package/highlevel/methods/chats/transfer-chat-ownership.js +31 -0
  21. package/highlevel/methods/files/upload-file.cjs +2 -2
  22. package/highlevel/methods/files/upload-file.js +2 -2
  23. package/highlevel/methods/users/resolve-peer.cjs +4 -4
  24. package/highlevel/methods/users/resolve-peer.js +4 -4
  25. package/highlevel/methods.d.cts +2 -0
  26. package/highlevel/methods.d.ts +2 -0
  27. package/highlevel/types/messages/message-action.cjs +13 -0
  28. package/highlevel/types/messages/message-action.d.cts +19 -1
  29. package/highlevel/types/messages/message-action.d.ts +19 -1
  30. package/highlevel/types/messages/message-action.js +13 -0
  31. package/highlevel/types/messages/message.cjs +4 -0
  32. package/highlevel/types/messages/message.d.cts +2 -0
  33. package/highlevel/types/messages/message.d.ts +2 -0
  34. package/highlevel/types/messages/message.js +4 -0
  35. package/highlevel/types/peers/chat-event/actions.cjs +7 -0
  36. package/highlevel/types/peers/chat-event/actions.d.cts +11 -1
  37. package/highlevel/types/peers/chat-event/actions.d.ts +11 -1
  38. package/highlevel/types/peers/chat-event/actions.js +7 -0
  39. package/highlevel/types/peers/chat-event/filters.cjs +1 -0
  40. package/highlevel/types/peers/chat-event/filters.js +1 -0
  41. package/highlevel/types/peers/chat-member.cjs +5 -8
  42. package/highlevel/types/peers/chat-member.d.cts +2 -2
  43. package/highlevel/types/peers/chat-member.d.ts +2 -2
  44. package/highlevel/types/peers/chat-member.js +5 -8
  45. package/highlevel/types/peers/full-user.cjs +14 -0
  46. package/highlevel/types/peers/full-user.d.cts +10 -0
  47. package/highlevel/types/peers/full-user.d.ts +10 -0
  48. package/highlevel/types/peers/full-user.js +14 -0
  49. package/highlevel/utils/file-utils.cjs +2 -2
  50. package/highlevel/utils/file-utils.d.cts +1 -1
  51. package/highlevel/utils/file-utils.d.ts +1 -1
  52. package/highlevel/utils/file-utils.js +2 -2
  53. package/methods.cjs +4 -0
  54. package/methods.js +4 -0
  55. package/network/network-manager.cjs +1 -1
  56. package/network/network-manager.js +1 -1
  57. package/network/server-salt.cjs +4 -8
  58. package/network/server-salt.js +4 -8
  59. package/package.json +3 -3
  60. package/utils/binary/compat.cjs +8 -0
  61. package/utils/binary/compat.js +8 -0
  62. package/utils/date-entity-format.cjs +48 -0
  63. package/utils/date-entity-format.d.cts +24 -0
  64. package/utils/date-entity-format.d.ts +24 -0
  65. package/utils/date-entity-format.js +43 -0
  66. package/utils/date-entity-format.test.d.cts +1 -0
  67. package/utils/date-entity-format.test.d.ts +1 -0
  68. package/utils/index.d.cts +1 -0
  69. package/utils/index.d.ts +1 -0
  70. package/utils/links/bots.cjs +3 -0
  71. package/utils/links/bots.js +3 -0
  72. package/utils.cjs +3 -0
  73. package/utils.js +3 -0
package/client.cjs CHANGED
@@ -49,6 +49,7 @@ 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");
@@ -86,6 +87,7 @@ const toggleContentProtection = require("./highlevel/methods/chats/toggle-conten
86
87
  const toggleFragmentUsername = require("./highlevel/methods/chats/toggle-fragment-username.cjs");
87
88
  const toggleJoinRequests = require("./highlevel/methods/chats/toggle-join-requests.cjs");
88
89
  const toggleJoinToSend = require("./highlevel/methods/chats/toggle-join-to-send.cjs");
90
+ const transferChatOwnership = require("./highlevel/methods/chats/transfer-chat-ownership.cjs");
89
91
  const unarchiveChats = require("./highlevel/methods/chats/unarchive-chats.cjs");
90
92
  const unbanChatMember = require("./highlevel/methods/chats/unban-chat-member.cjs");
91
93
  const addContact = require("./highlevel/methods/contacts/add-contact.cjs");
@@ -585,6 +587,9 @@ TelegramClient.prototype.deleteUserHistory = function(...args) {
585
587
  TelegramClient.prototype.editAdminRights = function(...args) {
586
588
  return editAdminRights.editAdminRights(this._client, ...args);
587
589
  };
590
+ TelegramClient.prototype.editChatMemberRank = function(...args) {
591
+ return editChatMemberRank.editChatMemberRank(this._client, ...args);
592
+ };
588
593
  TelegramClient.prototype.getChatEventLog = function(...args) {
589
594
  return getChatEventLog.getChatEventLog(this._client, ...args);
590
595
  };
@@ -699,6 +704,9 @@ TelegramClient.prototype.toggleJoinRequests = function(...args) {
699
704
  TelegramClient.prototype.toggleJoinToSend = function(...args) {
700
705
  return toggleJoinToSend.toggleJoinToSend(this._client, ...args);
701
706
  };
707
+ TelegramClient.prototype.transferChatOwnership = function(...args) {
708
+ return transferChatOwnership.transferChatOwnership(this._client, ...args);
709
+ };
702
710
  TelegramClient.prototype.unarchiveChats = function(...args) {
703
711
  return unarchiveChats.unarchiveChats(this._client, ...args);
704
712
  };
package/client.js CHANGED
@@ -42,6 +42,7 @@ 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";
@@ -79,6 +80,7 @@ import { toggleContentProtection } from "./highlevel/methods/chats/toggle-conten
79
80
  import { toggleFragmentUsername } from "./highlevel/methods/chats/toggle-fragment-username.js";
80
81
  import { toggleJoinRequests } from "./highlevel/methods/chats/toggle-join-requests.js";
81
82
  import { toggleJoinToSend } from "./highlevel/methods/chats/toggle-join-to-send.js";
83
+ import { transferChatOwnership } from "./highlevel/methods/chats/transfer-chat-ownership.js";
82
84
  import { unarchiveChats } from "./highlevel/methods/chats/unarchive-chats.js";
83
85
  import { unbanChatMember } from "./highlevel/methods/chats/unban-chat-member.js";
84
86
  import { addContact } from "./highlevel/methods/contacts/add-contact.js";
@@ -578,6 +580,9 @@ TelegramClient.prototype.deleteUserHistory = function(...args) {
578
580
  TelegramClient.prototype.editAdminRights = function(...args) {
579
581
  return editAdminRights(this._client, ...args);
580
582
  };
583
+ TelegramClient.prototype.editChatMemberRank = function(...args) {
584
+ return editChatMemberRank(this._client, ...args);
585
+ };
581
586
  TelegramClient.prototype.getChatEventLog = function(...args) {
582
587
  return getChatEventLog(this._client, ...args);
583
588
  };
@@ -692,6 +697,9 @@ TelegramClient.prototype.toggleJoinRequests = function(...args) {
692
697
  TelegramClient.prototype.toggleJoinToSend = function(...args) {
693
698
  return toggleJoinToSend(this._client, ...args);
694
699
  };
700
+ TelegramClient.prototype.transferChatOwnership = function(...args) {
701
+ return transferChatOwnership(this._client, ...args);
702
+ };
695
703
  TelegramClient.prototype.unarchiveChats = function(...args) {
696
704
  return unarchiveChats(this._client, ...args);
697
705
  };
@@ -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
  *
@@ -1268,9 +1279,9 @@ export interface TelegramClient extends ITelegramClient {
1268
1279
  */
1269
1280
  getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
1270
1281
  /**
1271
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
1282
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
1272
1283
  *
1273
- * You must be the creator of the channel/supergroup to use this method.
1284
+ * You must be the creator of the chat/channel/supergroup to use this method.
1274
1285
  */
1275
1286
  getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
1276
1287
  /**
@@ -1633,7 +1644,10 @@ export interface TelegramClient extends ITelegramClient {
1633
1644
  * @param chatId Chat ID or username
1634
1645
  * @param [enabled=false] Whether content protection should be enabled
1635
1646
  */
1636
- 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>;
1637
1651
  /**
1638
1652
  * Toggle a collectible (Fragment) username
1639
1653
  *
@@ -1678,6 +1692,20 @@ export interface TelegramClient extends ITelegramClient {
1678
1692
  * @param [enabled=false] Whether join-to-send setting should be enabled
1679
1693
  */
1680
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>;
1681
1709
  /**
1682
1710
  * Unarchive one or more chats
1683
1711
  *
@@ -1778,6 +1806,8 @@ export interface TelegramClient extends ITelegramClient {
1778
1806
  /**
1779
1807
  * Set a note for a contact
1780
1808
  *
1809
+ * **Available**: 👤 users only
1810
+ *
1781
1811
  * @param userId ID of the user to set the note for
1782
1812
  * @param note Note text
1783
1813
  */
@@ -2217,6 +2247,8 @@ export interface TelegramClient extends ITelegramClient {
2217
2247
  *
2218
2248
  * Only admins with `manageTopics` permission can do this.
2219
2249
  *
2250
+ * **Available**: 👤 users only
2251
+ *
2220
2252
  * @returns Service message for the created topic
2221
2253
  */
2222
2254
  createForumTopic(params: {
@@ -2248,6 +2280,8 @@ export interface TelegramClient extends ITelegramClient {
2248
2280
  /**
2249
2281
  * Delete a forum topic and all its history
2250
2282
  *
2283
+ * **Available**: 👤 users only
2284
+ *
2251
2285
  * @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
2252
2286
  * @param topicId ID of the topic (i.e. its top message ID)
2253
2287
  */
@@ -2263,6 +2297,8 @@ export interface TelegramClient extends ITelegramClient {
2263
2297
  *
2264
2298
  * Only admins with `manageTopics` permission can do this.
2265
2299
  *
2300
+ * **Available**: 👤 users only
2301
+ *
2266
2302
  * @param chatId Chat ID or username
2267
2303
  * @param topicId ID of the topic (i.e. its top message ID)
2268
2304
  * @returns Service message about the modification
@@ -2296,12 +2332,16 @@ export interface TelegramClient extends ITelegramClient {
2296
2332
  /**
2297
2333
  * Get forum topics by their IDs
2298
2334
  *
2335
+ * **Available**: 👤 users only
2336
+ *
2299
2337
  * @param chatId Chat ID or username
2300
2338
  */
2301
2339
  getForumTopicsById(chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
2302
2340
  /**
2303
2341
  * Get forum topics
2304
2342
  *
2343
+ * **Available**: 👤 users only
2344
+ *
2305
2345
  * @param chatId Chat ID or username
2306
2346
  */
2307
2347
  getForumTopics(chatId: InputPeerLike, params?: {
@@ -2343,6 +2383,8 @@ export interface TelegramClient extends ITelegramClient {
2343
2383
  * Reorder pinned forum topics
2344
2384
  *
2345
2385
  * Only admins with `manageTopics` permission can do this.
2386
+ * **Available**: 👤 users only
2387
+ *
2346
2388
  */
2347
2389
  reorderPinnedForumTopics(params: {
2348
2390
  /** Chat ID or username */
@@ -2361,6 +2403,8 @@ export interface TelegramClient extends ITelegramClient {
2361
2403
  *
2362
2404
  * Only admins with `manageTopics` permission can do this.
2363
2405
  *
2406
+ * **Available**: 👤 users only
2407
+ *
2364
2408
  * @returns Service message about the modification
2365
2409
  */
2366
2410
  toggleForumTopicClosed(parmas: {
@@ -2380,6 +2424,8 @@ export interface TelegramClient extends ITelegramClient {
2380
2424
  * Toggle whether a topic in a forum is pinned
2381
2425
  *
2382
2426
  * Only admins with `manageTopics` permission can do this.
2427
+ * **Available**: 👤 users only
2428
+ *
2383
2429
  */
2384
2430
  toggleForumTopicPinned(params: {
2385
2431
  /** Chat ID or username */
@@ -2529,6 +2575,8 @@ export interface TelegramClient extends ITelegramClient {
2529
2575
  getStarGiftOptions(): Promise<StarGift[]>;
2530
2576
  /**
2531
2577
  * Get a list of all possible attributes when upgrading a given star gift
2578
+ * **Available**: 👤 users only
2579
+ *
2532
2580
  */
2533
2581
  getStarGiftUpgradeOptions(giftId: tl.Long): Promise<StarGiftUpgradeOptions>;
2534
2582
  /**
@@ -2608,6 +2656,8 @@ export interface TelegramClient extends ITelegramClient {
2608
2656
  /**
2609
2657
  * Accept or decline a purchase offer for a star gift
2610
2658
  *
2659
+ * **Available**: 👤 users only
2660
+ *
2611
2661
  * @returns The generated service message
2612
2662
  */
2613
2663
  resolveStarGiftOffer(options: {
@@ -2623,6 +2673,8 @@ export interface TelegramClient extends ITelegramClient {
2623
2673
  }): Promise<Message>;
2624
2674
  /**
2625
2675
  * Create a purchase offer for a unique star gift
2676
+ * **Available**: 👤 users only
2677
+ *
2626
2678
  * @param client
2627
2679
  * @param params
2628
2680
  */
@@ -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
  *
@@ -1268,9 +1279,9 @@ export interface TelegramClient extends ITelegramClient {
1268
1279
  */
1269
1280
  getChats(chatIds: InputPeerLike[]): Promise<(Chat | null)[]>;
1270
1281
  /**
1271
- * Get the user who will be made the creator of the channel/supergroup if you were to leave it.
1282
+ * Get the user who will be made the creator of the chat/channel/supergroup if you were to leave it.
1272
1283
  *
1273
- * You must be the creator of the channel/supergroup to use this method.
1284
+ * You must be the creator of the chat/channel/supergroup to use this method.
1274
1285
  */
1275
1286
  getCreatorAfterLeave(chatId: InputPeerLike): Promise<User | null>;
1276
1287
  /**
@@ -1633,7 +1644,10 @@ export interface TelegramClient extends ITelegramClient {
1633
1644
  * @param chatId Chat ID or username
1634
1645
  * @param [enabled=false] Whether content protection should be enabled
1635
1646
  */
1636
- 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>;
1637
1651
  /**
1638
1652
  * Toggle a collectible (Fragment) username
1639
1653
  *
@@ -1678,6 +1692,20 @@ export interface TelegramClient extends ITelegramClient {
1678
1692
  * @param [enabled=false] Whether join-to-send setting should be enabled
1679
1693
  */
1680
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>;
1681
1709
  /**
1682
1710
  * Unarchive one or more chats
1683
1711
  *
@@ -1778,6 +1806,8 @@ export interface TelegramClient extends ITelegramClient {
1778
1806
  /**
1779
1807
  * Set a note for a contact
1780
1808
  *
1809
+ * **Available**: 👤 users only
1810
+ *
1781
1811
  * @param userId ID of the user to set the note for
1782
1812
  * @param note Note text
1783
1813
  */
@@ -2217,6 +2247,8 @@ export interface TelegramClient extends ITelegramClient {
2217
2247
  *
2218
2248
  * Only admins with `manageTopics` permission can do this.
2219
2249
  *
2250
+ * **Available**: 👤 users only
2251
+ *
2220
2252
  * @returns Service message for the created topic
2221
2253
  */
2222
2254
  createForumTopic(params: {
@@ -2248,6 +2280,8 @@ export interface TelegramClient extends ITelegramClient {
2248
2280
  /**
2249
2281
  * Delete a forum topic and all its history
2250
2282
  *
2283
+ * **Available**: 👤 users only
2284
+ *
2251
2285
  * @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
2252
2286
  * @param topicId ID of the topic (i.e. its top message ID)
2253
2287
  */
@@ -2263,6 +2297,8 @@ export interface TelegramClient extends ITelegramClient {
2263
2297
  *
2264
2298
  * Only admins with `manageTopics` permission can do this.
2265
2299
  *
2300
+ * **Available**: 👤 users only
2301
+ *
2266
2302
  * @param chatId Chat ID or username
2267
2303
  * @param topicId ID of the topic (i.e. its top message ID)
2268
2304
  * @returns Service message about the modification
@@ -2296,12 +2332,16 @@ export interface TelegramClient extends ITelegramClient {
2296
2332
  /**
2297
2333
  * Get forum topics by their IDs
2298
2334
  *
2335
+ * **Available**: 👤 users only
2336
+ *
2299
2337
  * @param chatId Chat ID or username
2300
2338
  */
2301
2339
  getForumTopicsById(chatId: InputPeerLike, ids: MaybeArray<number>): Promise<ForumTopic[]>;
2302
2340
  /**
2303
2341
  * Get forum topics
2304
2342
  *
2343
+ * **Available**: 👤 users only
2344
+ *
2305
2345
  * @param chatId Chat ID or username
2306
2346
  */
2307
2347
  getForumTopics(chatId: InputPeerLike, params?: {
@@ -2343,6 +2383,8 @@ export interface TelegramClient extends ITelegramClient {
2343
2383
  * Reorder pinned forum topics
2344
2384
  *
2345
2385
  * Only admins with `manageTopics` permission can do this.
2386
+ * **Available**: 👤 users only
2387
+ *
2346
2388
  */
2347
2389
  reorderPinnedForumTopics(params: {
2348
2390
  /** Chat ID or username */
@@ -2361,6 +2403,8 @@ export interface TelegramClient extends ITelegramClient {
2361
2403
  *
2362
2404
  * Only admins with `manageTopics` permission can do this.
2363
2405
  *
2406
+ * **Available**: 👤 users only
2407
+ *
2364
2408
  * @returns Service message about the modification
2365
2409
  */
2366
2410
  toggleForumTopicClosed(parmas: {
@@ -2380,6 +2424,8 @@ export interface TelegramClient extends ITelegramClient {
2380
2424
  * Toggle whether a topic in a forum is pinned
2381
2425
  *
2382
2426
  * Only admins with `manageTopics` permission can do this.
2427
+ * **Available**: 👤 users only
2428
+ *
2383
2429
  */
2384
2430
  toggleForumTopicPinned(params: {
2385
2431
  /** Chat ID or username */
@@ -2529,6 +2575,8 @@ export interface TelegramClient extends ITelegramClient {
2529
2575
  getStarGiftOptions(): Promise<StarGift[]>;
2530
2576
  /**
2531
2577
  * Get a list of all possible attributes when upgrading a given star gift
2578
+ * **Available**: 👤 users only
2579
+ *
2532
2580
  */
2533
2581
  getStarGiftUpgradeOptions(giftId: tl.Long): Promise<StarGiftUpgradeOptions>;
2534
2582
  /**
@@ -2608,6 +2656,8 @@ export interface TelegramClient extends ITelegramClient {
2608
2656
  /**
2609
2657
  * Accept or decline a purchase offer for a star gift
2610
2658
  *
2659
+ * **Available**: 👤 users only
2660
+ *
2611
2661
  * @returns The generated service message
2612
2662
  */
2613
2663
  resolveStarGiftOffer(options: {
@@ -2623,6 +2673,8 @@ export interface TelegramClient extends ITelegramClient {
2623
2673
  }): Promise<Message>;
2624
2674
  /**
2625
2675
  * Create a purchase offer for a unique star gift
2676
+ * **Available**: 👤 users only
2677
+ *
2626
2678
  * @param client
2627
2679
  * @param params
2628
2680
  */
@@ -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>;
@@ -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
+ };
@@ -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
  }
@@ -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>;