@mtcute/core 0.29.4 → 0.29.6
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.
- package/client.cjs +4 -0
- package/client.js +4 -0
- package/highlevel/base.cjs +0 -1
- package/highlevel/base.js +0 -1
- package/highlevel/client.d.cts +30 -0
- package/highlevel/client.d.ts +30 -0
- package/highlevel/methods/chats/get-creator-after-leave.cjs +4 -14
- package/highlevel/methods/chats/get-creator-after-leave.js +5 -15
- package/highlevel/methods/files/normalize-input-media.cjs +37 -15
- package/highlevel/methods/files/normalize-input-media.js +37 -15
- package/highlevel/methods/messages/close-poll.cjs +2 -1
- package/highlevel/methods/messages/close-poll.js +2 -1
- package/highlevel/methods/messages/create-streaming-draft.cjs +57 -0
- package/highlevel/methods/messages/create-streaming-draft.d.cts +36 -0
- package/highlevel/methods/messages/create-streaming-draft.d.ts +36 -0
- package/highlevel/methods/messages/create-streaming-draft.js +52 -0
- package/highlevel/methods/messages/send-common.cjs +2 -1
- package/highlevel/methods/messages/send-common.d.cts +4 -0
- package/highlevel/methods/messages/send-common.d.ts +4 -0
- package/highlevel/methods/messages/send-common.js +2 -1
- package/highlevel/methods/messages/send-media.cjs +1 -1
- package/highlevel/methods/messages/send-media.d.cts +3 -0
- package/highlevel/methods/messages/send-media.d.ts +3 -0
- package/highlevel/methods/messages/send-media.js +1 -1
- package/highlevel/methods/messages/send-text.cjs +1 -1
- package/highlevel/methods/messages/send-text.d.cts +3 -0
- package/highlevel/methods/messages/send-text.d.ts +3 -0
- package/highlevel/methods/messages/send-text.js +1 -1
- package/highlevel/methods/messages/send-vote.cjs +3 -1
- package/highlevel/methods/messages/send-vote.js +4 -2
- package/highlevel/methods.d.cts +2 -0
- package/highlevel/methods.d.ts +2 -0
- package/highlevel/storage/service/peers.cjs +1 -0
- package/highlevel/storage/service/peers.js +1 -0
- package/highlevel/types/media/input-media/types.d.cts +23 -12
- package/highlevel/types/media/input-media/types.d.ts +23 -12
- package/highlevel/types/media/photo.cjs +8 -0
- package/highlevel/types/media/photo.d.cts +2 -0
- package/highlevel/types/media/photo.d.ts +2 -0
- package/highlevel/types/media/photo.js +8 -0
- package/highlevel/types/media/poll.cjs +48 -5
- package/highlevel/types/media/poll.d.cts +21 -3
- package/highlevel/types/media/poll.d.ts +21 -3
- package/highlevel/types/media/poll.js +48 -5
- package/highlevel/types/messages/dialog.cjs +4 -0
- package/highlevel/types/messages/dialog.d.cts +2 -0
- package/highlevel/types/messages/dialog.d.ts +2 -0
- package/highlevel/types/messages/dialog.js +4 -0
- package/highlevel/types/messages/message-action.cjs +18 -0
- package/highlevel/types/messages/message-action.d.cts +19 -1
- package/highlevel/types/messages/message-action.d.ts +19 -1
- package/highlevel/types/messages/message-action.js +18 -0
- package/highlevel/types/messages/message-media.cjs +6 -1
- package/highlevel/types/messages/message-media.js +6 -1
- package/highlevel/types/messages/replied-message.cjs +4 -0
- package/highlevel/types/messages/replied-message.d.cts +2 -0
- package/highlevel/types/messages/replied-message.d.ts +2 -0
- package/highlevel/types/messages/replied-message.js +4 -0
- package/highlevel/types/messages/search-filters.cjs +2 -1
- package/highlevel/types/messages/search-filters.d.cts +4 -0
- package/highlevel/types/messages/search-filters.d.ts +4 -0
- package/highlevel/types/messages/search-filters.js +2 -1
- package/highlevel/types/peers/forum-topic.cjs +4 -0
- package/highlevel/types/peers/forum-topic.d.cts +2 -0
- package/highlevel/types/peers/forum-topic.d.ts +2 -0
- package/highlevel/types/peers/forum-topic.js +4 -0
- package/highlevel/types/peers/full-user.cjs +8 -0
- package/highlevel/types/peers/full-user.d.cts +4 -0
- package/highlevel/types/peers/full-user.d.ts +4 -0
- package/highlevel/types/peers/full-user.js +8 -0
- package/highlevel/types/peers/user.cjs +4 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +4 -0
- package/highlevel/types/updates/poll-update.cjs +8 -2
- package/highlevel/types/updates/poll-update.js +8 -2
- package/highlevel/updates/manager.cjs +7 -0
- package/highlevel/updates/manager.js +7 -0
- package/highlevel/worker/worker.cjs +6 -1
- package/highlevel/worker/worker.d.cts +2 -1
- package/highlevel/worker/worker.d.ts +2 -1
- package/highlevel/worker/worker.js +6 -1
- package/methods.cjs +2 -0
- package/methods.js +2 -0
- package/network/middlewares/flood-waiter.cjs +2 -1
- package/network/middlewares/flood-waiter.js +2 -1
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/package.json +1 -1
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +86 -39
- package/tl/binary/reader.js +86 -39
- package/tl/binary/writer.cjs +308 -32
- package/tl/binary/writer.js +308 -32
- package/tl/compat/reader.cjs +34 -0
- package/tl/compat/reader.js +34 -0
- package/tl/index.d.cts +295 -25
- package/tl/index.d.ts +295 -25
- package/tl/inner-tl.cjs +16 -8
- package/tl/inner-tl.js +16 -8
- package/utils/binary/compat.cjs +41 -0
- package/utils/binary/compat.js +41 -0
|
@@ -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 = {
|
|
@@ -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",
|
|
@@ -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.
|
|
@@ -33,7 +33,9 @@ async function sendVote(client, params) {
|
|
|
33
33
|
poll$1 = msg.media;
|
|
34
34
|
options = options.map((opt) => {
|
|
35
35
|
if (typeof opt === "number") {
|
|
36
|
-
|
|
36
|
+
const answer = poll$1.raw.answers[opt];
|
|
37
|
+
typeAssertions.assertTypeIsNot("Poll.answers", answer, "inputPollAnswer");
|
|
38
|
+
return answer.option;
|
|
37
39
|
}
|
|
38
40
|
return opt;
|
|
39
41
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MtArgumentError, MtTypeAssertionError } from "../../../types/errors.js";
|
|
2
2
|
import { getMarkedPeerId } from "../../../utils/peer-utils.js";
|
|
3
|
-
import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
3
|
+
import { assertTypeIsNot, assertTypeIs } from "../../../utils/type-assertions.js";
|
|
4
4
|
import { assertIsUpdatesGroup } from "../../updates/utils.js";
|
|
5
5
|
import { resolvePeer } from "../users/resolve-peer.js";
|
|
6
6
|
import { getMessages } from "./get-messages.js";
|
|
@@ -26,7 +26,9 @@ async function sendVote(client, params) {
|
|
|
26
26
|
poll = msg.media;
|
|
27
27
|
options = options.map((opt) => {
|
|
28
28
|
if (typeof opt === "number") {
|
|
29
|
-
|
|
29
|
+
const answer = poll.raw.answers[opt];
|
|
30
|
+
assertTypeIsNot("Poll.answers", answer, "inputPollAnswer");
|
|
31
|
+
return answer.option;
|
|
30
32
|
}
|
|
31
33
|
return opt;
|
|
32
34
|
});
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -160,6 +160,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
160
160
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
161
161
|
export { appendTodoList } from './methods/messages/append-todo-list.js';
|
|
162
162
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
163
|
+
export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
164
|
+
export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
163
165
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
164
166
|
export { deleteMessages } from './methods/messages/delete-messages.js';
|
|
165
167
|
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -160,6 +160,8 @@ export { iterInviteLinks } from './methods/invite-links/iter-invite-links.js';
|
|
|
160
160
|
export { revokeInviteLink } from './methods/invite-links/revoke-invite-link.js';
|
|
161
161
|
export { appendTodoList } from './methods/messages/append-todo-list.js';
|
|
162
162
|
export { closePoll } from './methods/messages/close-poll.js';
|
|
163
|
+
export { createStreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
164
|
+
export type { StreamingDraft } from './methods/messages/create-streaming-draft.js';
|
|
163
165
|
export { deleteMessagesById } from './methods/messages/delete-messages.js';
|
|
164
166
|
export { deleteMessages } from './methods/messages/delete-messages.js';
|
|
165
167
|
export type { DeleteMessagesParams } from './methods/messages/delete-messages.js';
|
|
@@ -182,6 +182,7 @@ class PeersService extends base.BaseService {
|
|
|
182
182
|
contactRequirePremium: peer.contactRequirePremium,
|
|
183
183
|
botBusiness: peer.botBusiness,
|
|
184
184
|
botHasMainApp: peer.botHasMainApp,
|
|
185
|
+
botCanManageBots: peer.botCanManageBots,
|
|
185
186
|
photo: peer.applyMinPhoto ? peer.photo : existing.photo,
|
|
186
187
|
status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
|
|
187
188
|
botInfoVersion: peer.botInfoVersion,
|
|
@@ -175,6 +175,7 @@ class PeersService extends BaseService {
|
|
|
175
175
|
contactRequirePremium: peer.contactRequirePremium,
|
|
176
176
|
botBusiness: peer.botBusiness,
|
|
177
177
|
botHasMainApp: peer.botHasMainApp,
|
|
178
|
+
botCanManageBots: peer.botCanManageBots,
|
|
178
179
|
photo: peer.applyMinPhoto ? peer.photo : existing.photo,
|
|
179
180
|
status: !existing.status || existing.status._ === "userStatusEmpty" ? peer.status : existing.status,
|
|
180
181
|
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
|
|
@@ -384,6 +386,13 @@ export interface InputMediaInvoice extends CaptionMixin {
|
|
|
384
386
|
*/
|
|
385
387
|
extendedMedia?: InputMediaLike;
|
|
386
388
|
}
|
|
389
|
+
/** A poll answer */
|
|
390
|
+
export interface InputPollAnswer {
|
|
391
|
+
/** Answer text */
|
|
392
|
+
text: InputText;
|
|
393
|
+
/** Media to be attached near the answer */
|
|
394
|
+
media?: InputMediaLike;
|
|
395
|
+
}
|
|
387
396
|
/**
|
|
388
397
|
* A simple poll to be sent
|
|
389
398
|
*
|
|
@@ -397,6 +406,8 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
397
406
|
* Question of the poll (1-255 chars for users, 1-300 chars for bots)
|
|
398
407
|
*/
|
|
399
408
|
question: InputText;
|
|
409
|
+
/** Media attached to the poll */
|
|
410
|
+
attachedMedia?: InputMediaLike;
|
|
400
411
|
/**
|
|
401
412
|
* Answers of the poll.
|
|
402
413
|
*
|
|
@@ -406,7 +417,7 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
406
417
|
* objects, with a single=byte incrementing
|
|
407
418
|
* `option` value.
|
|
408
419
|
*/
|
|
409
|
-
answers: (InputText | tl.TypePollAnswer)[];
|
|
420
|
+
answers: (InputText | tl.TypePollAnswer | InputPollAnswer)[];
|
|
410
421
|
/**
|
|
411
422
|
* Whether this is poll is closed
|
|
412
423
|
* (i.e. nobody can vote anymore)
|
|
@@ -437,6 +448,14 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
437
448
|
* When `number` is used, UNIX time in ms is expected
|
|
438
449
|
*/
|
|
439
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;
|
|
440
459
|
}
|
|
441
460
|
/**
|
|
442
461
|
* A quiz to be sent.
|
|
@@ -448,22 +467,14 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
|
|
|
448
467
|
type: 'quiz';
|
|
449
468
|
/**
|
|
450
469
|
* Correct answer ID(s) or index(es).
|
|
451
|
-
*
|
|
452
|
-
* > **Note**: even though quizzes can actually
|
|
453
|
-
* > only have exactly one correct answer,
|
|
454
|
-
* > the API itself has the possibility to pass
|
|
455
|
-
* > multiple or zero correct answers,
|
|
456
|
-
* > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`
|
|
457
|
-
* > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.
|
|
458
|
-
* >
|
|
459
|
-
* > But since the API has that option, we also provide it,
|
|
460
|
-
* > maybe to future-proof this :shrug:
|
|
461
470
|
*/
|
|
462
|
-
correct: MaybeArray<number
|
|
471
|
+
correct: MaybeArray<number>;
|
|
463
472
|
/**
|
|
464
473
|
* Explanation of the quiz solution
|
|
465
474
|
*/
|
|
466
475
|
solution?: InputText;
|
|
476
|
+
/** Media attached to the solution */
|
|
477
|
+
solutionMedia?: InputMediaLike;
|
|
467
478
|
}
|
|
468
479
|
/**
|
|
469
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
|
|
@@ -384,6 +386,13 @@ export interface InputMediaInvoice extends CaptionMixin {
|
|
|
384
386
|
*/
|
|
385
387
|
extendedMedia?: InputMediaLike;
|
|
386
388
|
}
|
|
389
|
+
/** A poll answer */
|
|
390
|
+
export interface InputPollAnswer {
|
|
391
|
+
/** Answer text */
|
|
392
|
+
text: InputText;
|
|
393
|
+
/** Media to be attached near the answer */
|
|
394
|
+
media?: InputMediaLike;
|
|
395
|
+
}
|
|
387
396
|
/**
|
|
388
397
|
* A simple poll to be sent
|
|
389
398
|
*
|
|
@@ -397,6 +406,8 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
397
406
|
* Question of the poll (1-255 chars for users, 1-300 chars for bots)
|
|
398
407
|
*/
|
|
399
408
|
question: InputText;
|
|
409
|
+
/** Media attached to the poll */
|
|
410
|
+
attachedMedia?: InputMediaLike;
|
|
400
411
|
/**
|
|
401
412
|
* Answers of the poll.
|
|
402
413
|
*
|
|
@@ -406,7 +417,7 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
406
417
|
* objects, with a single=byte incrementing
|
|
407
418
|
* `option` value.
|
|
408
419
|
*/
|
|
409
|
-
answers: (InputText | tl.TypePollAnswer)[];
|
|
420
|
+
answers: (InputText | tl.TypePollAnswer | InputPollAnswer)[];
|
|
410
421
|
/**
|
|
411
422
|
* Whether this is poll is closed
|
|
412
423
|
* (i.e. nobody can vote anymore)
|
|
@@ -437,6 +448,14 @@ export interface InputMediaPoll extends CaptionMixin {
|
|
|
437
448
|
* When `number` is used, UNIX time in ms is expected
|
|
438
449
|
*/
|
|
439
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;
|
|
440
459
|
}
|
|
441
460
|
/**
|
|
442
461
|
* A quiz to be sent.
|
|
@@ -448,22 +467,14 @@ export interface InputMediaQuiz extends Omit<InputMediaPoll, 'type'> {
|
|
|
448
467
|
type: 'quiz';
|
|
449
468
|
/**
|
|
450
469
|
* Correct answer ID(s) or index(es).
|
|
451
|
-
*
|
|
452
|
-
* > **Note**: even though quizzes can actually
|
|
453
|
-
* > only have exactly one correct answer,
|
|
454
|
-
* > the API itself has the possibility to pass
|
|
455
|
-
* > multiple or zero correct answers,
|
|
456
|
-
* > but that would result in `QUIZ_CORRECT_ANSWERS_TOO_MUCH`
|
|
457
|
-
* > and `QUIZ_CORRECT_ANSWERS_EMPTY` errors respectively.
|
|
458
|
-
* >
|
|
459
|
-
* > But since the API has that option, we also provide it,
|
|
460
|
-
* > maybe to future-proof this :shrug:
|
|
461
470
|
*/
|
|
462
|
-
correct: MaybeArray<number
|
|
471
|
+
correct: MaybeArray<number>;
|
|
463
472
|
/**
|
|
464
473
|
* Explanation of the quiz solution
|
|
465
474
|
*/
|
|
466
475
|
solution?: InputText;
|
|
476
|
+
/** Media attached to the solution */
|
|
477
|
+
solutionMedia?: InputMediaLike;
|
|
467
478
|
}
|
|
468
479
|
/**
|
|
469
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
|
*/
|
|
@@ -6,8 +6,10 @@ 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 Long = require("long");
|
|
9
|
+
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
9
10
|
const memoize = require("../../utils/memoize.cjs");
|
|
10
11
|
const messageEntity = require("../messages/message-entity.cjs");
|
|
12
|
+
const messageMedia = require("../messages/message-media.cjs");
|
|
11
13
|
const inspectable = require("../../utils/inspectable.cjs");
|
|
12
14
|
class PollAnswer {
|
|
13
15
|
constructor(raw, result) {
|
|
@@ -57,14 +59,19 @@ class PollAnswer {
|
|
|
57
59
|
get correct() {
|
|
58
60
|
return Boolean(this.result?.correct);
|
|
59
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
|
+
}
|
|
60
66
|
}
|
|
61
|
-
const PollAnswer$1 = /* @__PURE__ */ memoize.memoizeGetters(PollAnswer, ["textEntities"]);
|
|
67
|
+
const PollAnswer$1 = /* @__PURE__ */ memoize.memoizeGetters(PollAnswer, ["textEntities", "media"]);
|
|
62
68
|
const PollAnswer$2 = /* @__PURE__ */ inspectable.makeInspectable(PollAnswer$1);
|
|
63
69
|
class Poll {
|
|
64
|
-
constructor(raw, _peers, results) {
|
|
70
|
+
constructor(raw, _peers, results, attachedMedia) {
|
|
65
71
|
this.raw = raw;
|
|
66
72
|
this._peers = _peers;
|
|
67
73
|
this.results = results;
|
|
74
|
+
this.attachedMedia = attachedMedia;
|
|
68
75
|
}
|
|
69
76
|
type = "poll";
|
|
70
77
|
/**
|
|
@@ -91,6 +98,7 @@ class Poll {
|
|
|
91
98
|
get answers() {
|
|
92
99
|
const results = this.results?.results;
|
|
93
100
|
return this.raw.answers.map((ans, idx) => {
|
|
101
|
+
typeAssertions.assertTypeIs("Poll.answers", ans, "pollAnswer");
|
|
94
102
|
if (results) {
|
|
95
103
|
return new PollAnswer(ans, results[idx]);
|
|
96
104
|
}
|
|
@@ -129,6 +137,30 @@ class Poll {
|
|
|
129
137
|
get isMultiple() {
|
|
130
138
|
return this.raw.multipleChoice;
|
|
131
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
|
+
}
|
|
132
164
|
/**
|
|
133
165
|
* Solution for the quiz, only available
|
|
134
166
|
* in case you have already answered
|
|
@@ -150,6 +182,10 @@ class Poll {
|
|
|
150
182
|
}
|
|
151
183
|
return res;
|
|
152
184
|
}
|
|
185
|
+
/** Media attached to the solution, if any */
|
|
186
|
+
get solutionMedia() {
|
|
187
|
+
return this.results?.solutionMedia ? messageMedia._messageMediaFromTl(null, this.results.solutionMedia) : null;
|
|
188
|
+
}
|
|
153
189
|
/**
|
|
154
190
|
* Input media TL object generated from this object,
|
|
155
191
|
* to be used inside {@link InputMediaLike} and
|
|
@@ -168,6 +204,8 @@ class Poll {
|
|
|
168
204
|
get inputMedia() {
|
|
169
205
|
return {
|
|
170
206
|
_: "inputMediaPoll",
|
|
207
|
+
attachedMedia: this.attachedMedia?.inputMedia,
|
|
208
|
+
solutionMedia: this.solutionMedia?.inputMedia,
|
|
171
209
|
poll: {
|
|
172
210
|
_: "poll",
|
|
173
211
|
closed: false,
|
|
@@ -177,12 +215,17 @@ class Poll {
|
|
|
177
215
|
question: this.raw.question,
|
|
178
216
|
answers: this.raw.answers,
|
|
179
217
|
closePeriod: this.raw.closePeriod,
|
|
180
|
-
closeDate: this.raw.closeDate
|
|
218
|
+
closeDate: this.raw.closeDate,
|
|
219
|
+
openAnswers: this.raw.openAnswers,
|
|
220
|
+
revotingDisabled: this.raw.revotingDisabled,
|
|
221
|
+
shuffleAnswers: this.raw.shuffleAnswers,
|
|
222
|
+
hideResultsUntilClose: this.raw.hideResultsUntilClose,
|
|
223
|
+
hash: Long.ZERO
|
|
181
224
|
}
|
|
182
225
|
};
|
|
183
226
|
}
|
|
184
227
|
}
|
|
185
|
-
const Poll$1 = /* @__PURE__ */ memoize.memoizeGetters(Poll, ["answers", "solutionEntities", "questionEntities"]);
|
|
186
|
-
const Poll$2 = /* @__PURE__ */ inspectable.makeInspectable(Poll$1,
|
|
228
|
+
const Poll$1 = /* @__PURE__ */ memoize.memoizeGetters(Poll, ["answers", "solutionEntities", "questionEntities", "solutionMedia"]);
|
|
229
|
+
const Poll$2 = /* @__PURE__ */ inspectable.makeInspectable(Poll$1, ["attachedMedia"], ["inputMedia"]);
|
|
187
230
|
exports.Poll = Poll$2;
|
|
188
231
|
exports.PollAnswer = PollAnswer$2;
|
|
@@ -1,10 +1,11 @@
|
|
|
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 {
|
|
5
|
-
readonly raw: tl.
|
|
6
|
+
readonly raw: tl.RawPollAnswer;
|
|
6
7
|
readonly result?: tl.RawPollAnswerVoters | undefined;
|
|
7
|
-
constructor(raw: tl.
|
|
8
|
+
constructor(raw: tl.RawPollAnswer, result?: tl.RawPollAnswerVoters | undefined);
|
|
8
9
|
/**
|
|
9
10
|
* Answer text
|
|
10
11
|
*/
|
|
@@ -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,18 @@ 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;
|
|
84
100
|
/**
|
|
85
101
|
* Solution for the quiz, only available
|
|
86
102
|
* in case you have already answered
|
|
@@ -91,6 +107,8 @@ export declare class Poll {
|
|
|
91
107
|
* in case you have already answered
|
|
92
108
|
*/
|
|
93
109
|
get solutionEntities(): ReadonlyArray<MessageEntity> | null;
|
|
110
|
+
/** Media attached to the solution, if any */
|
|
111
|
+
get solutionMedia(): MessageMedia | null;
|
|
94
112
|
/**
|
|
95
113
|
* Input media TL object generated from this object,
|
|
96
114
|
* to be used inside {@link InputMediaLike} and
|
|
@@ -1,10 +1,11 @@
|
|
|
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 {
|
|
5
|
-
readonly raw: tl.
|
|
6
|
+
readonly raw: tl.RawPollAnswer;
|
|
6
7
|
readonly result?: tl.RawPollAnswerVoters | undefined;
|
|
7
|
-
constructor(raw: tl.
|
|
8
|
+
constructor(raw: tl.RawPollAnswer, result?: tl.RawPollAnswerVoters | undefined);
|
|
8
9
|
/**
|
|
9
10
|
* Answer text
|
|
10
11
|
*/
|
|
@@ -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,18 @@ 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;
|
|
84
100
|
/**
|
|
85
101
|
* Solution for the quiz, only available
|
|
86
102
|
* in case you have already answered
|
|
@@ -91,6 +107,8 @@ export declare class Poll {
|
|
|
91
107
|
* in case you have already answered
|
|
92
108
|
*/
|
|
93
109
|
get solutionEntities(): ReadonlyArray<MessageEntity> | null;
|
|
110
|
+
/** Media attached to the solution, if any */
|
|
111
|
+
get solutionMedia(): MessageMedia | null;
|
|
94
112
|
/**
|
|
95
113
|
* Input media TL object generated from this object,
|
|
96
114
|
* to be used inside {@link InputMediaLike} and
|