@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
|
@@ -21,10 +21,10 @@ export declare class Composer<C extends {
|
|
|
21
21
|
branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<C>;
|
|
22
22
|
filter<D extends C>(predicate: (ctx: UpdateIntersection<C>) => ctx is D, ...middleware: Middleware<D>[]): Composer<D>;
|
|
23
23
|
filter(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, ...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
|
|
24
|
-
on<Q extends FilterQuery>(filter: Q, ...
|
|
24
|
+
on<Q extends FilterQuery>(filter: Q, ...middleware: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, Q>>>;
|
|
25
25
|
command(commands: string | RegExp | (string | RegExp)[] | {
|
|
26
26
|
names: string | RegExp | (string | RegExp)[];
|
|
27
27
|
prefixes: string | string[];
|
|
28
|
-
}, ...
|
|
28
|
+
}, ...middleware: Middleware<WithFilter<C, "message:text">>[]): Composer<WithFilter<C, "message:text">>;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -74,12 +74,12 @@ class Composer {
|
|
|
74
74
|
this.branch(predicate, composer, skip);
|
|
75
75
|
return composer;
|
|
76
76
|
}
|
|
77
|
-
on(filter, ...
|
|
77
|
+
on(filter, ...middleware) {
|
|
78
78
|
return this.filter((ctx) => {
|
|
79
79
|
return (0, _0_filters_js_1.match)(filter, ctx);
|
|
80
|
-
}, ...
|
|
80
|
+
}, ...middleware);
|
|
81
81
|
}
|
|
82
|
-
command(commands, ...
|
|
82
|
+
command(commands, ...middleware) {
|
|
83
83
|
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
84
84
|
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
85
85
|
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Composer_prefixes, "f") ?? []);
|
|
@@ -120,7 +120,7 @@ class Composer {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
123
|
-
}, ...
|
|
123
|
+
}, ...middleware);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
exports.Composer = Composer;
|
|
@@ -102,55 +102,48 @@ class FileManager {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
async *download(fileId, params) {
|
|
105
|
-
const fileId_ = _3_types_js_1.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
105
|
+
const fileId_ = (0, _3_types_js_1.deserializeFileId)(fileId);
|
|
106
|
+
if (fileId_.location.type == "photo") {
|
|
107
|
+
switch (fileId_.type) {
|
|
108
|
+
case _3_types_js_1.FileType.ProfilePhoto: {
|
|
109
|
+
if (fileId_.location.source.type != _3_types_js_1.PhotoSourceType.ChatPhotoBig && fileId_.location.source.type != _3_types_js_1.PhotoSourceType.ChatPhotoSmall) {
|
|
110
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
111
|
+
}
|
|
112
|
+
const big = fileId_.location.source.type == _3_types_js_1.PhotoSourceType.ChatPhotoBig;
|
|
113
|
+
const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId)); // TODO: use access hash from source?
|
|
114
|
+
const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.location.id });
|
|
115
|
+
for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
116
|
+
yield chunk;
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
case _3_types_js_1.FileType.Photo: {
|
|
121
|
+
const location = new _2_tl_js_1.types.InputPhotoFileLocation({
|
|
122
|
+
id: fileId_.location.id,
|
|
123
|
+
access_hash: fileId_.location.accessHash,
|
|
124
|
+
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
125
|
+
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : "",
|
|
126
|
+
});
|
|
127
|
+
for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
128
|
+
yield chunk;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
128
131
|
}
|
|
129
|
-
break;
|
|
130
132
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const location = new _2_tl_js_1.types.InputDocumentFileLocation({
|
|
142
|
-
id: fileId_.params.mediaId,
|
|
143
|
-
access_hash: fileId_.params.accessHash,
|
|
144
|
-
file_reference: fileId_.params.fileReference,
|
|
145
|
-
thumb_size: fileId_.params.thumbnailSize,
|
|
146
|
-
});
|
|
147
|
-
for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
148
|
-
yield chunk;
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
133
|
+
}
|
|
134
|
+
else if (fileId_.location.type == "common") {
|
|
135
|
+
const location = new _2_tl_js_1.types.InputDocumentFileLocation({
|
|
136
|
+
id: fileId_.location.id,
|
|
137
|
+
access_hash: fileId_.location.accessHash,
|
|
138
|
+
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
139
|
+
thumb_size: "", // TODO?
|
|
140
|
+
});
|
|
141
|
+
for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
|
|
142
|
+
yield chunk;
|
|
151
143
|
}
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
154
147
|
}
|
|
155
148
|
}
|
|
156
149
|
async getCustomEmojiDocuments(id) {
|
|
@@ -164,12 +157,14 @@ class FileManager {
|
|
|
164
157
|
const maybeDocument = await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.getCustomEmojiDocument(BigInt(id_));
|
|
165
158
|
if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= 30 * 60 * 1000) {
|
|
166
159
|
const document_ = maybeDocument[0];
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
accessHash: document_.access_hash,
|
|
160
|
+
const fileId_ = {
|
|
161
|
+
type: _3_types_js_1.FileType.Document,
|
|
162
|
+
dcId: document_.dc_id,
|
|
171
163
|
fileReference: document_.file_reference,
|
|
172
|
-
|
|
164
|
+
location: { type: "common", id: document_.id, accessHash: document_.access_hash },
|
|
165
|
+
};
|
|
166
|
+
const fileUniqueId = (0, _3_types_js_1.toUniqueFileId)(fileId_);
|
|
167
|
+
const fileId = (0, _3_types_js_1.serializeFileId)(fileId_);
|
|
173
168
|
const document = (0, _3_types_js_1.constructDocument)(document_, new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${(0, _0_deps_js_1.extension)(document_.mime_type)}` }), fileId, fileUniqueId);
|
|
174
169
|
documents.push(document);
|
|
175
170
|
}
|
|
@@ -184,12 +179,14 @@ class FileManager {
|
|
|
184
179
|
const documents_ = await __classPrivateFieldGet(this, _FileManager_c, "f").api.messages.getCustomEmojiDocuments({ document_id: id.map(BigInt) }).then((v) => v.map((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Document)));
|
|
185
180
|
for (const [i, document_] of documents_.entries()) {
|
|
186
181
|
await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.setCustomEmojiDocument(document_.id, document_);
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
accessHash: document_.access_hash,
|
|
182
|
+
const fileId_ = {
|
|
183
|
+
type: _3_types_js_1.FileType.Document,
|
|
184
|
+
dcId: document_.dc_id,
|
|
191
185
|
fileReference: document_.file_reference,
|
|
192
|
-
|
|
186
|
+
location: { type: "common", id: document_.id, accessHash: document_.access_hash },
|
|
187
|
+
};
|
|
188
|
+
const fileUniqueId = (0, _3_types_js_1.toUniqueFileId)(fileId_);
|
|
189
|
+
const fileId = (0, _3_types_js_1.serializeFileId)(fileId_);
|
|
193
190
|
const document = (0, _3_types_js_1.constructDocument)(document_, new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: `${id[i] ?? "customEmoji"}.${(0, _0_deps_js_1.extension)(document_.mime_type)}` }), fileId, fileUniqueId);
|
|
194
191
|
documents.push(document);
|
|
195
192
|
}
|
|
@@ -366,7 +366,7 @@ class MessageManager {
|
|
|
366
366
|
return (0, _3_types_js_2.assertMessageType)(message, "audio");
|
|
367
367
|
}
|
|
368
368
|
async sendVoice(chatId, voice, params) {
|
|
369
|
-
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_2.FileType.
|
|
369
|
+
const message = await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_2.FileType.VoiceNote, [
|
|
370
370
|
new _2_tl_js_1.types.DocumentAttributeAudio({
|
|
371
371
|
voice: true,
|
|
372
372
|
duration: params?.duration ?? 0,
|
|
@@ -429,22 +429,19 @@ class MessageManager {
|
|
|
429
429
|
resolveFileId(maybeFileId, expectedFileType) {
|
|
430
430
|
let fileId = null;
|
|
431
431
|
try {
|
|
432
|
-
fileId =
|
|
432
|
+
fileId = (0, _3_types_js_1.deserializeFileId)(maybeFileId);
|
|
433
433
|
}
|
|
434
434
|
catch (err) {
|
|
435
435
|
__classPrivateFieldGet(this, _MessageManager_LresolveFileId, "f").warning(err);
|
|
436
436
|
}
|
|
437
437
|
if (fileId != null) {
|
|
438
|
-
if (fileId.
|
|
439
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
440
|
-
}
|
|
441
|
-
if (fileId.params.mediaId == undefined || fileId.params.accessHash == undefined || fileId.params.fileReference == undefined) {
|
|
438
|
+
if (fileId.type != expectedFileType) {
|
|
442
439
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
443
440
|
}
|
|
444
441
|
return {
|
|
445
|
-
id: fileId.
|
|
446
|
-
access_hash: fileId.
|
|
447
|
-
file_reference: fileId.
|
|
442
|
+
id: "id" in fileId.location ? fileId.location.id : (0, _1_utilities_js_1.UNREACHABLE)(),
|
|
443
|
+
access_hash: fileId.location.accessHash,
|
|
444
|
+
file_reference: fileId.fileReference ?? new Uint8Array(),
|
|
448
445
|
};
|
|
449
446
|
}
|
|
450
447
|
return null;
|
|
@@ -269,11 +269,11 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
269
269
|
branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<C>;
|
|
270
270
|
filter<D extends C>(predicate: (ctx: UpdateIntersection<C>) => ctx is D, ...middleware: Middleware<D>[]): Composer<D>;
|
|
271
271
|
filter(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, ...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
|
|
272
|
-
on<Q extends FilterQuery>(filter: Q, ...
|
|
272
|
+
on<Q extends FilterQuery>(filter: Q, ...middleware: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, Q>>>;
|
|
273
273
|
command(commands: string | RegExp | (string | RegExp)[] | {
|
|
274
274
|
names: string | RegExp | (string | RegExp)[];
|
|
275
275
|
prefixes: string | string[];
|
|
276
|
-
}, ...
|
|
276
|
+
}, ...middleware: Middleware<WithFilter<C, "message:text">>[]): Composer<WithFilter<C, "message:text">>;
|
|
277
277
|
/**
|
|
278
278
|
* Send a text message.
|
|
279
279
|
*
|
|
@@ -1395,12 +1395,12 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1395
1395
|
this.branch(predicate, composer, _1_composer_js_1.skip);
|
|
1396
1396
|
return composer;
|
|
1397
1397
|
}
|
|
1398
|
-
on(filter, ...
|
|
1398
|
+
on(filter, ...middleware) {
|
|
1399
1399
|
return this.filter((ctx) => {
|
|
1400
1400
|
return (0, _0_filters_js_1.match)(filter, ctx);
|
|
1401
|
-
}, ...
|
|
1401
|
+
}, ...middleware);
|
|
1402
1402
|
}
|
|
1403
|
-
command(commands, ...
|
|
1403
|
+
command(commands, ...middleware) {
|
|
1404
1404
|
const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
|
|
1405
1405
|
const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
|
|
1406
1406
|
const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Client_prefixes, "f") ?? []);
|
|
@@ -1441,7 +1441,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
return false;
|
|
1444
|
-
}, ...
|
|
1444
|
+
}, ...middleware);
|
|
1445
1445
|
}
|
|
1446
1446
|
//#endregion
|
|
1447
1447
|
/**
|