@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.
Files changed (83) hide show
  1. package/esm/4_constants.d.ts +2 -2
  2. package/esm/4_constants.js +2 -2
  3. package/esm/client/1_composer.d.ts +2 -2
  4. package/esm/client/1_composer.js +4 -4
  5. package/esm/client/1_file_manager.js +53 -56
  6. package/esm/client/2_message_manager.js +8 -11
  7. package/esm/client/4_client.d.ts +2 -2
  8. package/esm/client/4_client.js +4 -4
  9. package/esm/tl/2_types.d.ts +596 -1
  10. package/esm/tl/2_types.js +1824 -319
  11. package/esm/tl/3_functions.d.ts +374 -2
  12. package/esm/tl/3_functions.js +943 -31
  13. package/esm/types/0__file_id.d.ts +79 -54
  14. package/esm/types/0__file_id.js +259 -277
  15. package/esm/types/0_chat_photo.js +15 -21
  16. package/esm/types/0_giveaway_parameters.d.ts +5 -0
  17. package/esm/types/0_login_url.d.ts +4 -0
  18. package/esm/types/0_message_reference.d.ts +2 -0
  19. package/esm/types/0_price_tag.d.ts +2 -0
  20. package/esm/types/0_thumbnail.js +16 -14
  21. package/esm/types/1_giveaway.d.ts +2 -0
  22. package/esm/types/1_inline_query_result_button.d.ts +3 -0
  23. package/esm/types/1_photo.js +20 -14
  24. package/esm/types/1_poll.d.ts +13 -0
  25. package/esm/types/1_reaction_count.d.ts +2 -0
  26. package/esm/types/1_reply_quote.d.ts +3 -0
  27. package/esm/types/1_user.d.ts +13 -13
  28. package/esm/types/2_chosen_inline_result.d.ts +5 -0
  29. package/esm/types/2_game.d.ts +6 -0
  30. package/esm/types/2_game.js +11 -7
  31. package/esm/types/2_inactive_chat.d.ts +3 -0
  32. package/esm/types/2_inline_query.d.ts +6 -0
  33. package/esm/types/2_message_interactions.d.ts +5 -0
  34. package/esm/types/2_message_reaction_count.d.ts +4 -0
  35. package/esm/types/2_message_reactions.d.ts +7 -0
  36. package/esm/types/2_story_content.js +4 -7
  37. package/esm/types/4_inline_query_result.js +5 -5
  38. package/esm/types/4_message.js +21 -17
  39. package/esm/types/5_callback_query.d.ts +7 -0
  40. package/esm/utilities/0_buffer.d.ts +1 -1
  41. package/esm/utilities/0_buffer.js +26 -24
  42. package/package.json +1 -1
  43. package/script/4_constants.d.ts +2 -2
  44. package/script/4_constants.js +2 -2
  45. package/script/client/1_composer.d.ts +2 -2
  46. package/script/client/1_composer.js +4 -4
  47. package/script/client/1_file_manager.js +52 -55
  48. package/script/client/2_message_manager.js +6 -9
  49. package/script/client/4_client.d.ts +2 -2
  50. package/script/client/4_client.js +4 -4
  51. package/script/tl/2_types.d.ts +596 -1
  52. package/script/tl/2_types.js +1904 -345
  53. package/script/tl/3_functions.d.ts +374 -2
  54. package/script/tl/3_functions.js +977 -41
  55. package/script/types/0__file_id.d.ts +79 -54
  56. package/script/types/0__file_id.js +263 -280
  57. package/script/types/0_chat_photo.js +14 -20
  58. package/script/types/0_giveaway_parameters.d.ts +5 -0
  59. package/script/types/0_login_url.d.ts +4 -0
  60. package/script/types/0_message_reference.d.ts +2 -0
  61. package/script/types/0_price_tag.d.ts +2 -0
  62. package/script/types/0_thumbnail.js +15 -13
  63. package/script/types/1_giveaway.d.ts +2 -0
  64. package/script/types/1_inline_query_result_button.d.ts +3 -0
  65. package/script/types/1_photo.js +19 -13
  66. package/script/types/1_poll.d.ts +13 -0
  67. package/script/types/1_reaction_count.d.ts +2 -0
  68. package/script/types/1_reply_quote.d.ts +3 -0
  69. package/script/types/1_user.d.ts +13 -13
  70. package/script/types/2_chosen_inline_result.d.ts +5 -0
  71. package/script/types/2_game.d.ts +6 -0
  72. package/script/types/2_game.js +10 -6
  73. package/script/types/2_inactive_chat.d.ts +3 -0
  74. package/script/types/2_inline_query.d.ts +6 -0
  75. package/script/types/2_message_interactions.d.ts +5 -0
  76. package/script/types/2_message_reaction_count.d.ts +4 -0
  77. package/script/types/2_message_reactions.d.ts +7 -0
  78. package/script/types/2_story_content.js +3 -6
  79. package/script/types/4_inline_query_result.js +4 -4
  80. package/script/types/4_message.js +20 -16
  81. package/script/types/5_callback_query.d.ts +7 -0
  82. package/script/utilities/0_buffer.d.ts +1 -1
  83. 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, ...middleawre: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, 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
- }, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<WithFilter<C, "message:text">>;
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, ...middleawre) {
77
+ on(filter, ...middleware) {
78
78
  return this.filter((ctx) => {
79
79
  return (0, _0_filters_js_1.match)(filter, ctx);
80
- }, ...middleawre);
80
+ }, ...middleware);
81
81
  }
82
- command(commands, ...middleawre) {
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
- }, ...middleawre);
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.FileID.decode(fileId);
106
- switch (fileId_.fileType) {
107
- case _3_types_js_1.FileType.ChatPhoto: {
108
- const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
109
- const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(fileId_.params.chatId);
110
- const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.params.mediaId });
111
- for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
112
- yield chunk;
113
- }
114
- break;
115
- }
116
- case _3_types_js_1.FileType.Photo: {
117
- if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
118
- (0, _1_utilities_js_1.UNREACHABLE)();
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
- const location = new _2_tl_js_1.types.InputPhotoFileLocation({
121
- id: fileId_.params.mediaId,
122
- access_hash: fileId_.params.accessHash,
123
- file_reference: fileId_.params.fileReference,
124
- thumb_size: fileId_.params.thumbnailSize,
125
- });
126
- for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
127
- yield chunk;
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
- case _3_types_js_1.FileType.Document:
132
- case _3_types_js_1.FileType.Sticker:
133
- case _3_types_js_1.FileType.VideoNote:
134
- case _3_types_js_1.FileType.Video:
135
- case _3_types_js_1.FileType.Audio:
136
- case _3_types_js_1.FileType.Voice:
137
- case _3_types_js_1.FileType.Animation: {
138
- if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
139
- (0, _1_utilities_js_1.UNREACHABLE)();
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
- default:
153
- (0, _1_utilities_js_1.UNREACHABLE)();
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 fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
168
- const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
169
- mediaId: document_.id,
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
- }).encode();
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 fileUniqueId = new _3_types_js_1.FileUniqueID(_3_types_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode();
188
- const fileId = new _3_types_js_1.FileID(null, null, _3_types_js_1.FileType.Document, document_.dc_id, {
189
- mediaId: document_.id,
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
- }).encode();
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.Voice, [
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 = _3_types_js_2.FileID.decode(maybeFileId);
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.fileType != expectedFileType) {
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.params.mediaId,
446
- access_hash: fileId.params.accessHash,
447
- file_reference: fileId.params.fileReference,
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, ...middleawre: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, 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
- }, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<WithFilter<C, "message:text">>;
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, ...middleawre) {
1398
+ on(filter, ...middleware) {
1399
1399
  return this.filter((ctx) => {
1400
1400
  return (0, _0_filters_js_1.match)(filter, ctx);
1401
- }, ...middleawre);
1401
+ }, ...middleware);
1402
1402
  }
1403
- command(commands, ...middleawre) {
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
- }, ...middleawre);
1444
+ }, ...middleware);
1445
1445
  }
1446
1446
  //#endregion
1447
1447
  /**