@mtcute/core 0.26.0 → 0.26.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 (91) hide show
  1. package/highlevel/client.d.cts +3 -3
  2. package/highlevel/client.d.ts +3 -3
  3. package/highlevel/methods/chats/set-chat-color.cjs +5 -2
  4. package/highlevel/methods/chats/set-chat-color.d.cts +0 -2
  5. package/highlevel/methods/chats/set-chat-color.d.ts +0 -2
  6. package/highlevel/methods/chats/set-chat-color.js +5 -2
  7. package/highlevel/methods/contacts/add-contact.cjs +4 -2
  8. package/highlevel/methods/contacts/add-contact.d.cts +5 -1
  9. package/highlevel/methods/contacts/add-contact.d.ts +5 -1
  10. package/highlevel/methods/contacts/add-contact.js +4 -2
  11. package/highlevel/methods/contacts/set-contact-note.d.cts +9 -0
  12. package/highlevel/methods/contacts/set-contact-note.d.ts +9 -0
  13. package/highlevel/methods/forums/create-forum-topic.cjs +2 -2
  14. package/highlevel/methods/forums/create-forum-topic.js +3 -3
  15. package/highlevel/methods/forums/delete-forum-topic-history.cjs +9 -6
  16. package/highlevel/methods/forums/delete-forum-topic-history.js +10 -7
  17. package/highlevel/methods/forums/edit-forum-topic.cjs +6 -4
  18. package/highlevel/methods/forums/edit-forum-topic.d.cts +4 -0
  19. package/highlevel/methods/forums/edit-forum-topic.d.ts +4 -0
  20. package/highlevel/methods/forums/edit-forum-topic.js +7 -5
  21. package/highlevel/methods/forums/get-forum-topics-by-id.cjs +2 -2
  22. package/highlevel/methods/forums/get-forum-topics-by-id.js +3 -3
  23. package/highlevel/methods/forums/get-forum-topics.cjs +2 -2
  24. package/highlevel/methods/forums/get-forum-topics.js +3 -3
  25. package/highlevel/methods/forums/iter-forum-topics.cjs +1 -1
  26. package/highlevel/methods/forums/iter-forum-topics.js +2 -2
  27. package/highlevel/methods/messages/append-todo-list.cjs +1 -1
  28. package/highlevel/methods/messages/append-todo-list.js +1 -1
  29. package/highlevel/methods/messages/get-messages-unsafe.d.cts +1 -1
  30. package/highlevel/methods/messages/get-messages-unsafe.d.ts +1 -1
  31. package/highlevel/methods/messages/get-messages.d.cts +1 -1
  32. package/highlevel/methods/messages/get-messages.d.ts +1 -1
  33. package/highlevel/methods/messages/get-scheduled-messages.d.cts +1 -1
  34. package/highlevel/methods/messages/get-scheduled-messages.d.ts +1 -1
  35. package/highlevel/methods/premium/get-saved-star-gifts.cjs +1 -0
  36. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +4 -0
  37. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +4 -0
  38. package/highlevel/methods/premium/get-saved-star-gifts.js +1 -0
  39. package/highlevel/methods/users/set-emoji-status.cjs +2 -7
  40. package/highlevel/methods/users/set-emoji-status.js +2 -7
  41. package/highlevel/storage/service/current-user.cjs +5 -4
  42. package/highlevel/storage/service/current-user.js +5 -4
  43. package/highlevel/types/messages/message-action.cjs +15 -2
  44. package/highlevel/types/messages/message-action.d.cts +14 -1
  45. package/highlevel/types/messages/message-action.d.ts +14 -1
  46. package/highlevel/types/messages/message-action.js +15 -2
  47. package/highlevel/types/peers/chat-event/actions.cjs +1 -0
  48. package/highlevel/types/peers/chat-event/actions.js +1 -0
  49. package/highlevel/types/peers/chat.cjs +8 -2
  50. package/highlevel/types/peers/chat.js +8 -2
  51. package/highlevel/types/peers/forum-topic.cjs +10 -0
  52. package/highlevel/types/peers/forum-topic.d.cts +5 -0
  53. package/highlevel/types/peers/forum-topic.d.ts +5 -0
  54. package/highlevel/types/peers/forum-topic.js +10 -0
  55. package/highlevel/types/peers/full-user.cjs +4 -0
  56. package/highlevel/types/peers/full-user.d.cts +3 -0
  57. package/highlevel/types/peers/full-user.d.ts +3 -0
  58. package/highlevel/types/peers/full-user.js +4 -0
  59. package/highlevel/types/peers/user.cjs +12 -2
  60. package/highlevel/types/peers/user.d.cts +2 -0
  61. package/highlevel/types/peers/user.d.ts +2 -0
  62. package/highlevel/types/peers/user.js +12 -2
  63. package/highlevel/types/premium/saved-star-gift.cjs +4 -0
  64. package/highlevel/types/premium/saved-star-gift.d.cts +2 -0
  65. package/highlevel/types/premium/saved-star-gift.d.ts +2 -0
  66. package/highlevel/types/premium/saved-star-gift.js +4 -0
  67. package/highlevel/types/premium/stars-gift-unique.cjs +24 -0
  68. package/highlevel/types/premium/stars-gift-unique.d.cts +14 -0
  69. package/highlevel/types/premium/stars-gift-unique.d.ts +14 -0
  70. package/highlevel/types/premium/stars-gift-unique.js +24 -0
  71. package/highlevel/types/premium/stars-gift.cjs +4 -0
  72. package/highlevel/types/premium/stars-gift.d.cts +2 -0
  73. package/highlevel/types/premium/stars-gift.d.ts +2 -0
  74. package/highlevel/types/premium/stars-gift.js +4 -0
  75. package/highlevel/types/premium/stars-transaction.cjs +6 -0
  76. package/highlevel/types/premium/stars-transaction.d.cts +7 -0
  77. package/highlevel/types/premium/stars-transaction.d.ts +7 -0
  78. package/highlevel/types/premium/stars-transaction.js +6 -0
  79. package/highlevel/types/updates/history-read-update.cjs +2 -1
  80. package/highlevel/types/updates/history-read-update.js +2 -1
  81. package/highlevel/types/updates/user-typing-update.cjs +12 -0
  82. package/highlevel/types/updates/user-typing-update.d.cts +2 -0
  83. package/highlevel/types/updates/user-typing-update.d.ts +2 -0
  84. package/highlevel/types/updates/user-typing-update.js +12 -0
  85. package/network/network-manager.cjs +1 -1
  86. package/network/network-manager.js +1 -1
  87. package/network/session-connection.cjs +16 -4
  88. package/network/session-connection.js +16 -4
  89. package/package.json +2 -2
  90. package/utils/binary/compat.cjs +16 -2
  91. package/utils/binary/compat.js +16 -2
@@ -2965,7 +2965,7 @@ export interface TelegramClient extends ITelegramClient {
2965
2965
  * Unlike {@link getMessages}, this method does not
2966
2966
  * check if the message belongs to some chat.
2967
2967
  *
2968
- * Fot messages that were not found, `null` will be
2968
+ * For messages that were not found, `null` will be
2969
2969
  * returned at that position.
2970
2970
  *
2971
2971
  * **Available**: ✅ both users and bots
@@ -2979,7 +2979,7 @@ export interface TelegramClient extends ITelegramClient {
2979
2979
  /**
2980
2980
  * Get messages in chat by their IDs
2981
2981
  *
2982
- * Fot messages that were not found, `null` will be
2982
+ * For messages that were not found, `null` will be
2983
2983
  * returned at that position.
2984
2984
  *
2985
2985
  * **Available**: ✅ both users and bots
@@ -3027,7 +3027,7 @@ export interface TelegramClient extends ITelegramClient {
3027
3027
  /**
3028
3028
  * Get scheduled messages in chat by their IDs
3029
3029
  *
3030
- * Fot messages that were not found, `null` will be
3030
+ * For messages that were not found, `null` will be
3031
3031
  * returned at that position.
3032
3032
  *
3033
3033
  * **Available**: 👤 users only
@@ -2965,7 +2965,7 @@ export interface TelegramClient extends ITelegramClient {
2965
2965
  * Unlike {@link getMessages}, this method does not
2966
2966
  * check if the message belongs to some chat.
2967
2967
  *
2968
- * Fot messages that were not found, `null` will be
2968
+ * For messages that were not found, `null` will be
2969
2969
  * returned at that position.
2970
2970
  *
2971
2971
  * **Available**: ✅ both users and bots
@@ -2979,7 +2979,7 @@ export interface TelegramClient extends ITelegramClient {
2979
2979
  /**
2980
2980
  * Get messages in chat by their IDs
2981
2981
  *
2982
- * Fot messages that were not found, `null` will be
2982
+ * For messages that were not found, `null` will be
2983
2983
  * returned at that position.
2984
2984
  *
2985
2985
  * **Available**: ✅ both users and bots
@@ -3027,7 +3027,7 @@ export interface TelegramClient extends ITelegramClient {
3027
3027
  /**
3028
3028
  * Get scheduled messages in chat by their IDs
3029
3029
  *
3030
- * Fot messages that were not found, `null` will be
3030
+ * For messages that were not found, `null` will be
3031
3031
  * returned at that position.
3032
3032
  *
3033
3033
  * **Available**: 👤 users only
@@ -30,8 +30,11 @@ async function setChatColor(client, params) {
30
30
  }
31
31
  const r = await client.call({
32
32
  _: "account.updateColor",
33
- color,
34
- backgroundEmojiId,
33
+ color: {
34
+ _: "peerColor",
35
+ color,
36
+ backgroundEmojiId
37
+ },
35
38
  forProfile
36
39
  });
37
40
  typeAssertions.assertTrue("account.updateColor", r);
@@ -31,8 +31,6 @@ export declare function setChatColor(client: ITelegramClient, params: {
31
31
  /**
32
32
  * Whether to set this color for the profile
33
33
  * header instead of chat name/replies.
34
- *
35
- * Currently only available for the current user.
36
34
  */
37
35
  forProfile?: boolean;
38
36
  }): Promise<void>;
@@ -31,8 +31,6 @@ export declare function setChatColor(client: ITelegramClient, params: {
31
31
  /**
32
32
  * Whether to set this color for the profile
33
33
  * header instead of chat name/replies.
34
- *
35
- * Currently only available for the current user.
36
34
  */
37
35
  forProfile?: boolean;
38
36
  }): Promise<void>;
@@ -23,8 +23,11 @@ async function setChatColor(client, params) {
23
23
  }
24
24
  const r = await client.call({
25
25
  _: "account.updateColor",
26
- color,
27
- backgroundEmojiId,
26
+ color: {
27
+ _: "peerColor",
28
+ color,
29
+ backgroundEmojiId
30
+ },
28
31
  forProfile
29
32
  });
30
33
  assertTrue("account.updateColor", r);
@@ -7,9 +7,10 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("../../updates/utils.cjs");
9
9
  const resolvePeer = require("../users/resolve-peer.cjs");
10
+ const entities = require("../../types/misc/entities.cjs");
10
11
  const user = require("../../types/peers/user.cjs");
11
12
  async function addContact(client, params) {
12
- const { userId, firstName, lastName = "", phone = "", sharePhone = false } = params;
13
+ const { userId, firstName, lastName = "", phone = "", sharePhone = false, note } = params;
13
14
  const peer = await resolvePeer.resolveUser(client, userId);
14
15
  const res = await client.call({
15
16
  _: "contacts.addContact",
@@ -17,7 +18,8 @@ async function addContact(client, params) {
17
18
  firstName,
18
19
  lastName,
19
20
  phone,
20
- addPhonePrivacyException: sharePhone
21
+ addPhonePrivacyException: sharePhone,
22
+ note: note ? entities.inputTextToTl(note) : void 0
21
23
  });
22
24
  utils.assertIsUpdatesGroup("contacts.addContact", res);
23
25
  client.handleClientUpdate(res);
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, User } from '../../types/index.js';
2
+ import { InputPeerLike, InputText, User } from '../../types/index.js';
3
3
  /**
4
4
  * Add an existing Telegram user as a contact
5
5
  */
@@ -25,4 +25,8 @@ export declare function addContact(client: ITelegramClient, params: {
25
25
  * @default false
26
26
  */
27
27
  sharePhone?: boolean;
28
+ /**
29
+ * Note to the contact
30
+ */
31
+ note?: InputText;
28
32
  }): Promise<User>;
@@ -1,5 +1,5 @@
1
1
  import { ITelegramClient } from '../../client.types.js';
2
- import { InputPeerLike, User } from '../../types/index.js';
2
+ import { InputPeerLike, InputText, User } from '../../types/index.js';
3
3
  /**
4
4
  * Add an existing Telegram user as a contact
5
5
  */
@@ -25,4 +25,8 @@ export declare function addContact(client: ITelegramClient, params: {
25
25
  * @default false
26
26
  */
27
27
  sharePhone?: boolean;
28
+ /**
29
+ * Note to the contact
30
+ */
31
+ note?: InputText;
28
32
  }): Promise<User>;
@@ -1,8 +1,9 @@
1
1
  import { assertIsUpdatesGroup } from "../../updates/utils.js";
2
2
  import { resolveUser } from "../users/resolve-peer.js";
3
+ import { inputTextToTl } from "../../types/misc/entities.js";
3
4
  import { User as User$2 } from "../../types/peers/user.js";
4
5
  async function addContact(client, params) {
5
- const { userId, firstName, lastName = "", phone = "", sharePhone = false } = params;
6
+ const { userId, firstName, lastName = "", phone = "", sharePhone = false, note } = params;
6
7
  const peer = await resolveUser(client, userId);
7
8
  const res = await client.call({
8
9
  _: "contacts.addContact",
@@ -10,7 +11,8 @@ async function addContact(client, params) {
10
11
  firstName,
11
12
  lastName,
12
13
  phone,
13
- addPhonePrivacyException: sharePhone
14
+ addPhonePrivacyException: sharePhone,
15
+ note: note ? inputTextToTl(note) : void 0
14
16
  });
15
17
  assertIsUpdatesGroup("contacts.addContact", res);
16
18
  client.handleClientUpdate(res);
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, InputText } from '../../types/index.js';
3
+ /**
4
+ * Set a note for a contact
5
+ *
6
+ * @param userId ID of the user to set the note for
7
+ * @param note Note text
8
+ */
9
+ export declare function setContactNote(client: ITelegramClient, userId: InputPeerLike, note: InputText): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike, InputText } from '../../types/index.js';
3
+ /**
4
+ * Set a note for a contact
5
+ *
6
+ * @param userId ID of the user to set the note for
7
+ * @param note Note text
8
+ */
9
+ export declare function setContactNote(client: ITelegramClient, userId: InputPeerLike, note: InputText): Promise<void>;
@@ -11,8 +11,8 @@ const resolvePeer = require("../users/resolve-peer.cjs");
11
11
  async function createForumTopic(client, params) {
12
12
  const { chatId, title, icon, sendAs, shouldDispatch } = params;
13
13
  const res = await client.call({
14
- _: "channels.createForumTopic",
15
- channel: await resolvePeer.resolveChannel(client, chatId),
14
+ _: "messages.createForumTopic",
15
+ peer: await resolvePeer.resolvePeer(client, chatId),
16
16
  title,
17
17
  iconColor: typeof icon === "number" ? icon : void 0,
18
18
  iconEmojiId: typeof icon !== "number" ? icon : void 0,
@@ -1,11 +1,11 @@
1
1
  import { randomLong } from "../../../utils/long-utils.js";
2
2
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
- import { resolvePeer, resolveChannel } from "../users/resolve-peer.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
4
  async function createForumTopic(client, params) {
5
5
  const { chatId, title, icon, sendAs, shouldDispatch } = params;
6
6
  const res = await client.call({
7
- _: "channels.createForumTopic",
8
- channel: await resolveChannel(client, chatId),
7
+ _: "messages.createForumTopic",
8
+ peer: await resolvePeer(client, chatId),
9
9
  title,
10
10
  iconColor: typeof icon === "number" ? icon : void 0,
11
11
  iconEmojiId: typeof icon !== "number" ? icon : void 0,
@@ -5,20 +5,23 @@ 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 typeAssertions = require("../../../utils/type-assertions.cjs");
9
8
  const utils = require("../../updates/utils.cjs");
9
+ const peerUtils = require("../../utils/peer-utils.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
11
  async function deleteForumTopicHistory(client, chat, topicId, params) {
12
12
  const { shouldDispatch } = params ?? {};
13
- const channel = await resolvePeer.resolveChannel(client, chat);
14
- typeAssertions.assertTypeIsNot("deleteForumTopicHistory", channel, "inputChannelEmpty");
13
+ const peer = await resolvePeer.resolvePeer(client, chat);
15
14
  const res = await client.call({
16
- _: "channels.deleteTopicHistory",
17
- channel,
15
+ _: "messages.deleteTopicHistory",
16
+ peer,
18
17
  topMsgId: typeof topicId === "number" ? topicId : topicId.id
19
18
  });
20
19
  if (!shouldDispatch) {
21
- client.handleClientUpdate(utils.createDummyUpdate(res.pts, res.ptsCount, channel.channelId));
20
+ client.handleClientUpdate(utils.createDummyUpdate(
21
+ res.pts,
22
+ res.ptsCount,
23
+ peerUtils.isInputPeerChannel(peer) ? peer.channelId : void 0
24
+ ));
22
25
  }
23
26
  }
24
27
  exports.deleteForumTopicHistory = deleteForumTopicHistory;
@@ -1,17 +1,20 @@
1
- import { assertTypeIsNot } from "../../../utils/type-assertions.js";
2
1
  import { createDummyUpdate } from "../../updates/utils.js";
3
- import { resolveChannel } from "../users/resolve-peer.js";
2
+ import { isInputPeerChannel } from "../../utils/peer-utils.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
4
  async function deleteForumTopicHistory(client, chat, topicId, params) {
5
5
  const { shouldDispatch } = params ?? {};
6
- const channel = await resolveChannel(client, chat);
7
- assertTypeIsNot("deleteForumTopicHistory", channel, "inputChannelEmpty");
6
+ const peer = await resolvePeer(client, chat);
8
7
  const res = await client.call({
9
- _: "channels.deleteTopicHistory",
10
- channel,
8
+ _: "messages.deleteTopicHistory",
9
+ peer,
11
10
  topMsgId: typeof topicId === "number" ? topicId : topicId.id
12
11
  });
13
12
  if (!shouldDispatch) {
14
- client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount, channel.channelId));
13
+ client.handleClientUpdate(createDummyUpdate(
14
+ res.pts,
15
+ res.ptsCount,
16
+ isInputPeerChannel(peer) ? peer.channelId : void 0
17
+ ));
15
18
  }
16
19
  }
17
20
  export {
@@ -9,13 +9,15 @@ const Long = require("long");
9
9
  const findInUpdate = require("../messages/find-in-update.cjs");
10
10
  const resolvePeer = require("../users/resolve-peer.cjs");
11
11
  async function editForumTopic(client, params) {
12
- const { chatId, topicId, title, icon, shouldDispatch } = params;
12
+ const { chatId, topicId, title, icon, shouldDispatch, closed, hidden } = params;
13
13
  const res = await client.call({
14
- _: "channels.editForumTopic",
15
- channel: await resolvePeer.resolveChannel(client, chatId),
14
+ _: "messages.editForumTopic",
15
+ peer: await resolvePeer.resolvePeer(client, chatId),
16
16
  topicId: typeof topicId === "number" ? topicId : topicId.id,
17
17
  title,
18
- iconEmojiId: icon ? icon ?? Long.ZERO : void 0
18
+ iconEmojiId: icon ? icon ?? Long.ZERO : void 0,
19
+ closed,
20
+ hidden
19
21
  });
20
22
  return findInUpdate._findMessageInUpdate(client, res, false, shouldDispatch);
21
23
  }
@@ -31,4 +31,8 @@ export declare function editForumTopic(client: ITelegramClient, params: {
31
31
  * to the client's update handler.
32
32
  */
33
33
  shouldDispatch?: true;
34
+ /** Whether to (un)close the topic */
35
+ closed?: boolean;
36
+ /** Whether to (un)hide the topic */
37
+ hidden?: boolean;
34
38
  }): Promise<Message>;
@@ -31,4 +31,8 @@ export declare function editForumTopic(client: ITelegramClient, params: {
31
31
  * to the client's update handler.
32
32
  */
33
33
  shouldDispatch?: true;
34
+ /** Whether to (un)close the topic */
35
+ closed?: boolean;
36
+ /** Whether to (un)hide the topic */
37
+ hidden?: boolean;
34
38
  }): Promise<Message>;
@@ -1,14 +1,16 @@
1
1
  import Long from "long";
2
2
  import { _findMessageInUpdate } from "../messages/find-in-update.js";
3
- import { resolveChannel } from "../users/resolve-peer.js";
3
+ import { resolvePeer } from "../users/resolve-peer.js";
4
4
  async function editForumTopic(client, params) {
5
- const { chatId, topicId, title, icon, shouldDispatch } = params;
5
+ const { chatId, topicId, title, icon, shouldDispatch, closed, hidden } = params;
6
6
  const res = await client.call({
7
- _: "channels.editForumTopic",
8
- channel: await resolveChannel(client, chatId),
7
+ _: "messages.editForumTopic",
8
+ peer: await resolvePeer(client, chatId),
9
9
  topicId: typeof topicId === "number" ? topicId : topicId.id,
10
10
  title,
11
- iconEmojiId: icon ? icon ?? Long.ZERO : void 0
11
+ iconEmojiId: icon ? icon ?? Long.ZERO : void 0,
12
+ closed,
13
+ hidden
12
14
  });
13
15
  return _findMessageInUpdate(client, res, false, shouldDispatch);
14
16
  }
@@ -10,8 +10,8 @@ const forumTopic = require("../../types/peers/forum-topic.cjs");
10
10
  async function getForumTopicsById(client, chatId, ids) {
11
11
  if (!Array.isArray(ids)) ids = [ids];
12
12
  const res = await client.call({
13
- _: "channels.getForumTopicsByID",
14
- channel: await resolvePeer.resolveChannel(client, chatId),
13
+ _: "messages.getForumTopicsByID",
14
+ peer: await resolvePeer.resolvePeer(client, chatId),
15
15
  topics: ids
16
16
  });
17
17
  return forumTopic.ForumTopic.parseTlForumTopics(res);
@@ -1,10 +1,10 @@
1
- import { resolveChannel } from "../users/resolve-peer.js";
1
+ import { resolvePeer } from "../users/resolve-peer.js";
2
2
  import { ForumTopic as ForumTopic$2 } from "../../types/peers/forum-topic.js";
3
3
  async function getForumTopicsById(client, chatId, ids) {
4
4
  if (!Array.isArray(ids)) ids = [ids];
5
5
  const res = await client.call({
6
- _: "channels.getForumTopicsByID",
7
- channel: await resolveChannel(client, chatId),
6
+ _: "messages.getForumTopicsByID",
7
+ peer: await resolvePeer(client, chatId),
8
8
  topics: ids
9
9
  });
10
10
  return ForumTopic$2.parseTlForumTopics(res);
@@ -21,8 +21,8 @@ async function getForumTopics(client, chatId, params) {
21
21
  limit = 100
22
22
  } = params;
23
23
  const res = await client.call({
24
- _: "channels.getForumTopics",
25
- channel: await resolvePeer.resolveChannel(client, chatId),
24
+ _: "messages.getForumTopics",
25
+ peer: await resolvePeer.resolvePeer(client, chatId),
26
26
  q: query,
27
27
  offsetDate,
28
28
  offsetId,
@@ -1,4 +1,4 @@
1
- import { resolveChannel } from "../users/resolve-peer.js";
1
+ import { resolvePeer } from "../users/resolve-peer.js";
2
2
  import { makeArrayPaginated } from "../../utils/misc-utils.js";
3
3
  import { ForumTopic as ForumTopic$2 } from "../../types/peers/forum-topic.js";
4
4
  const defaultOffset = {
@@ -14,8 +14,8 @@ async function getForumTopics(client, chatId, params) {
14
14
  limit = 100
15
15
  } = params;
16
16
  const res = await client.call({
17
- _: "channels.getForumTopics",
18
- channel: await resolveChannel(client, chatId),
17
+ _: "messages.getForumTopics",
18
+ peer: await resolvePeer(client, chatId),
19
19
  q: query,
20
20
  offsetDate,
21
21
  offsetId,
@@ -10,7 +10,7 @@ const getForumTopics = require("./get-forum-topics.cjs");
10
10
  async function* iterForumTopics(client, chatId, params) {
11
11
  if (!params) params = {};
12
12
  const { query, limit = Infinity, chunkSize = 100 } = params;
13
- const peer = await resolvePeer.resolveChannel(client, chatId);
13
+ const peer = await resolvePeer.resolvePeer(client, chatId);
14
14
  let { offset } = params;
15
15
  let current = 0;
16
16
  for (; ; ) {
@@ -1,9 +1,9 @@
1
- import { resolveChannel } from "../users/resolve-peer.js";
1
+ import { resolvePeer } from "../users/resolve-peer.js";
2
2
  import { getForumTopics } from "./get-forum-topics.js";
3
3
  async function* iterForumTopics(client, chatId, params) {
4
4
  if (!params) params = {};
5
5
  const { query, limit = Infinity, chunkSize = 100 } = params;
6
- const peer = await resolveChannel(client, chatId);
6
+ const peer = await resolvePeer(client, chatId);
7
7
  let { offset } = params;
8
8
  let current = 0;
9
9
  for (; ; ) {
@@ -9,8 +9,8 @@ const utils = require("@fuman/utils");
9
9
  const resolvePeer = require("../users/resolve-peer.cjs");
10
10
  const findInUpdate = require("./find-in-update.cjs");
11
11
  const getMessages = require("./get-messages.cjs");
12
- const entities = require("../../types/misc/entities.cjs");
13
12
  const inputMessageId = require("../../types/messages/input-message-id.cjs");
13
+ const entities = require("../../types/misc/entities.cjs");
14
14
  async function appendTodoList(client, params) {
15
15
  const { items, shouldDispatch } = params;
16
16
  const { chatId, message } = inputMessageId.normalizeInputMessageId(params);
@@ -2,8 +2,8 @@ import { assert } from "@fuman/utils";
2
2
  import { resolvePeer } from "../users/resolve-peer.js";
3
3
  import { _findMessageInUpdate } from "./find-in-update.js";
4
4
  import { getMessages } from "./get-messages.js";
5
- import { inputTextToTl } from "../../types/misc/entities.js";
6
5
  import { normalizeInputMessageId } from "../../types/messages/input-message-id.js";
6
+ import { inputTextToTl } from "../../types/misc/entities.js";
7
7
  async function appendTodoList(client, params) {
8
8
  const { items, shouldDispatch } = params;
9
9
  const { chatId, message } = normalizeInputMessageId(params);
@@ -8,7 +8,7 @@ import { Message } from '../../types/index.js';
8
8
  * Unlike {@link getMessages}, this method does not
9
9
  * check if the message belongs to some chat.
10
10
  *
11
- * Fot messages that were not found, `null` will be
11
+ * For messages that were not found, `null` will be
12
12
  * returned at that position.
13
13
  *
14
14
  * @param messageIds Messages IDs
@@ -8,7 +8,7 @@ import { Message } from '../../types/index.js';
8
8
  * Unlike {@link getMessages}, this method does not
9
9
  * check if the message belongs to some chat.
10
10
  *
11
- * Fot messages that were not found, `null` will be
11
+ * For messages that were not found, `null` will be
12
12
  * returned at that position.
13
13
  *
14
14
  * @param messageIds Messages IDs
@@ -5,7 +5,7 @@ import { Message } from '../../types/messages/index.js';
5
5
  /**
6
6
  * Get messages in chat by their IDs
7
7
  *
8
- * Fot messages that were not found, `null` will be
8
+ * For messages that were not found, `null` will be
9
9
  * returned at that position.
10
10
  *
11
11
  * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
@@ -5,7 +5,7 @@ import { Message } from '../../types/messages/index.js';
5
5
  /**
6
6
  * Get messages in chat by their IDs
7
7
  *
8
- * Fot messages that were not found, `null` will be
8
+ * For messages that were not found, `null` will be
9
9
  * returned at that position.
10
10
  *
11
11
  * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
@@ -4,7 +4,7 @@ import { InputPeerLike, Message } from '../../types/index.js';
4
4
  /**
5
5
  * Get scheduled messages in chat by their IDs
6
6
  *
7
- * Fot messages that were not found, `null` will be
7
+ * For messages that were not found, `null` will be
8
8
  * returned at that position.
9
9
  *
10
10
  * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
@@ -4,7 +4,7 @@ import { InputPeerLike, Message } from '../../types/index.js';
4
4
  /**
5
5
  * Get scheduled messages in chat by their IDs
6
6
  *
7
- * Fot messages that were not found, `null` will be
7
+ * For messages that were not found, `null` will be
8
8
  * returned at that position.
9
9
  *
10
10
  * @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
@@ -19,6 +19,7 @@ async function getSavedStarGifts(client, params) {
19
19
  excludeUnupgradable: params.excludeUnupgradable,
20
20
  excludeUpgradable: params.excludeUpgradable,
21
21
  excludeUnique: params.excludeUnique,
22
+ peerColorAvailable: params.peerColorAvailable,
22
23
  sortByValue: params.sortByValue,
23
24
  collectionId: params.collectionId,
24
25
  offset: params.offset ?? "",
@@ -21,6 +21,10 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
21
21
  excludeUnupgradable?: boolean;
22
22
  /** Whether to exclude gifts that can be upgraded */
23
23
  excludeUpgradable?: boolean;
24
+ /** Whether to exclude "hosted" gifts (i.e. those that are actually stored on the TON blockchain) */
25
+ excludeHosted?: boolean;
26
+ /** Whether to only return gifts with peer color available */
27
+ peerColorAvailable?: boolean;
24
28
  /** ID of the collection to get gifts from */
25
29
  collectionId?: number;
26
30
  /** Whether to sort by value */
@@ -21,6 +21,10 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
21
21
  excludeUnupgradable?: boolean;
22
22
  /** Whether to exclude gifts that can be upgraded */
23
23
  excludeUpgradable?: boolean;
24
+ /** Whether to exclude "hosted" gifts (i.e. those that are actually stored on the TON blockchain) */
25
+ excludeHosted?: boolean;
26
+ /** Whether to only return gifts with peer color available */
27
+ peerColorAvailable?: boolean;
24
28
  /** ID of the collection to get gifts from */
25
29
  collectionId?: number;
26
30
  /** Whether to sort by value */
@@ -12,6 +12,7 @@ async function getSavedStarGifts(client, params) {
12
12
  excludeUnupgradable: params.excludeUnupgradable,
13
13
  excludeUpgradable: params.excludeUpgradable,
14
14
  excludeUnique: params.excludeUnique,
15
+ peerColorAvailable: params.peerColorAvailable,
15
16
  sortByValue: params.sortByValue,
16
17
  collectionId: params.collectionId,
17
18
  offset: params.offset ?? "",
@@ -22,12 +22,6 @@ async function setEmojiStatus(client, params) {
22
22
  let emojiStatus;
23
23
  if (emoji === null) {
24
24
  emojiStatus = { _: "emojiStatusEmpty" };
25
- } else if (until) {
26
- emojiStatus = {
27
- _: "emojiStatusUntil",
28
- documentId: emoji,
29
- until: miscUtils.normalizeDate(until)
30
- };
31
25
  } else if (isCollectible) {
32
26
  emojiStatus = {
33
27
  _: "inputEmojiStatusCollectible",
@@ -37,7 +31,8 @@ async function setEmojiStatus(client, params) {
37
31
  } else {
38
32
  emojiStatus = {
39
33
  _: "emojiStatus",
40
- documentId: emoji
34
+ documentId: emoji,
35
+ until: miscUtils.normalizeDate(until)
41
36
  };
42
37
  }
43
38
  if (utils.isSelfPeer(client, peer)) {
@@ -15,12 +15,6 @@ async function setEmojiStatus(client, params) {
15
15
  let emojiStatus;
16
16
  if (emoji === null) {
17
17
  emojiStatus = { _: "emojiStatusEmpty" };
18
- } else if (until) {
19
- emojiStatus = {
20
- _: "emojiStatusUntil",
21
- documentId: emoji,
22
- until: normalizeDate(until)
23
- };
24
18
  } else if (isCollectible) {
25
19
  emojiStatus = {
26
20
  _: "inputEmojiStatusCollectible",
@@ -30,7 +24,8 @@ async function setEmojiStatus(client, params) {
30
24
  } else {
31
25
  emojiStatus = {
32
26
  _: "emojiStatus",
33
- documentId: emoji
27
+ documentId: emoji,
28
+ until: normalizeDate(until)
34
29
  };
35
30
  }
36
31
  if (isSelfPeer(client, peer)) {
@@ -64,11 +64,10 @@ class CurrentUserService extends base.BaseService {
64
64
  _cached;
65
65
  async store(info) {
66
66
  if (info && this._cached) {
67
- if (this._cached.userId === info.userId) {
68
- return;
69
- }
70
67
  this._cached.userId = info.userId;
71
68
  this._cached.isBot = info.isBot;
69
+ this._cached.isPremium = info.isPremium;
70
+ this._cached.usernames = info.usernames;
72
71
  } else {
73
72
  this._cached = info;
74
73
  }
@@ -87,7 +86,9 @@ class CurrentUserService extends base.BaseService {
87
86
  return obj;
88
87
  }
89
88
  async fetch() {
90
- if (this._cached) return this._cached;
89
+ if (this._cached) {
90
+ return this._cached;
91
+ }
91
92
  const data = await this._kv.get(KV_CURRENT_USER);
92
93
  if (!data) return null;
93
94
  const info = parse(data);