@mtkruto/node 0.0.923 → 0.0.930
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/client/3_client.d.ts +2 -0
- package/esm/client/3_client.js +17 -4
- package/esm/constants.d.ts +2 -1
- package/esm/constants.js +2 -1
- package/esm/storage/0_storage.d.ts +3 -0
- package/esm/storage/0_storage.js +19 -0
- package/esm/types/0_audio.d.ts +13 -0
- package/esm/types/0_audio.js +14 -0
- package/esm/types/0_contact.d.ts +9 -0
- package/esm/types/0_contact.js +9 -0
- package/esm/types/0_dice.d.ts +6 -0
- package/esm/types/0_dice.js +3 -0
- package/esm/types/0_mask_position.d.ts +8 -0
- package/esm/types/0_mask_position.js +8 -0
- package/esm/types/0_thumbnail.d.ts +1 -1
- package/esm/types/0_thumbnail.js +15 -1
- package/esm/types/0_voice.d.ts +9 -0
- package/esm/types/0_voice.js +9 -0
- package/esm/types/1_animation.d.ts +13 -0
- package/esm/types/1_animation.js +14 -0
- package/esm/types/1_document.d.ts +11 -0
- package/esm/types/1_document.js +12 -0
- package/esm/types/1_photo.js +1 -13
- package/esm/types/1_sticker.d.ts +23 -0
- package/esm/types/1_sticker.js +28 -0
- package/esm/types/1_video.d.ts +14 -0
- package/esm/types/1_video.js +15 -0
- package/esm/types/1_video_note.d.ts +12 -0
- package/esm/types/1_video_note.js +12 -0
- package/esm/types/3_message.d.ts +19 -1
- package/esm/types/3_message.js +65 -2
- package/package.json +1 -1
- package/script/client/3_client.d.ts +2 -0
- package/script/client/3_client.js +17 -4
- package/script/constants.d.ts +2 -1
- package/script/constants.js +3 -2
- package/script/storage/0_storage.d.ts +3 -0
- package/script/storage/0_storage.js +19 -0
- package/script/types/0_audio.d.ts +13 -0
- package/script/types/0_audio.js +41 -0
- package/script/types/0_contact.d.ts +9 -0
- package/script/types/0_contact.js +13 -0
- package/script/types/0_dice.d.ts +6 -0
- package/script/types/0_dice.js +7 -0
- package/script/types/0_mask_position.d.ts +8 -0
- package/script/types/0_mask_position.js +12 -0
- package/script/types/0_thumbnail.d.ts +1 -1
- package/script/types/0_thumbnail.js +38 -1
- package/script/types/0_voice.d.ts +9 -0
- package/script/types/0_voice.js +13 -0
- package/script/types/1_animation.d.ts +13 -0
- package/script/types/1_animation.js +41 -0
- package/script/types/1_document.d.ts +11 -0
- package/script/types/1_document.js +39 -0
- package/script/types/1_photo.js +1 -13
- package/script/types/1_sticker.d.ts +23 -0
- package/script/types/1_sticker.js +55 -0
- package/script/types/1_video.d.ts +14 -0
- package/script/types/1_video.js +42 -0
- package/script/types/1_video_note.d.ts +12 -0
- package/script/types/1_video_note.js +39 -0
- package/script/types/3_message.d.ts +19 -1
- package/script/types/3_message.js +65 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.constructVideoNote = void 0;
|
|
27
|
+
const types = __importStar(require("../tl/2_types.js"));
|
|
28
|
+
const _0_thumbnail_js_1 = require("./0_thumbnail.js");
|
|
29
|
+
function constructVideoNote(document, videoAttribute, fileId, fileUniqueId) {
|
|
30
|
+
return {
|
|
31
|
+
fileId,
|
|
32
|
+
fileUniqueId,
|
|
33
|
+
length: videoAttribute.w,
|
|
34
|
+
duration: videoAttribute.duration,
|
|
35
|
+
thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
|
|
36
|
+
fileSize: Number(document.size),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.constructVideoNote = constructVideoNote;
|
|
@@ -7,7 +7,16 @@ import { Chat } from "./1_chat.js";
|
|
|
7
7
|
import { User } from "./1_user.js";
|
|
8
8
|
import { InlineKeyboardMarkup } from "./2_inline_keyboard_markup.js";
|
|
9
9
|
import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
|
|
10
|
+
import { Sticker, StickerSetNameGetter } from "./1_sticker.js";
|
|
10
11
|
import { Photo } from "./1_photo.js";
|
|
12
|
+
import { Document } from "./1_document.js";
|
|
13
|
+
import { Video } from "./1_video.js";
|
|
14
|
+
import { VideoNote } from "./1_video_note.js";
|
|
15
|
+
import { Animation } from "./1_animation.js";
|
|
16
|
+
import { Audio } from "./0_audio.js";
|
|
17
|
+
import { Voice } from "./0_voice.js";
|
|
18
|
+
import { Dice } from "./0_dice.js";
|
|
19
|
+
import { Contact } from "./0_contact.js";
|
|
11
20
|
export interface Message {
|
|
12
21
|
id: number;
|
|
13
22
|
threadId?: number;
|
|
@@ -37,6 +46,15 @@ export interface Message {
|
|
|
37
46
|
views?: number;
|
|
38
47
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
39
48
|
photo?: Photo;
|
|
49
|
+
document?: Document;
|
|
50
|
+
video?: Video;
|
|
51
|
+
sticker?: Sticker;
|
|
52
|
+
animation?: Animation;
|
|
53
|
+
voice?: Voice;
|
|
54
|
+
audio?: Audio;
|
|
55
|
+
dice?: Dice;
|
|
56
|
+
videoNote?: VideoNote;
|
|
57
|
+
contact?: Contact;
|
|
40
58
|
}
|
|
41
59
|
export declare function constructMessage(message_: types.Message, getEntity: {
|
|
42
60
|
(peer: types.PeerUser): MaybePromise<types.User | null>;
|
|
@@ -44,4 +62,4 @@ export declare function constructMessage(message_: types.Message, getEntity: {
|
|
|
44
62
|
(peer: types.PeerChannel): MaybePromise<types.Channel | null>;
|
|
45
63
|
}, getMessage: {
|
|
46
64
|
(chatId: number, messageId: number): MaybePromise<Omit<Message, "replyToMessage"> | null>;
|
|
47
|
-
} | null): Promise<Message>;
|
|
65
|
+
} | null, getStickerSetName: StickerSetNameGetter): Promise<Message>;
|
|
@@ -35,9 +35,19 @@ const _1_chat_js_1 = require("./1_chat.js");
|
|
|
35
35
|
const _1_user_js_1 = require("./1_user.js");
|
|
36
36
|
const _2_inline_keyboard_markup_js_1 = require("./2_inline_keyboard_markup.js");
|
|
37
37
|
const _2_reply_keyboard_markup_js_1 = require("./2_reply_keyboard_markup.js");
|
|
38
|
+
const _1_sticker_js_1 = require("./1_sticker.js");
|
|
38
39
|
const _1_photo_js_1 = require("./1_photo.js");
|
|
40
|
+
const _1_document_js_1 = require("./1_document.js");
|
|
41
|
+
const _1_video_js_1 = require("./1_video.js");
|
|
42
|
+
const _1_video_note_js_1 = require("./1_video_note.js");
|
|
43
|
+
const _1_animation_js_1 = require("./1_animation.js");
|
|
44
|
+
const _0_audio_js_1 = require("./0_audio.js");
|
|
45
|
+
const _0_voice_js_1 = require("./0_voice.js");
|
|
46
|
+
const _0_dice_js_1 = require("./0_dice.js");
|
|
47
|
+
const _0_file_id_js_1 = require("./!0_file_id.js");
|
|
48
|
+
const _0_contact_js_1 = require("./0_contact.js");
|
|
39
49
|
const d = (0, deps_js_1.debug)("types/Message");
|
|
40
|
-
async function constructMessage(message_, getEntity, getMessage) {
|
|
50
|
+
async function constructMessage(message_, getEntity, getMessage, getStickerSetName) {
|
|
41
51
|
let chat_ = null;
|
|
42
52
|
if (message_.peerId instanceof types.PeerUser) {
|
|
43
53
|
const entity = await getEntity(message_.peerId);
|
|
@@ -137,7 +147,6 @@ async function constructMessage(message_, getEntity, getMessage) {
|
|
|
137
147
|
(0, _0_control_js_1.UNREACHABLE)();
|
|
138
148
|
}
|
|
139
149
|
}
|
|
140
|
-
// message_.
|
|
141
150
|
if (getMessage && message_.replyTo instanceof types.MessageReplyHeader) {
|
|
142
151
|
if (message_.replyTo.forumTopic) {
|
|
143
152
|
message.isTopicMessage = true;
|
|
@@ -206,6 +215,60 @@ async function constructMessage(message_, getEntity, getMessage) {
|
|
|
206
215
|
message.photo = (0, _1_photo_js_1.constructPhoto)(message_.media.photo);
|
|
207
216
|
}
|
|
208
217
|
}
|
|
218
|
+
else if (message_.media instanceof types.MessageMediaDice) {
|
|
219
|
+
message.dice = (0, _0_dice_js_1.constructDice)(message_.media);
|
|
220
|
+
}
|
|
221
|
+
else if (message_.media instanceof types.MessageMediaDocument) {
|
|
222
|
+
const { document } = message_.media;
|
|
223
|
+
if (document instanceof types.Document) {
|
|
224
|
+
const getFileId = (type) => new _0_file_id_js_1.FileID(null, null, type, document.dcId, {
|
|
225
|
+
mediaId: document.id,
|
|
226
|
+
accessHash: document.accessHash,
|
|
227
|
+
fileReference: document.fileReference,
|
|
228
|
+
}).encode();
|
|
229
|
+
const fileUniqueId = new _0_file_id_js_1.FileUniqueID(_0_file_id_js_1.FileUniqueType.Document, { mediaId: document.id }).encode();
|
|
230
|
+
const animated = document.attributes.find((v) => v instanceof types.DocumentAttributeAnimated);
|
|
231
|
+
const audio = document.attributes.find((v) => v instanceof types.DocumentAttributeAudio);
|
|
232
|
+
const fileName = document.attributes.find((v) => v instanceof types.DocumentAttributeFilename);
|
|
233
|
+
const sticker = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
|
|
234
|
+
const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
|
|
235
|
+
if (animated) {
|
|
236
|
+
message.animation = (0, _1_animation_js_1.constructAnimation)(document, video, getFileId(_0_file_id_js_1.FileType.Animation), fileUniqueId);
|
|
237
|
+
}
|
|
238
|
+
else if (video) {
|
|
239
|
+
if (video.roundMessage) {
|
|
240
|
+
message.videoNote = (0, _1_video_note_js_1.constructVideoNote)(document, video, getFileId(_0_file_id_js_1.FileType.VideoNote), fileUniqueId);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
message.video = (0, _1_video_js_1.constructVideo)(document, video, fileName?.fileName, getFileId(_0_file_id_js_1.FileType.Video), fileUniqueId);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else if (audio) {
|
|
247
|
+
if (audio.voice) {
|
|
248
|
+
message.voice = (0, _0_voice_js_1.constructVoice)(document, audio, getFileId(_0_file_id_js_1.FileType.Voice), fileUniqueId);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
message.audio = (0, _0_audio_js_1.constructAudio)(document, audio, getFileId(_0_file_id_js_1.FileType.Audio), fileUniqueId);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else if (sticker) {
|
|
255
|
+
message.sticker = await (0, _1_sticker_js_1.constructSticker)(document, getFileId(_0_file_id_js_1.FileType.Sticker), fileUniqueId, getStickerSetName);
|
|
256
|
+
}
|
|
257
|
+
else if (fileName) {
|
|
258
|
+
message.document = (0, _1_document_js_1.constructDocument)(document, fileName, getFileId(_0_file_id_js_1.FileType.Document), fileUniqueId);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
(0, _0_control_js_1.UNREACHABLE)();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (message_.media instanceof types.MessageMediaContact) {
|
|
266
|
+
message.contact = (0, _0_contact_js_1.constructContact)(message_.media);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// not implemented
|
|
270
|
+
(0, _0_control_js_1.UNREACHABLE)();
|
|
271
|
+
}
|
|
209
272
|
}
|
|
210
273
|
return (0, _0_object_js_1.cleanObject)(message);
|
|
211
274
|
}
|