@mtkruto/node 0.1.157 → 0.1.160
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/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +2 -2
- package/esm/client/1_composer.d.ts +2 -2
- package/esm/client/1_composer.js +4 -4
- package/esm/client/1_file_manager.js +53 -56
- package/esm/client/2_message_manager.js +8 -11
- package/esm/client/4_client.d.ts +2 -2
- package/esm/client/4_client.js +4 -4
- package/esm/tl/2_types.d.ts +596 -1
- package/esm/tl/2_types.js +1824 -319
- package/esm/tl/3_functions.d.ts +374 -2
- package/esm/tl/3_functions.js +943 -31
- package/esm/types/0__file_id.d.ts +79 -54
- package/esm/types/0__file_id.js +259 -277
- package/esm/types/0_chat_photo.js +15 -21
- package/esm/types/0_giveaway_parameters.d.ts +5 -0
- package/esm/types/0_login_url.d.ts +4 -0
- package/esm/types/0_message_reference.d.ts +2 -0
- package/esm/types/0_price_tag.d.ts +2 -0
- package/esm/types/0_thumbnail.js +16 -14
- package/esm/types/1_giveaway.d.ts +2 -0
- package/esm/types/1_inline_query_result_button.d.ts +3 -0
- package/esm/types/1_photo.js +20 -14
- package/esm/types/1_poll.d.ts +13 -0
- package/esm/types/1_reaction_count.d.ts +2 -0
- package/esm/types/1_reply_quote.d.ts +3 -0
- package/esm/types/1_user.d.ts +13 -13
- package/esm/types/2_chosen_inline_result.d.ts +5 -0
- package/esm/types/2_game.d.ts +6 -0
- package/esm/types/2_game.js +11 -7
- package/esm/types/2_inactive_chat.d.ts +3 -0
- package/esm/types/2_inline_query.d.ts +6 -0
- package/esm/types/2_message_interactions.d.ts +5 -0
- package/esm/types/2_message_reaction_count.d.ts +4 -0
- package/esm/types/2_message_reactions.d.ts +7 -0
- package/esm/types/2_story_content.js +4 -7
- package/esm/types/4_inline_query_result.js +5 -5
- package/esm/types/4_message.js +21 -17
- package/esm/types/5_callback_query.d.ts +7 -0
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.js +26 -24
- package/package.json +1 -1
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +2 -2
- package/script/client/1_composer.d.ts +2 -2
- package/script/client/1_composer.js +4 -4
- package/script/client/1_file_manager.js +52 -55
- package/script/client/2_message_manager.js +6 -9
- package/script/client/4_client.d.ts +2 -2
- package/script/client/4_client.js +4 -4
- package/script/tl/2_types.d.ts +596 -1
- package/script/tl/2_types.js +1904 -345
- package/script/tl/3_functions.d.ts +374 -2
- package/script/tl/3_functions.js +977 -41
- package/script/types/0__file_id.d.ts +79 -54
- package/script/types/0__file_id.js +263 -280
- package/script/types/0_chat_photo.js +14 -20
- package/script/types/0_giveaway_parameters.d.ts +5 -0
- package/script/types/0_login_url.d.ts +4 -0
- package/script/types/0_message_reference.d.ts +2 -0
- package/script/types/0_price_tag.d.ts +2 -0
- package/script/types/0_thumbnail.js +15 -13
- package/script/types/1_giveaway.d.ts +2 -0
- package/script/types/1_inline_query_result_button.d.ts +3 -0
- package/script/types/1_photo.js +19 -13
- package/script/types/1_poll.d.ts +13 -0
- package/script/types/1_reaction_count.d.ts +2 -0
- package/script/types/1_reply_quote.d.ts +3 -0
- package/script/types/1_user.d.ts +13 -13
- package/script/types/2_chosen_inline_result.d.ts +5 -0
- package/script/types/2_game.d.ts +6 -0
- package/script/types/2_game.js +10 -6
- package/script/types/2_inactive_chat.d.ts +3 -0
- package/script/types/2_inline_query.d.ts +6 -0
- package/script/types/2_message_interactions.d.ts +5 -0
- package/script/types/2_message_reaction_count.d.ts +4 -0
- package/script/types/2_message_reactions.d.ts +7 -0
- package/script/types/2_story_content.js +3 -6
- package/script/types/4_inline_query_result.js +4 -4
- package/script/types/4_message.js +20 -16
- package/script/types/5_callback_query.d.ts +7 -0
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.js +26 -24
package/esm/types/0_thumbnail.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
|
-
import {
|
|
2
|
+
import { FileType, PhotoSourceType, serializeFileId, toUniqueFileId } from "./0__file_id.js";
|
|
3
3
|
export function constructThumbnail(size, file) {
|
|
4
4
|
const fileType = file instanceof types.Photo ? FileType.Photo : FileType.Document;
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
const fileId_ = file instanceof types.Photo
|
|
6
|
+
? {
|
|
7
|
+
type: FileType.Photo,
|
|
8
|
+
dcId: file.dc_id,
|
|
9
|
+
fileReference: file.file_reference,
|
|
10
|
+
location: { type: "photo", id: file.id, accessHash: file.access_hash, source: { type: PhotoSourceType.Thumbnail, fileType, thumbnailType: size.type.charCodeAt(0) } },
|
|
11
|
+
}
|
|
12
|
+
: {
|
|
13
|
+
type: FileType.Photo,
|
|
14
|
+
dcId: file.dc_id,
|
|
15
|
+
fileReference: file.file_reference,
|
|
16
|
+
location: { type: "common", id: file.id, accessHash: file.access_hash },
|
|
17
|
+
};
|
|
16
18
|
return {
|
|
17
|
-
fileId,
|
|
18
|
-
fileUniqueId,
|
|
19
|
+
fileId: serializeFileId(fileId_),
|
|
20
|
+
fileUniqueId: toUniqueFileId(fileId_),
|
|
19
21
|
width: size.w,
|
|
20
22
|
height: size.h,
|
|
21
23
|
fileSize: size.size,
|
|
@@ -3,7 +3,9 @@ import { GiveawayParameters } from "./0_giveaway_parameters.js";
|
|
|
3
3
|
/** A giveaway. */
|
|
4
4
|
export interface Giveaway {
|
|
5
5
|
parameters: GiveawayParameters;
|
|
6
|
+
/** The quantity of the Telegram Premium subscriptions that will be given away.. */
|
|
6
7
|
winnerCount: number;
|
|
8
|
+
/** The duration of each Telegram Premium subscription that is to be given away in months. */
|
|
7
9
|
monthCount: number;
|
|
8
10
|
}
|
|
9
11
|
export declare function constructGiveaway(g: types.MessageMediaGiveaway): Giveaway;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MiniAppInfo } from "./0_mini_app_info.js";
|
|
2
2
|
/** A button to be shown along with the results of an inline query. */
|
|
3
3
|
export interface InlineQueryResultButton {
|
|
4
|
+
/** Label text on the button. */
|
|
4
5
|
text: string;
|
|
6
|
+
/** Description of the Mini App that will be launched when the user presses the button. */
|
|
5
7
|
miniApp?: MiniAppInfo;
|
|
8
|
+
/** Deep linking parameter for the /start message. */
|
|
6
9
|
startParameter?: string;
|
|
7
10
|
}
|
package/esm/types/1_photo.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
|
-
import {
|
|
2
|
+
import { PhotoSourceType } from "./0__file_id.js";
|
|
3
|
+
import { FileType, serializeFileId, toUniqueFileId } from "./0__file_id.js";
|
|
3
4
|
import { constructThumbnail } from "./0_thumbnail.js";
|
|
4
5
|
export function constructPhoto(photo) {
|
|
5
6
|
const sizes = photo.sizes
|
|
@@ -14,20 +15,25 @@ export function constructPhoto(photo) {
|
|
|
14
15
|
.filter((v) => v instanceof types.PhotoSize)
|
|
15
16
|
.sort((a, b) => a.size - b.size);
|
|
16
17
|
const largest = sizes.slice(-1)[0];
|
|
17
|
-
const { dc_id: dcId, id
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const { dc_id: dcId, id, access_hash: accessHash, file_reference: fileReference } = photo;
|
|
19
|
+
const fileId_ = {
|
|
20
|
+
type: FileType.Photo,
|
|
21
|
+
dcId,
|
|
22
|
+
fileReference,
|
|
23
|
+
location: {
|
|
24
|
+
type: "photo",
|
|
25
|
+
id,
|
|
22
26
|
accessHash,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
source: {
|
|
28
|
+
type: PhotoSourceType.Thumbnail,
|
|
29
|
+
fileType: FileType.Photo,
|
|
30
|
+
thumbnailType: largest.type.charCodeAt(0),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
fileId: serializeFileId(fileId_),
|
|
36
|
+
fileUniqueId: toUniqueFileId(fileId_),
|
|
31
37
|
width: largest.w,
|
|
32
38
|
height: largest.h,
|
|
33
39
|
fileSize: largest.size,
|
package/esm/types/1_poll.d.ts
CHANGED
|
@@ -3,18 +3,31 @@ import { MessageEntity } from "./0_message_entity.js";
|
|
|
3
3
|
import { PollOption } from "./0_poll_option.js";
|
|
4
4
|
/** A poll. */
|
|
5
5
|
export interface Poll {
|
|
6
|
+
/** The identifier of the poll. */
|
|
6
7
|
id: string;
|
|
8
|
+
/** The poll's question. */
|
|
7
9
|
question: string;
|
|
10
|
+
/** The poll's options. */
|
|
8
11
|
options: PollOption[];
|
|
12
|
+
/** The number of users who have participated in the poll. */
|
|
9
13
|
totalVoterCount: number;
|
|
14
|
+
/** Whether the poll is closed. */
|
|
10
15
|
isClosed: boolean;
|
|
16
|
+
/** Whether the poll is anonymous. */
|
|
11
17
|
isAnonymous: boolean;
|
|
18
|
+
/** The type of the poll. */
|
|
12
19
|
type: "regular" | "quiz";
|
|
20
|
+
/** Whether the poll allows multiple answers. */
|
|
13
21
|
allowMultipleAnswers?: boolean;
|
|
22
|
+
/** Index of the correct option. */
|
|
14
23
|
correctOptionIndex?: number;
|
|
24
|
+
/** A text that is shown to the user when the poll is answered. */
|
|
15
25
|
explanation?: string;
|
|
26
|
+
/** The explanation's entities. */
|
|
16
27
|
explanationEntities?: MessageEntity[];
|
|
28
|
+
/** Duration of the poll in seconds. */
|
|
17
29
|
openPeriod?: number;
|
|
30
|
+
/** The time in which the poll will be closed. */
|
|
18
31
|
closeDate?: Date;
|
|
19
32
|
}
|
|
20
33
|
export declare function constructPoll(media_: types.MessageMediaPoll): Poll;
|
|
@@ -2,7 +2,9 @@ import { types } from "../2_tl.js";
|
|
|
2
2
|
import { Reaction } from "./0_reaction.js";
|
|
3
3
|
/** The count of a specific reaction. */
|
|
4
4
|
export interface ReactionCount {
|
|
5
|
+
/** The type of the reaction. */
|
|
5
6
|
reaction: Reaction;
|
|
7
|
+
/** Number of times the reaction was added. */
|
|
6
8
|
count: number;
|
|
7
9
|
}
|
|
8
10
|
export declare function constructReactionCount(reaction_: types.ReactionCount): ReactionCount;
|
|
@@ -2,8 +2,11 @@ import { enums } from "../2_tl.js";
|
|
|
2
2
|
import { MessageEntity } from "./0_message_entity.js";
|
|
3
3
|
/** A reference to a specific part of a message that is being replied to. */
|
|
4
4
|
export interface ReplyQuote {
|
|
5
|
+
/** The byte offset of the quoted text. */
|
|
5
6
|
offset: number;
|
|
7
|
+
/** The quoted text. */
|
|
6
8
|
text: string;
|
|
9
|
+
/** The entities of the quoted text. */
|
|
7
10
|
entities: MessageEntity[];
|
|
8
11
|
}
|
|
9
12
|
export declare function constructReplyQuote(quoteText: string | undefined, quoteOffset: number | undefined, quoteEntities: enums.MessageEntity[] | undefined): ReplyQuote;
|
package/esm/types/1_user.d.ts
CHANGED
|
@@ -6,31 +6,31 @@ export interface User {
|
|
|
6
6
|
id: number;
|
|
7
7
|
/** Identifier of color that can be displayed instead of the user's photo. */
|
|
8
8
|
color: number;
|
|
9
|
-
/**
|
|
9
|
+
/** Whether the user is a bot. */
|
|
10
10
|
isBot: boolean;
|
|
11
|
-
/**
|
|
11
|
+
/** The first name of the user. */
|
|
12
12
|
firstName: string;
|
|
13
|
-
/**
|
|
13
|
+
/** The last name of the user. */
|
|
14
14
|
lastName?: string;
|
|
15
|
-
/**
|
|
15
|
+
/** The user’s main username. */
|
|
16
16
|
username?: string;
|
|
17
|
-
/**
|
|
17
|
+
/** The user's additional usernames. */
|
|
18
18
|
also?: string[];
|
|
19
|
-
/** The user's photo. */
|
|
19
|
+
/** The user's profile photo. */
|
|
20
20
|
photo?: ChatPhotoUser;
|
|
21
|
-
/** [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag)
|
|
21
|
+
/** The user's [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag). */
|
|
22
22
|
languageCode?: string;
|
|
23
|
-
/**
|
|
23
|
+
/** Whether the user has been identified as scam. */
|
|
24
24
|
isScam: boolean;
|
|
25
|
-
/**
|
|
25
|
+
/** Whether the user has been identified as an impersonator. */
|
|
26
26
|
isFake: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/** Whether the user is subscribed to Telegram Premium. */
|
|
28
28
|
isPremium: boolean;
|
|
29
|
-
/**
|
|
29
|
+
/** Whether the user has been verified. */
|
|
30
30
|
isVerified: boolean;
|
|
31
|
-
/**
|
|
31
|
+
/** Whether the user is official support. */
|
|
32
32
|
isSupport: boolean;
|
|
33
|
-
/**
|
|
33
|
+
/** Whether the user is a bot that has been added to the attachment menu by the current user. */
|
|
34
34
|
addedToAttachmentMenu: boolean;
|
|
35
35
|
}
|
|
36
36
|
export declare function constructUser(user_: types.User): User;
|
|
@@ -4,10 +4,15 @@ import { EntityGetter } from "./1__getters.js";
|
|
|
4
4
|
import { User } from "./1_user.js";
|
|
5
5
|
/** A chosen inline result. */
|
|
6
6
|
export interface ChosenInlineResult {
|
|
7
|
+
/** The identifier of the inline result that was chosen. */
|
|
7
8
|
resultId: string;
|
|
9
|
+
/** The user who chose the result. */
|
|
8
10
|
from: User;
|
|
11
|
+
/** The location of the user who chose the result. */
|
|
9
12
|
location?: Location;
|
|
13
|
+
/** Identifier of the sent inline message. */
|
|
10
14
|
inlineMessageId?: string;
|
|
15
|
+
/** The query that was used to obtain the result. */
|
|
11
16
|
query: string;
|
|
12
17
|
}
|
|
13
18
|
export declare function constructChosenInlineResult(ubis: types.UpdateBotInlineSend, getEntity: EntityGetter): Promise<ChosenInlineResult>;
|
package/esm/types/2_game.d.ts
CHANGED
|
@@ -4,11 +4,17 @@ import { Animation } from "./1_animation.js";
|
|
|
4
4
|
import { Photo } from "./1_photo.js";
|
|
5
5
|
/** A game. */
|
|
6
6
|
export interface Game {
|
|
7
|
+
/** The title of the game. */
|
|
7
8
|
title: string;
|
|
9
|
+
/** The description of the game. */
|
|
8
10
|
description: string;
|
|
11
|
+
/** A photo that is displayed when the game is shared. */
|
|
9
12
|
photo: Photo;
|
|
13
|
+
/** A text that is displayed when the game is shared. */
|
|
10
14
|
text?: string;
|
|
15
|
+
/** The text's entities. */
|
|
11
16
|
textEntities?: MessageEntity[];
|
|
17
|
+
/** An animation that is displayed when the game is shared. */
|
|
12
18
|
animation?: Animation;
|
|
13
19
|
}
|
|
14
20
|
export declare function constructGame(media_: types.MessageMediaGame): Game;
|
package/esm/types/2_game.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { cleanObject } from "../1_utilities.js";
|
|
2
2
|
import { as, types } from "../2_tl.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FileType, serializeFileId, toUniqueFileId } from "./0__file_id.js";
|
|
4
4
|
import { constructAnimation } from "./1_animation.js";
|
|
5
5
|
import { constructPhoto } from "./1_photo.js";
|
|
6
6
|
export function constructGame(media_) {
|
|
7
7
|
const game_ = media_.game;
|
|
8
8
|
const document_ = game_.document ? game_.document[as](types.Document) : undefined;
|
|
9
|
+
const fileId_ = document_
|
|
10
|
+
? {
|
|
11
|
+
type: FileType.Animation,
|
|
12
|
+
dcId: document_.dc_id,
|
|
13
|
+
fileReference: document_.file_reference,
|
|
14
|
+
location: { type: "common", id: document_.id, accessHash: document_.access_hash },
|
|
15
|
+
}
|
|
16
|
+
: undefined;
|
|
9
17
|
return cleanObject({
|
|
10
18
|
title: game_.title,
|
|
11
19
|
description: media_.game.description,
|
|
12
20
|
photo: constructPhoto(game_.photo[as](types.Photo)),
|
|
13
|
-
animation: document_
|
|
14
|
-
? constructAnimation(document_, document_.attributes.find((v) => v instanceof types.DocumentAttributeVideo), document_.attributes.find((v) => v instanceof types.DocumentAttributeFilename),
|
|
15
|
-
mediaId: document_.id,
|
|
16
|
-
accessHash: document_.access_hash,
|
|
17
|
-
fileReference: document_.file_reference,
|
|
18
|
-
}).encode(), new FileUniqueID(FileUniqueType.Document, { mediaId: document_.id }).encode())
|
|
21
|
+
animation: fileId_ && document_
|
|
22
|
+
? constructAnimation(document_, document_.attributes.find((v) => v instanceof types.DocumentAttributeVideo), document_.attributes.find((v) => v instanceof types.DocumentAttributeFilename), serializeFileId(fileId_), toUniqueFileId(fileId_))
|
|
19
23
|
: undefined,
|
|
20
24
|
});
|
|
21
25
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { enums } from "../2_tl.js";
|
|
2
2
|
import { ChatP } from "./1_chat_p.js";
|
|
3
|
+
/** An inactive chat. */
|
|
3
4
|
export interface InactiveChat {
|
|
5
|
+
/** The point of time in which the chat was last active. */
|
|
4
6
|
lastActivity: Date;
|
|
7
|
+
/** The chat that has been marked as inactive. */
|
|
5
8
|
chat: ChatP;
|
|
6
9
|
}
|
|
7
10
|
export declare function constructInactiveChat(chat_: enums.Chat, lastActivity: number): InactiveChat;
|
|
@@ -4,11 +4,17 @@ import { EntityGetter } from "./1__getters.js";
|
|
|
4
4
|
import { User } from "./1_user.js";
|
|
5
5
|
/** An incoming inline query. */
|
|
6
6
|
export interface InlineQuery {
|
|
7
|
+
/** The identifier of the inline query. */
|
|
7
8
|
id: string;
|
|
9
|
+
/** The user who made the inline query. */
|
|
8
10
|
from: User;
|
|
11
|
+
/** The query that was made. */
|
|
9
12
|
query: string;
|
|
13
|
+
/** The offset parameter that was passed to the last [answerInlineQuery](/methods/answerInlineQuery) call. */
|
|
10
14
|
offset: string;
|
|
15
|
+
/** The type of the chat from which the inline query was made. */
|
|
11
16
|
chatType?: "sender" | "private" | "group" | "supergroup" | "channel";
|
|
17
|
+
/** The location of the user who made the inline query. */
|
|
12
18
|
location?: Location;
|
|
13
19
|
}
|
|
14
20
|
export declare function constructInlineQuery(query_: types.UpdateBotInlineQuery, getEntity: EntityGetter): Promise<InlineQuery>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { MessageReaction } from "./1_message_reaction.js";
|
|
2
2
|
/** The interactions made with a message. */
|
|
3
3
|
export interface MessageInteractions {
|
|
4
|
+
/** The identifier of the message's chat. */
|
|
4
5
|
chatId: number;
|
|
6
|
+
/** The message's identifier. */
|
|
5
7
|
messageId: number;
|
|
8
|
+
/** The reactions made to the message. */
|
|
6
9
|
reactions: MessageReaction[];
|
|
10
|
+
/** The number of times the message was viewed. */
|
|
7
11
|
views: number;
|
|
12
|
+
/** The number of times the message was forwarded. */
|
|
8
13
|
forwards: number;
|
|
9
14
|
}
|
|
@@ -4,9 +4,13 @@ import { ChatP } from "./1_chat_p.js";
|
|
|
4
4
|
import { ReactionCount } from "./1_reaction_count.js";
|
|
5
5
|
/** Information on the reactions made to a channel post. */
|
|
6
6
|
export interface MessageReactionCount {
|
|
7
|
+
/** The chat containing the message. */
|
|
7
8
|
chat: ChatP;
|
|
9
|
+
/** The message's identifier. */
|
|
8
10
|
messageId: number;
|
|
11
|
+
/** This reaction state's point of time. */
|
|
9
12
|
date: Date;
|
|
13
|
+
/** The reactions made to the post. */
|
|
10
14
|
reactions: ReactionCount[];
|
|
11
15
|
}
|
|
12
16
|
export declare function constructMessageReactionCount(update: types.UpdateBotMessageReactions, getEntity: EntityGetter): Promise<MessageReactionCount | null>;
|
|
@@ -5,12 +5,19 @@ import { ChatP } from "./1_chat_p.js";
|
|
|
5
5
|
import { User } from "./1_user.js";
|
|
6
6
|
/** The reactions of a user to a messages in a group. */
|
|
7
7
|
export interface MessageReactions {
|
|
8
|
+
/** The chat containing the message the user reacted to. */
|
|
8
9
|
chat: ChatP;
|
|
10
|
+
/** The message's identifier. */
|
|
9
11
|
messageId: number;
|
|
12
|
+
/** The user who changed their reactions to the message. Unset if done on behalf of a chat. */
|
|
10
13
|
user?: User;
|
|
14
|
+
/** The chat that changed its reactions to the message. Unset if done on behalf of a user. */
|
|
11
15
|
actorChat?: ChatP;
|
|
16
|
+
/** The point of time in which the change was made. */
|
|
12
17
|
date: Date;
|
|
18
|
+
/** The previous reactions. */
|
|
13
19
|
oldReactions: Reaction[];
|
|
20
|
+
/** The current reactions. */
|
|
14
21
|
newReactions: Reaction[];
|
|
15
22
|
}
|
|
16
23
|
export declare function constructMessageReactions(update: types.UpdateBotMessageReaction, getEntity: EntityGetter): Promise<MessageReactions | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
2
|
import { as, types } from "../2_tl.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FileType, serializeFileId, toUniqueFileId } from "./0__file_id.js";
|
|
4
4
|
import { constructPhoto } from "./1_photo.js";
|
|
5
5
|
import { constructVideo } from "./1_video.js";
|
|
6
6
|
export function constructStoryContent(media) {
|
|
@@ -20,12 +20,9 @@ export function constructStoryContent(media) {
|
|
|
20
20
|
if (!video) {
|
|
21
21
|
UNREACHABLE();
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
accessHash: document.access_hash,
|
|
27
|
-
fileReference: document.file_reference,
|
|
28
|
-
}).encode();
|
|
23
|
+
const fileId_ = { type: FileType.Video, dcId: document.dc_id, fileReference: document.file_reference, location: { type: "common", id: document.id, accessHash: document.access_hash } };
|
|
24
|
+
const fileUniqueId = toUniqueFileId(fileId_);
|
|
25
|
+
const fileId = serializeFileId(fileId_);
|
|
29
26
|
const video_ = constructVideo(document, video, undefined, fileId, fileUniqueId);
|
|
30
27
|
return { video: video_ };
|
|
31
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
|
-
import {
|
|
3
|
+
import { deserializeFileId } from "./0__file_id.js";
|
|
4
4
|
import { replyMarkupToTlObject } from "./3_reply_markup.js";
|
|
5
5
|
// deno-lint-ignore no-explicit-any
|
|
6
6
|
export async function inlineQueryResultToTlObject(result_, parseText, usernameResolver) {
|
|
@@ -175,16 +175,16 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
else if (fileId_ != null) {
|
|
178
|
-
const fileId =
|
|
178
|
+
const fileId = deserializeFileId(fileId_);
|
|
179
179
|
return new types.InputBotInlineResultDocument({
|
|
180
180
|
id,
|
|
181
181
|
type: type == "document" ? "file" : type,
|
|
182
182
|
title,
|
|
183
183
|
description,
|
|
184
184
|
document: new types.InputDocument({
|
|
185
|
-
id: fileId.
|
|
186
|
-
access_hash: fileId.
|
|
187
|
-
file_reference: fileId.
|
|
185
|
+
id: "id" in fileId.location ? fileId.location.id : UNREACHABLE(),
|
|
186
|
+
access_hash: fileId.location.accessHash,
|
|
187
|
+
file_reference: fileId.fileReference ?? new Uint8Array(),
|
|
188
188
|
}),
|
|
189
189
|
send_message: sendMessage,
|
|
190
190
|
});
|
package/esm/types/4_message.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cleanObject, fromUnixTimestamp, getLogger, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
2
2
|
import { as, types } from "../2_tl.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FileType, toUniqueFileId } from "./0__file_id.js";
|
|
4
|
+
import { serializeFileId } from "./0__file_id.js";
|
|
4
5
|
import { constructContact } from "./0_contact.js";
|
|
5
6
|
import { constructDice } from "./0_dice.js";
|
|
6
7
|
import { constructLinkPreview } from "./0_link_preview.js";
|
|
@@ -389,51 +390,54 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
389
390
|
else if (message_.media instanceof types.MessageMediaDocument) {
|
|
390
391
|
const { document } = message_.media;
|
|
391
392
|
if (document instanceof types.Document) {
|
|
392
|
-
const getFileId = (type) =>
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
const getFileId = (type) => ({
|
|
394
|
+
type,
|
|
395
|
+
dcId: document.dc_id,
|
|
395
396
|
fileReference: document.file_reference,
|
|
396
|
-
|
|
397
|
-
|
|
397
|
+
location: { type: "common", id: document.id, accessHash: document.access_hash },
|
|
398
|
+
});
|
|
398
399
|
const animated = document.attributes.find((v) => v instanceof types.DocumentAttributeAnimated);
|
|
399
400
|
const audio = document.attributes.find((v) => v instanceof types.DocumentAttributeAudio);
|
|
400
401
|
const fileName = document.attributes.find((v) => v instanceof types.DocumentAttributeFilename);
|
|
401
402
|
const sticker = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
|
|
402
403
|
const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
|
|
403
404
|
if (animated) {
|
|
404
|
-
const
|
|
405
|
+
const fileId = getFileId(FileType.Animation);
|
|
406
|
+
const animation = constructAnimation(document, video, fileName, serializeFileId(fileId), toUniqueFileId(fileId));
|
|
405
407
|
m = { ...messageMedia, animation };
|
|
406
408
|
}
|
|
407
409
|
else if (video) {
|
|
408
410
|
if (video.round_message) {
|
|
409
|
-
const
|
|
411
|
+
const fileId = getFileId(FileType.VideoNote);
|
|
412
|
+
const videoNote = constructVideoNote(document, video, serializeFileId(fileId), toUniqueFileId(fileId));
|
|
410
413
|
m = { ...message, videoNote };
|
|
411
414
|
}
|
|
412
415
|
else {
|
|
413
|
-
const
|
|
416
|
+
const fileId = getFileId(FileType.Video);
|
|
417
|
+
const video_ = constructVideo(document, video, fileName?.file_name, serializeFileId(fileId), toUniqueFileId(fileId));
|
|
414
418
|
m = { ...messageMedia, video: video_ };
|
|
415
419
|
}
|
|
416
420
|
}
|
|
417
421
|
else if (audio) {
|
|
418
422
|
if (audio.voice) {
|
|
419
|
-
const
|
|
423
|
+
const fileId = getFileId(FileType.VoiceNote);
|
|
424
|
+
const voice = constructVoice(document, audio, serializeFileId(fileId), toUniqueFileId(fileId));
|
|
420
425
|
m = { ...messageMedia, voice };
|
|
421
426
|
}
|
|
422
427
|
else {
|
|
423
|
-
const
|
|
428
|
+
const fileId = getFileId(FileType.Audio);
|
|
429
|
+
const audio_ = constructAudio(document, audio, serializeFileId(fileId), toUniqueFileId(fileId));
|
|
424
430
|
m = { ...messageMedia, audio: audio_ };
|
|
425
431
|
}
|
|
426
432
|
}
|
|
427
433
|
else if (sticker) {
|
|
428
|
-
const
|
|
434
|
+
const fileId = getFileId(FileType.Sticker);
|
|
435
|
+
const sticker = await constructSticker(document, serializeFileId(fileId), toUniqueFileId(fileId), getStickerSetName);
|
|
429
436
|
m = { ...message, sticker };
|
|
430
437
|
}
|
|
431
|
-
else if (fileName) {
|
|
432
|
-
const document_ = constructDocument(document, fileName, getFileId(FileType.Document), fileUniqueId);
|
|
433
|
-
m = { ...messageMedia, document: document_ };
|
|
434
|
-
}
|
|
435
438
|
else {
|
|
436
|
-
const
|
|
439
|
+
const fileId = getFileId(FileType.Document);
|
|
440
|
+
const document_ = constructDocument(document, fileName ?? new types.DocumentAttributeFilename({ file_name: "Unknown" }), serializeFileId(fileId), toUniqueFileId(fileId));
|
|
437
441
|
m = { ...messageMedia, document: document_ };
|
|
438
442
|
}
|
|
439
443
|
}
|
|
@@ -4,12 +4,19 @@ import { User } from "./1_user.js";
|
|
|
4
4
|
import { Message, MessageGetter } from "./4_message.js";
|
|
5
5
|
/** A received callback query. */
|
|
6
6
|
export interface CallbackQuery {
|
|
7
|
+
/** The identifier of the callback query. */
|
|
7
8
|
id: string;
|
|
9
|
+
/** The user who made the callback query. */
|
|
8
10
|
from: User;
|
|
11
|
+
/** The message from which the callback query was made. Unset if made from an inline result message. */
|
|
9
12
|
message?: Message;
|
|
13
|
+
/** The identifier of the inline result message from which the callback query was made. Unset if made from a message not originating from an inline query result. */
|
|
10
14
|
inlineMessageId?: string;
|
|
15
|
+
/** A special identifier for the chat in which the callback was made from. Useful for inline result messages. */
|
|
11
16
|
chatInstance: string;
|
|
17
|
+
/** The data associated with the button that was used to make the callback query. */
|
|
12
18
|
data?: string;
|
|
19
|
+
/** The short name of the game to be returned. */
|
|
13
20
|
gameShortName?: string;
|
|
14
21
|
}
|
|
15
22
|
export declare function deserializeInlineMessageId(inlineMessageId: string): enums.InputBotInlineMessageID;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function concat(...buffers: [Uint8Array, Uint8Array, ...Uint8Array[]]): Uint8Array;
|
|
2
|
-
export declare function bufferFromBigInt(
|
|
2
|
+
export declare function bufferFromBigInt(int: bigint | number, byteCount: number, littleEndian?: boolean, signed?: boolean): Uint8Array;
|
|
@@ -12,31 +12,33 @@ export function concat(...buffers) {
|
|
|
12
12
|
return buffer;
|
|
13
13
|
}
|
|
14
14
|
const bufferFromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
15
|
-
export function bufferFromBigInt(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
export function bufferFromBigInt(int, byteCount, littleEndian = true, signed = false) {
|
|
16
|
+
const actualByteCount = Math.ceil(int.toString(2).length / 8);
|
|
17
|
+
if (byteCount < actualByteCount) {
|
|
18
|
+
throw new Error("Int too big");
|
|
19
|
+
}
|
|
20
|
+
if (byteCount == 4 || byteCount == 2) { // fast path
|
|
21
|
+
const buffer = new Uint8Array(byteCount);
|
|
22
|
+
const dataView = new DataView(buffer.buffer);
|
|
23
|
+
(byteCount == 2 ? signed ? dataView.setInt16 : dataView.setUint16 : signed ? dataView.setInt32 : dataView.setUint32).call(dataView, 0, Number(int), littleEndian);
|
|
24
|
+
return buffer;
|
|
25
|
+
}
|
|
26
|
+
int = BigInt(typeof int === "number" ? Math.ceil(int) : int);
|
|
27
|
+
if (byteCount == 8) { // fast path
|
|
28
|
+
const buffer = new Uint8Array(byteCount);
|
|
29
|
+
const dataView = new DataView(buffer.buffer);
|
|
30
|
+
(signed ? dataView.setBigInt64 : dataView.setBigUint64).call(dataView, 0, int, littleEndian);
|
|
31
|
+
return buffer;
|
|
32
|
+
}
|
|
33
|
+
if (!signed && int < 0n) {
|
|
34
|
+
throw new Error("Got unexpected signed int");
|
|
35
|
+
}
|
|
36
|
+
if (signed && int < 0n) {
|
|
37
|
+
int = 2n ** BigInt(byteCount * 8) + int;
|
|
38
|
+
}
|
|
39
|
+
const hex = int.toString(16).padStart(byteCount * 2, "0");
|
|
31
40
|
const buffer = bufferFromHexString(hex);
|
|
32
|
-
if (
|
|
33
|
-
buffer[buffer.length - 1] = 256 -
|
|
34
|
-
buffer[buffer.length - 1];
|
|
35
|
-
for (let i = 0; i < buffer.length - 1; i++) {
|
|
36
|
-
buffer[i] = 255 - buffer[i];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (little) {
|
|
41
|
+
if (littleEndian) {
|
|
40
42
|
buffer.reverse();
|
|
41
43
|
}
|
|
42
44
|
return buffer;
|
package/package.json
CHANGED
package/script/4_constants.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const ACK_THRESHOLD = 10;
|
|
|
3
3
|
export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
5
|
export declare const INITIAL_DC: DC;
|
|
6
|
-
export declare const LAYER =
|
|
7
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
6
|
+
export declare const LAYER = 176;
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.160";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -78,8 +78,8 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
78
78
|
],
|
|
79
79
|
]);
|
|
80
80
|
exports.INITIAL_DC = "2";
|
|
81
|
-
exports.LAYER =
|
|
82
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
81
|
+
exports.LAYER = 176;
|
|
82
|
+
exports.APP_VERSION = "MTKruto 0.1.160";
|
|
83
83
|
// @ts-ignore: lib
|
|
84
84
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
85
85
|
exports.LANG_CODE = typeof navigator === "undefined" || typeof navigator.language !== "string" ? "en" : navigator.language.split("-")[0];
|