@mtcute/core 0.29.5 → 0.29.7

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 (96) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +49 -1
  4. package/highlevel/client.d.ts +49 -1
  5. package/highlevel/methods/bots/answer-bot-guest-chat-query.cjs +26 -0
  6. package/highlevel/methods/bots/answer-bot-guest-chat-query.d.cts +12 -0
  7. package/highlevel/methods/bots/answer-bot-guest-chat-query.d.ts +12 -0
  8. package/highlevel/methods/bots/answer-bot-guest-chat-query.js +21 -0
  9. package/highlevel/methods/files/normalize-input-media.cjs +21 -1
  10. package/highlevel/methods/files/normalize-input-media.js +21 -1
  11. package/highlevel/methods/messages/create-streaming-draft.cjs +57 -0
  12. package/highlevel/methods/messages/create-streaming-draft.d.cts +36 -0
  13. package/highlevel/methods/messages/create-streaming-draft.d.ts +36 -0
  14. package/highlevel/methods/messages/create-streaming-draft.js +52 -0
  15. package/highlevel/methods/messages/send-common.cjs +2 -1
  16. package/highlevel/methods/messages/send-common.d.cts +4 -0
  17. package/highlevel/methods/messages/send-common.d.ts +4 -0
  18. package/highlevel/methods/messages/send-common.js +2 -1
  19. package/highlevel/methods/messages/send-copy-group.cjs +5 -9
  20. package/highlevel/methods/messages/send-copy-group.js +5 -9
  21. package/highlevel/methods/messages/send-media.cjs +1 -1
  22. package/highlevel/methods/messages/send-media.d.cts +3 -0
  23. package/highlevel/methods/messages/send-media.d.ts +3 -0
  24. package/highlevel/methods/messages/send-media.js +1 -1
  25. package/highlevel/methods/messages/send-text.cjs +1 -1
  26. package/highlevel/methods/messages/send-text.d.cts +3 -0
  27. package/highlevel/methods/messages/send-text.d.ts +3 -0
  28. package/highlevel/methods/messages/send-text.js +1 -1
  29. package/highlevel/methods.d.cts +3 -0
  30. package/highlevel/methods.d.ts +3 -0
  31. package/highlevel/storage/service/peers.cjs +1 -0
  32. package/highlevel/storage/service/peers.js +1 -0
  33. package/highlevel/types/media/input-media/types.d.cts +14 -0
  34. package/highlevel/types/media/input-media/types.d.ts +14 -0
  35. package/highlevel/types/media/photo.cjs +8 -0
  36. package/highlevel/types/media/photo.d.cts +2 -0
  37. package/highlevel/types/media/photo.d.ts +2 -0
  38. package/highlevel/types/media/photo.js +8 -0
  39. package/highlevel/types/media/poll.cjs +58 -4
  40. package/highlevel/types/media/poll.d.cts +25 -1
  41. package/highlevel/types/media/poll.d.ts +25 -1
  42. package/highlevel/types/media/poll.js +58 -4
  43. package/highlevel/types/messages/message-media.cjs +6 -1
  44. package/highlevel/types/messages/message-media.js +6 -1
  45. package/highlevel/types/messages/message.cjs +10 -1
  46. package/highlevel/types/messages/message.d.cts +5 -0
  47. package/highlevel/types/messages/message.d.ts +5 -0
  48. package/highlevel/types/messages/message.js +10 -1
  49. package/highlevel/types/messages/replied-message.cjs +4 -0
  50. package/highlevel/types/messages/replied-message.d.cts +2 -0
  51. package/highlevel/types/messages/replied-message.d.ts +2 -0
  52. package/highlevel/types/messages/replied-message.js +4 -0
  53. package/highlevel/types/messages/search-filters.cjs +2 -1
  54. package/highlevel/types/messages/search-filters.d.cts +4 -0
  55. package/highlevel/types/messages/search-filters.d.ts +4 -0
  56. package/highlevel/types/messages/search-filters.js +2 -1
  57. package/highlevel/types/peers/chat-permissions.cjs +6 -0
  58. package/highlevel/types/peers/chat-permissions.d.cts +4 -0
  59. package/highlevel/types/peers/chat-permissions.d.ts +4 -0
  60. package/highlevel/types/peers/chat-permissions.js +6 -0
  61. package/highlevel/types/peers/user.cjs +4 -0
  62. package/highlevel/types/peers/user.d.cts +2 -0
  63. package/highlevel/types/peers/user.d.ts +2 -0
  64. package/highlevel/types/peers/user.js +4 -0
  65. package/highlevel/types/updates/bot-guest-chat-query.cjs +39 -0
  66. package/highlevel/types/updates/bot-guest-chat-query.d.cts +21 -0
  67. package/highlevel/types/updates/bot-guest-chat-query.d.ts +21 -0
  68. package/highlevel/types/updates/bot-guest-chat-query.js +34 -0
  69. package/highlevel/types/updates/index.d.cts +5 -1
  70. package/highlevel/types/updates/index.d.ts +5 -1
  71. package/highlevel/types/updates/parse-update.cjs +3 -0
  72. package/highlevel/types/updates/parse-update.js +3 -0
  73. package/highlevel/updates/manager.cjs +23 -3
  74. package/highlevel/updates/manager.d.cts +1 -0
  75. package/highlevel/updates/manager.d.ts +1 -0
  76. package/highlevel/updates/manager.js +23 -3
  77. package/index.cjs +2 -0
  78. package/index.js +2 -0
  79. package/methods.cjs +4 -0
  80. package/methods.js +4 -0
  81. package/network/network-manager.cjs +1 -1
  82. package/network/network-manager.js +1 -1
  83. package/package.json +1 -1
  84. package/tl/api-schema.json +1 -1
  85. package/tl/binary/reader.cjs +85 -40
  86. package/tl/binary/reader.js +85 -40
  87. package/tl/binary/writer.cjs +349 -143
  88. package/tl/binary/writer.js +349 -143
  89. package/tl/compat/reader.cjs +8 -0
  90. package/tl/compat/reader.js +8 -0
  91. package/tl/index.d.cts +2071 -179
  92. package/tl/index.d.ts +2071 -179
  93. package/tl/inner-tl.cjs +17 -5
  94. package/tl/inner-tl.js +17 -5
  95. package/utils/binary/compat.cjs +5 -0
  96. package/utils/binary/compat.js +5 -0
@@ -0,0 +1,36 @@
1
+ import { default as Long } from 'long';
2
+ import { ITelegramClient } from '../../client.types.js';
3
+ import { InputPeerLike, InputText, TextWithEntities } from '../../types/index.js';
4
+ export interface StreamingDraft {
5
+ /** Random ID of the draft */
6
+ readonly randomId: Long;
7
+ /** Depending on the `mode`, this method will either append or replace the draft */
8
+ send(text: InputText): Promise<void>;
9
+ /** Final text of the draft, for convenience */
10
+ get finalText(): TextWithEntities;
11
+ }
12
+ /**
13
+ * Create a streaming text message draft
14
+ *
15
+ * @param chatId Chat ID
16
+ * @param params
17
+ */
18
+ export declare function createStreamingDraft(client: ITelegramClient, chatId: InputPeerLike, params?: {
19
+ /**
20
+ * Unique identifier of the business connection on behalf of which the action will be sent
21
+ */
22
+ businessConnectionId?: string;
23
+ /**
24
+ * For comment threads, ID of the thread (i.e. top message)
25
+ */
26
+ threadId?: number;
27
+ /**
28
+ * Mode of the draft's `send` method
29
+ *
30
+ * - `append` - appends the text to the previous draft
31
+ * - `replace` - replaces the previous draft with the new one
32
+ *
33
+ * @default `replace`
34
+ */
35
+ mode?: 'append' | 'replace';
36
+ }): Promise<StreamingDraft>;
@@ -0,0 +1,52 @@
1
+ import { randomLong } from "../../../utils/long-utils.js";
2
+ import { assertTrue } from "../../../utils/type-assertions.js";
3
+ import { joinTextWithEntities } from "../../utils/entities.js";
4
+ import { _normalizeInputText } from "../misc/normalize-text.js";
5
+ import { resolvePeer } from "../users/resolve-peer.js";
6
+ async function createStreamingDraft(client, chatId, params) {
7
+ const {
8
+ mode = "replace",
9
+ threadId,
10
+ businessConnectionId
11
+ } = params ?? {};
12
+ const randomId = randomLong();
13
+ const peer = await resolvePeer(client, chatId);
14
+ let previousText;
15
+ const sendDraft = async (text) => {
16
+ if (typeof text === "string") {
17
+ text = { text };
18
+ }
19
+ if (mode === "append" && previousText) {
20
+ text = joinTextWithEntities([previousText, text]);
21
+ }
22
+ previousText = text;
23
+ const [_text, entities = []] = await _normalizeInputText(client, text);
24
+ const r = await client.call({
25
+ _: "messages.setTyping",
26
+ peer,
27
+ action: {
28
+ _: "sendMessageTextDraftAction",
29
+ text: {
30
+ _: "textWithEntities",
31
+ text: _text,
32
+ entities
33
+ },
34
+ randomId
35
+ },
36
+ topMsgId: threadId
37
+ }, {
38
+ businessConnectionId
39
+ });
40
+ assertTrue("messages.setTyping", r);
41
+ };
42
+ return {
43
+ randomId,
44
+ send: sendDraft,
45
+ get finalText() {
46
+ return previousText ?? { text: "", entities: [] };
47
+ }
48
+ };
49
+ }
50
+ export {
51
+ createStreamingDraft
52
+ };
@@ -57,7 +57,8 @@ async function _processCommonSendParameters(client, chatId, params) {
57
57
  quoteEntities: params.quote?.entities,
58
58
  quoteOffset: params.quoteOffset,
59
59
  monoforumPeerId: params.toMonoforumPeer ? await resolvePeer.resolvePeer(client, params.toMonoforumPeer) : void 0,
60
- todoItemId: params.replyToTodoItem
60
+ todoItemId: params.replyToTodoItem,
61
+ pollOption: params.replyToPollOption
61
62
  };
62
63
  } else if (params.toMonoforumPeer) {
63
64
  tlReplyTo = {
@@ -16,6 +16,10 @@ export interface CommonSendParams {
16
16
  * If this is a reply to a specific todo item, ID of that item
17
17
  */
18
18
  replyToTodoItem?: number;
19
+ /**
20
+ * If this is a reply to a specific poll option, ID of that option
21
+ */
22
+ replyToPollOption?: Uint8Array;
19
23
  /**
20
24
  * When the chat is a monoforum you are an admin of, you **must** pass an
21
25
  * ID of a peer you are sending the message to.
@@ -16,6 +16,10 @@ export interface CommonSendParams {
16
16
  * If this is a reply to a specific todo item, ID of that item
17
17
  */
18
18
  replyToTodoItem?: number;
19
+ /**
20
+ * If this is a reply to a specific poll option, ID of that option
21
+ */
22
+ replyToPollOption?: Uint8Array;
19
23
  /**
20
24
  * When the chat is a monoforum you are an admin of, you **must** pass an
21
25
  * ID of a peer you are sending the message to.
@@ -50,7 +50,8 @@ async function _processCommonSendParameters(client, chatId, params) {
50
50
  quoteEntities: params.quote?.entities,
51
51
  quoteOffset: params.quoteOffset,
52
52
  monoforumPeerId: params.toMonoforumPeer ? await resolvePeer(client, params.toMonoforumPeer) : void 0,
53
- todoItemId: params.replyToTodoItem
53
+ todoItemId: params.replyToTodoItem,
54
+ pollOption: params.replyToPollOption
54
55
  };
55
56
  } else if (params.toMonoforumPeer) {
56
57
  tlReplyTo = {
@@ -28,15 +28,11 @@ async function sendCopyGroup(client, params) {
28
28
  return sendMediaGroup.sendMediaGroup(
29
29
  client,
30
30
  toChatId,
31
- msgs.map((msg) => {
32
- const raw = msg.raw;
33
- return {
34
- type: "auto",
35
- file: msg.media.inputMedia,
36
- caption: raw.message,
37
- entities: raw.entities
38
- };
39
- }),
31
+ msgs.map((msg) => ({
32
+ type: "auto",
33
+ file: msg.media.inputMedia,
34
+ caption: msg.textWithEntities
35
+ })),
40
36
  rest
41
37
  );
42
38
  }
@@ -21,15 +21,11 @@ async function sendCopyGroup(client, params) {
21
21
  return sendMediaGroup(
22
22
  client,
23
23
  toChatId,
24
- msgs.map((msg) => {
25
- const raw = msg.raw;
26
- return {
27
- type: "auto",
28
- file: msg.media.inputMedia,
29
- caption: raw.message,
30
- entities: raw.entities
31
- };
32
- }),
24
+ msgs.map((msg) => ({
25
+ type: "auto",
26
+ file: msg.media.inputMedia,
27
+ caption: msg.textWithEntities
28
+ })),
33
29
  rest
34
30
  );
35
31
  }
@@ -37,7 +37,7 @@ async function sendMedia(client, chatId, media, params) {
37
37
  params.caption || media.caption
38
38
  );
39
39
  const replyMarkup = factories._convertToTl(params.replyMarkup);
40
- const randomId = longUtils.randomLong();
40
+ const randomId = params.randomId ?? longUtils.randomLong();
41
41
  const res = await client.call(
42
42
  {
43
43
  _: "messages.sendMedia",
@@ -1,3 +1,4 @@
1
+ import { default as Long } from 'long';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
3
4
  import { InputMediaLike } from '../../types/media/input-media/types.js';
@@ -17,6 +18,8 @@ import { CommonSendParams } from './send-common.js';
17
18
  * @link InputMedia
18
19
  */
19
20
  export declare function sendMedia(client: ITelegramClient, chatId: InputPeerLike, media: InputMediaLike | string, params?: CommonSendParams & {
21
+ /** Override the default random ID, for streaming drafts */
22
+ randomId?: Long;
20
23
  /**
21
24
  * For bots: inline or reply markup or an instruction
22
25
  * to hide a reply keyboard or to force a reply.
@@ -1,3 +1,4 @@
1
+ import { default as Long } from 'long';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
3
4
  import { InputMediaLike } from '../../types/media/input-media/types.js';
@@ -17,6 +18,8 @@ import { CommonSendParams } from './send-common.js';
17
18
  * @link InputMedia
18
19
  */
19
20
  export declare function sendMedia(client: ITelegramClient, chatId: InputPeerLike, media: InputMediaLike | string, params?: CommonSendParams & {
21
+ /** Override the default random ID, for streaming drafts */
22
+ randomId?: Long;
20
23
  /**
21
24
  * For bots: inline or reply markup or an instruction
22
25
  * to hide a reply keyboard or to force a reply.
@@ -30,7 +30,7 @@ async function sendMedia(client, chatId, media, params) {
30
30
  params.caption || media.caption
31
31
  );
32
32
  const replyMarkup = _convertToTl(params.replyMarkup);
33
- const randomId = randomLong();
33
+ const randomId = params.randomId ?? randomLong();
34
34
  const res = await client.call(
35
35
  {
36
36
  _: "messages.sendMedia",
@@ -27,7 +27,7 @@ async function sendText(client, chatId, text, params) {
27
27
  chatId,
28
28
  params
29
29
  );
30
- const randomId = longUtils.randomLong();
30
+ const randomId = params.randomId ?? longUtils.randomLong();
31
31
  const res = await client.call(
32
32
  {
33
33
  _: "messages.sendMessage",
@@ -1,3 +1,4 @@
1
+ import { default as Long } from 'long';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
3
4
  import { InputText } from '../../types/misc/entities.js';
@@ -12,6 +13,8 @@ import { Message } from '../../types/messages/message.js';
12
13
  * @param params Additional sending parameters
13
14
  */
14
15
  export declare function sendText(client: ITelegramClient, chatId: InputPeerLike, text: InputText, params?: CommonSendParams & {
16
+ /** Override the default random ID, for streaming drafts */
17
+ randomId?: Long;
15
18
  /**
16
19
  * For bots: inline or reply markup or an instruction
17
20
  * to hide a reply keyboard or to force a reply.
@@ -1,3 +1,4 @@
1
+ import { default as Long } from 'long';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { ReplyMarkup } from '../../types/bots/keyboards/index.js';
3
4
  import { InputText } from '../../types/misc/entities.js';
@@ -12,6 +13,8 @@ import { Message } from '../../types/messages/message.js';
12
13
  * @param params Additional sending parameters
13
14
  */
14
15
  export declare function sendText(client: ITelegramClient, chatId: InputPeerLike, text: InputText, params?: CommonSendParams & {
16
+ /** Override the default random ID, for streaming drafts */
17
+ randomId?: Long;
15
18
  /**
16
19
  * For bots: inline or reply markup or an instruction
17
20
  * to hide a reply keyboard or to force a reply.
@@ -20,7 +20,7 @@ async function sendText(client, chatId, text, params) {
20
20
  chatId,
21
21
  params
22
22
  );
23
- const randomId = randomLong();
23
+ const randomId = params.randomId ?? randomLong();
24
24
  const res = await client.call(
25
25
  {
26
26
  _: "messages.sendMessage",
@@ -12,6 +12,7 @@ export { signIn } from './methods/auth/sign-in.js';
12
12
  export { startTest } from './methods/auth/start-test.js';
13
13
  export { start } from './methods/auth/start.js';
14
14
  export { isSelfPeer } from './methods/auth/utils.js';
15
+ export { answerBotGuestChatQuery } from './methods/bots/answer-bot-guest-chat-query.js';
15
16
  export { answerCallbackQuery } from './methods/bots/answer-callback-query.js';
16
17
  export { answerInlineQuery } from './methods/bots/answer-inline-query.js';
17
18
  export { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query.js';
@@ -160,6 +161,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
160
161
  export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
161
162
  export { appendTodoList } from './methods/messages/append-todo-list.js';
162
163
  export { closePoll } from './methods/messages/close-poll.js';
164
+ export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
165
+ export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
163
166
  export { deleteMessagesById } from './methods/messages/delete-messages.js';
164
167
  export { deleteMessages } from './methods/messages/delete-messages.js';
165
168
  export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
@@ -12,6 +12,7 @@ export { signIn } from './methods/auth/sign-in.js';
12
12
  export { startTest } from './methods/auth/start-test.js';
13
13
  export { start } from './methods/auth/start.js';
14
14
  export { isSelfPeer } from './methods/auth/utils.js';
15
+ export { answerBotGuestChatQuery } from './methods/bots/answer-bot-guest-chat-query.js';
15
16
  export { answerCallbackQuery } from './methods/bots/answer-callback-query.js';
16
17
  export { answerInlineQuery } from './methods/bots/answer-inline-query.js';
17
18
  export { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query.js';
@@ -160,6 +161,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
160
161
  export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
161
162
  export { appendTodoList } from './methods/messages/append-todo-list.js';
162
163
  export { closePoll } from './methods/messages/close-poll.js';
164
+ export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
165
+ export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
163
166
  export { deleteMessagesById } from './methods/messages/delete-messages.js';
164
167
  export { deleteMessages } from './methods/messages/delete-messages.js';
165
168
  export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
@@ -183,6 +183,7 @@ class PeersService extends base.BaseService {
183
183
  botBusiness: peer.botBusiness,
184
184
  botHasMainApp: peer.botHasMainApp,
185
185
  botCanManageBots: peer.botCanManageBots,
186
+ botGuestchat: peer.botGuestchat,
186
187
  photo: peer.applyMinPhoto ? peer.photo : existing.photo,
187
188
  status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
188
189
  botInfoVersion: peer.botInfoVersion,
@@ -176,6 +176,7 @@ class PeersService extends BaseService {
176
176
  botBusiness: peer.botBusiness,
177
177
  botHasMainApp: peer.botHasMainApp,
178
178
  botCanManageBots: peer.botCanManageBots,
179
+ botGuestchat: peer.botGuestchat,
179
180
  photo: peer.applyMinPhoto ? peer.photo : existing.photo,
180
181
  status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
181
182
  botInfoVersion: peer.botInfoVersion,
@@ -131,6 +131,8 @@ export interface InputMediaPhoto extends FileMixin, CaptionMixin {
131
131
  * Whether this photo should be hidden with a spoiler
132
132
  */
133
133
  spoiler?: boolean;
134
+ /** If this is a live photo, the video representing it */
135
+ livePhotoVideo?: InputMediaLike;
134
136
  }
135
137
  /**
136
138
  * A sticker to be sent
@@ -404,6 +406,8 @@ export interface InputMediaPoll extends CaptionMixin {
404
406
  * Question of the poll (1-255 chars for users, 1-300 chars for bots)
405
407
  */
406
408
  question: InputText;
409
+ /** Media attached to the poll */
410
+ attachedMedia?: InputMediaLike;
407
411
  /**
408
412
  * Answers of the poll.
409
413
  *
@@ -444,6 +448,14 @@ export interface InputMediaPoll extends CaptionMixin {
444
448
  * When `number` is used, UNIX time in ms is expected
445
449
  */
446
450
  closeDate?: number | Date;
451
+ /** Whether participants can suggest new options to the poll */
452
+ openAnswers?: boolean;
453
+ /** Whether retracting the votes should be disabled in the poll */
454
+ disableRevoting?: boolean;
455
+ /** Whether answers to the poll should be shuffled before showing to the user */
456
+ shuffleAnswers?: boolean;
457
+ /** Whether the results of the poll should be hidden until the end of the poll */
458
+ hideResultsUntilClose?: boolean;
447
459
  }
448
460
  /**
449
461
  * A quiz to be sent.
@@ -461,6 +473,8 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
461
473
  * Explanation of the quiz solution
462
474
  */
463
475
  solution?: InputText;
476
+ /** Media attached to the solution */
477
+ solutionMedia?: InputMediaLike;
464
478
  }
465
479
  /**
466
480
  * A story to be sent
@@ -131,6 +131,8 @@ export interface InputMediaPhoto extends FileMixin, CaptionMixin {
131
131
  * Whether this photo should be hidden with a spoiler
132
132
  */
133
133
  spoiler?: boolean;
134
+ /** If this is a live photo, the video representing it */
135
+ livePhotoVideo?: InputMediaLike;
134
136
  }
135
137
  /**
136
138
  * A sticker to be sent
@@ -404,6 +406,8 @@ export interface InputMediaPoll extends CaptionMixin {
404
406
  * Question of the poll (1-255 chars for users, 1-300 chars for bots)
405
407
  */
406
408
  question: InputText;
409
+ /** Media attached to the poll */
410
+ attachedMedia?: InputMediaLike;
407
411
  /**
408
412
  * Answers of the poll.
409
413
  *
@@ -444,6 +448,14 @@ export interface InputMediaPoll extends CaptionMixin {
444
448
  * When `number` is used, UNIX time in ms is expected
445
449
  */
446
450
  closeDate?: number | Date;
451
+ /** Whether participants can suggest new options to the poll */
452
+ openAnswers?: boolean;
453
+ /** Whether retracting the votes should be disabled in the poll */
454
+ disableRevoting?: boolean;
455
+ /** Whether answers to the poll should be shuffled before showing to the user */
456
+ shuffleAnswers?: boolean;
457
+ /** Whether the results of the poll should be hidden until the end of the poll */
458
+ hideResultsUntilClose?: boolean;
447
459
  }
448
460
  /**
449
461
  * A quiz to be sent.
@@ -461,6 +473,8 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
461
473
  * Explanation of the quiz solution
462
474
  */
463
475
  solution?: InputText;
476
+ /** Media attached to the solution */
477
+ solutionMedia?: InputMediaLike;
464
478
  }
465
479
  /**
466
480
  * A story to be sent
@@ -7,6 +7,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const errors = require("../../../types/errors.cjs");
9
9
  const memoize = require("../../utils/memoize.cjs");
10
+ const documentUtils = require("./document-utils.cjs");
10
11
  const thumbnail = require("./thumbnail.cjs");
11
12
  const inspectable = require("../../utils/inspectable.cjs");
12
13
  const fileLocation = require("../files/file-location.cjs");
@@ -136,6 +137,13 @@ class Photo extends fileLocation.FileLocation {
136
137
  }
137
138
  return this.getThumbnail(this._bestSize.type).uniqueFileId;
138
139
  }
140
+ get livePhotoVideo() {
141
+ if (!this.media?.video) return null;
142
+ if (this.media.video._ !== "document") return null;
143
+ const parsed = documentUtils.parseDocument(this.media.video);
144
+ if (parsed.type !== "video") return null;
145
+ return parsed;
146
+ }
139
147
  /**
140
148
  * Input photo generated from this object.
141
149
  */
@@ -1,4 +1,5 @@
1
1
  import { tl } from '../../../tl/index.js';
2
+ import { Video } from './video.js';
2
3
  import { FileLocation } from '../files/index.js';
3
4
  import { Thumbnail } from './thumbnail.js';
4
5
  /**
@@ -59,6 +60,7 @@ export declare class Photo extends FileLocation {
59
60
  * representing this photo's best thumbnail.
60
61
  */
61
62
  get uniqueFileId(): string;
63
+ get livePhotoVideo(): Video | null;
62
64
  /**
63
65
  * Input photo generated from this object.
64
66
  */
@@ -1,4 +1,5 @@
1
1
  import { tl } from '../../../tl/index.js';
2
+ import { Video } from './video.js';
2
3
  import { FileLocation } from '../files/index.js';
3
4
  import { Thumbnail } from './thumbnail.js';
4
5
  /**
@@ -59,6 +60,7 @@ export declare class Photo extends FileLocation {
59
60
  * representing this photo's best thumbnail.
60
61
  */
61
62
  get uniqueFileId(): string;
63
+ get livePhotoVideo(): Video | null;
62
64
  /**
63
65
  * Input photo generated from this object.
64
66
  */
@@ -1,5 +1,6 @@
1
1
  import { MtArgumentError } from "../../../types/errors.js";
2
2
  import { memoizeGetters } from "../../utils/memoize.js";
3
+ import { parseDocument } from "./document-utils.js";
3
4
  import { Thumbnail as Thumbnail$2 } from "./thumbnail.js";
4
5
  import { makeInspectable } from "../../utils/inspectable.js";
5
6
  import { FileLocation as FileLocation$1 } from "../files/file-location.js";
@@ -129,6 +130,13 @@ class Photo extends FileLocation$1 {
129
130
  }
130
131
  return this.getThumbnail(this._bestSize.type).uniqueFileId;
131
132
  }
133
+ get livePhotoVideo() {
134
+ if (!this.media?.video) return null;
135
+ if (this.media.video._ !== "document") return null;
136
+ const parsed = parseDocument(this.media.video);
137
+ if (parsed.type !== "video") return null;
138
+ return parsed;
139
+ }
132
140
  /**
133
141
  * Input photo generated from this object.
134
142
  */
@@ -9,6 +9,7 @@ const Long = require("long");
9
9
  const typeAssertions = require("../../../utils/type-assertions.cjs");
10
10
  const memoize = require("../../utils/memoize.cjs");
11
11
  const messageEntity = require("../messages/message-entity.cjs");
12
+ const messageMedia = require("../messages/message-media.cjs");
12
13
  const inspectable = require("../../utils/inspectable.cjs");
13
14
  class PollAnswer {
14
15
  constructor(raw, result) {
@@ -58,14 +59,19 @@ class PollAnswer {
58
59
  get correct() {
59
60
  return Boolean(this.result?.correct);
60
61
  }
62
+ /** Media attached to this answer, if any */
63
+ get media() {
64
+ return this.raw.media ? messageMedia._messageMediaFromTl(null, this.raw.media) : null;
65
+ }
61
66
  }
62
- const PollAnswer$1 = /* @__PURE__ */ memoize.memoizeGetters(PollAnswer, ["textEntities"]);
67
+ const PollAnswer$1 = /* @__PURE__ */ memoize.memoizeGetters(PollAnswer, ["textEntities", "media"]);
63
68
  const PollAnswer$2 = /* @__PURE__ */ inspectable.makeInspectable(PollAnswer$1);
64
69
  class Poll {
65
- constructor(raw, _peers, results) {
70
+ constructor(raw, _peers, results, attachedMedia) {
66
71
  this.raw = raw;
67
72
  this._peers = _peers;
68
73
  this.results = results;
74
+ this.attachedMedia = attachedMedia;
69
75
  }
70
76
  type = "poll";
71
77
  /**
@@ -131,6 +137,42 @@ class Poll {
131
137
  get isMultiple() {
132
138
  return this.raw.multipleChoice;
133
139
  }
140
+ /** Whether the current user is the creator of this poll */
141
+ get isCreator() {
142
+ return this.raw.creator;
143
+ }
144
+ /** Whether new options can be suggested to this poll */
145
+ get canAddAnswers() {
146
+ return !this.raw.closed && !this.raw.openAnswers;
147
+ }
148
+ /** Whether retracting the vote is disabled in this poll */
149
+ get isRevotingDisabled() {
150
+ return this.raw.revotingDisabled;
151
+ }
152
+ /** Whether answers to this poll should be shuffled before showing to the user */
153
+ get shuffleAnswers() {
154
+ return this.raw.shuffleAnswers;
155
+ }
156
+ /** Whether the results of this poll are hidden until the end of the poll */
157
+ get hideResultsUntilClose() {
158
+ return this.raw.hideResultsUntilClose;
159
+ }
160
+ /** Whether the poll has unread votes */
161
+ get hasUnreaVotes() {
162
+ return this.results?.hasUnreadVotes ?? false;
163
+ }
164
+ /** Whether voting in this poll is restricted to channel subscribers */
165
+ get isSubscribersOnly() {
166
+ return this.raw.subscribersOnly;
167
+ }
168
+ /** ISO2 country codes the poll is restricted to */
169
+ get countries() {
170
+ return this.raw.countriesIso2 ?? null;
171
+ }
172
+ /** Whether the current user can view extended statistics for this poll */
173
+ get canViewStats() {
174
+ return this.results?.canViewStats ?? false;
175
+ }
134
176
  /**
135
177
  * Solution for the quiz, only available
136
178
  * in case you have already answered
@@ -152,6 +194,10 @@ class Poll {
152
194
  }
153
195
  return res;
154
196
  }
197
+ /** Media attached to the solution, if any */
198
+ get solutionMedia() {
199
+ return this.results?.solutionMedia ? messageMedia._messageMediaFromTl(null, this.results.solutionMedia) : null;
200
+ }
155
201
  /**
156
202
  * Input media TL object generated from this object,
157
203
  * to be used inside {@link InputMediaLike} and
@@ -170,6 +216,8 @@ class Poll {
170
216
  get inputMedia() {
171
217
  return {
172
218
  _: "inputMediaPoll",
219
+ attachedMedia: this.attachedMedia?.inputMedia,
220
+ solutionMedia: this.solutionMedia?.inputMedia,
173
221
  poll: {
174
222
  _: "poll",
175
223
  closed: false,
@@ -180,12 +228,18 @@ class Poll {
180
228
  answers: this.raw.answers,
181
229
  closePeriod: this.raw.closePeriod,
182
230
  closeDate: this.raw.closeDate,
231
+ openAnswers: this.raw.openAnswers,
232
+ revotingDisabled: this.raw.revotingDisabled,
233
+ shuffleAnswers: this.raw.shuffleAnswers,
234
+ hideResultsUntilClose: this.raw.hideResultsUntilClose,
235
+ subscribersOnly: this.raw.subscribersOnly,
236
+ countriesIso2: this.raw.countriesIso2,
183
237
  hash: Long.ZERO
184
238
  }
185
239
  };
186
240
  }
187
241
  }
188
- const Poll$1 = /* @__PURE__ */ memoize.memoizeGetters(Poll, ["answers", "solutionEntities", "questionEntities"]);
189
- const Poll$2 = /* @__PURE__ */ inspectable.makeInspectable(Poll$1, void 0, ["inputMedia"]);
242
+ const Poll$1 = /* @__PURE__ */ memoize.memoizeGetters(Poll, ["answers", "solutionEntities", "questionEntities", "solutionMedia"]);
243
+ const Poll$2 = /* @__PURE__ */ inspectable.makeInspectable(Poll$1, ["attachedMedia"], ["inputMedia"]);
190
244
  exports.Poll = Poll$2;
191
245
  exports.PollAnswer = PollAnswer$2;
@@ -1,4 +1,5 @@
1
1
  import { tl } from '../../../tl/index.js';
2
+ import { MessageMedia } from '../messages/message-media.js';
2
3
  import { PeersIndex } from '../peers/peers-index.js';
3
4
  import { MessageEntity } from '../messages/message-entity.js';
4
5
  export declare class PollAnswer {
@@ -36,13 +37,16 @@ export declare class PollAnswer {
36
37
  * @default
37
38
  */
38
39
  get correct(): boolean;
40
+ /** Media attached to this answer, if any */
41
+ get media(): MessageMedia | null;
39
42
  }
40
43
  export declare class Poll {
41
44
  readonly raw: tl.TypePoll;
42
45
  readonly _peers: PeersIndex;
43
46
  readonly results?: tl.RawPollResults | undefined;
47
+ readonly attachedMedia?: MessageMedia | undefined;
44
48
  readonly type: "poll";
45
- constructor(raw: tl.TypePoll, _peers: PeersIndex, results?: tl.RawPollResults | undefined);
49
+ constructor(raw: tl.TypePoll, _peers: PeersIndex, results?: tl.RawPollResults | undefined, attachedMedia?: MessageMedia | undefined);
46
50
  /**
47
51
  * Unique identifier of the poll
48
52
  */
@@ -81,6 +85,24 @@ export declare class Poll {
81
85
  * Whether this poll accepts multiple answers
82
86
  */
83
87
  get isMultiple(): boolean;
88
+ /** Whether the current user is the creator of this poll */
89
+ get isCreator(): boolean;
90
+ /** Whether new options can be suggested to this poll */
91
+ get canAddAnswers(): boolean;
92
+ /** Whether retracting the vote is disabled in this poll */
93
+ get isRevotingDisabled(): boolean;
94
+ /** Whether answers to this poll should be shuffled before showing to the user */
95
+ get shuffleAnswers(): boolean;
96
+ /** Whether the results of this poll are hidden until the end of the poll */
97
+ get hideResultsUntilClose(): boolean;
98
+ /** Whether the poll has unread votes */
99
+ get hasUnreaVotes(): boolean;
100
+ /** Whether voting in this poll is restricted to channel subscribers */
101
+ get isSubscribersOnly(): boolean;
102
+ /** ISO2 country codes the poll is restricted to */
103
+ get countries(): ReadonlyArray<string> | null;
104
+ /** Whether the current user can view extended statistics for this poll */
105
+ get canViewStats(): boolean;
84
106
  /**
85
107
  * Solution for the quiz, only available
86
108
  * in case you have already answered
@@ -91,6 +113,8 @@ export declare class Poll {
91
113
  * in case you have already answered
92
114
  */
93
115
  get solutionEntities(): ReadonlyArray<MessageEntity> | null;
116
+ /** Media attached to the solution, if any */
117
+ get solutionMedia(): MessageMedia | null;
94
118
  /**
95
119
  * Input media TL object generated from this object,
96
120
  * to be used inside {@link InputMediaLike} and