@mtkruto/node 0.1.130 → 0.1.131

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.
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo, _Client_resolveFileId, _Client_sendMedia, _Client_sendChatUpdate, _Client_reassignChatLastMessage, _Client_chats, _Client_archivedChats, _Client_chatsLoadedFromStorage, _Client_tryGetChatId, _Client_getChatAnywhere, _Client_getChatList, _Client_loadChatsFromStorage, _Client_getLoadedChats, _Client_pinnedChats, _Client_pinnedArchiveChats, _Client_storageHadPinnedChats, _Client_pinnedChatsLoaded, _Client_loadPinnedChats, _Client_fetchPinnedChats, _Client_getPinnedChats, _Client_updateOrAddChat, _Client_removeChat, _Client_updatePinnedChats, _Client_fetchChats;
12
+ var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortSignal, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkGap, _Client_checkChannelGap, _Client_lastUpdates, _Client_processUpdates, _Client_setUpdateStateDate, _Client_setUpdatePts, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_lastGetMe, _Client_getMe, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo, _Client_resolveFileId, _Client_sendMedia, _Client_sendDocumentInner, _Client_sendChatUpdate, _Client_reassignChatLastMessage, _Client_chats, _Client_archivedChats, _Client_chatsLoadedFromStorage, _Client_tryGetChatId, _Client_getChatAnywhere, _Client_getChatList, _Client_loadChatsFromStorage, _Client_getLoadedChats, _Client_pinnedChats, _Client_pinnedArchiveChats, _Client_storageHadPinnedChats, _Client_pinnedChatsLoaded, _Client_loadPinnedChats, _Client_fetchPinnedChats, _Client_getPinnedChats, _Client_updateOrAddChat, _Client_removeChat, _Client_updatePinnedChats, _Client_fetchChats;
13
13
  import { contentType, debug, extension, gunzip, Mutex } from "../0_deps.js";
14
14
  import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
15
15
  import { as, functions, getChannelChatId, Message_, MessageContainer, name, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
@@ -226,6 +226,51 @@ export class Client extends ClientAbstract {
226
226
  const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
227
227
  return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
228
228
  },
229
+ replyContact: (firstName, number, params) => {
230
+ const effectiveMessage = mustGetMsg();
231
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
232
+ return this.sendContact(effectiveMessage.chat.id, firstName, number, { ...params, replyToMessageId });
233
+ },
234
+ replyLocation: (latitude, longitude, params) => {
235
+ const effectiveMessage = mustGetMsg();
236
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
237
+ return this.sendLocation(effectiveMessage.chat.id, latitude, longitude, { ...params, replyToMessageId });
238
+ },
239
+ replyDice: (params) => {
240
+ const effectiveMessage = mustGetMsg();
241
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
242
+ return this.sendDice(effectiveMessage.chat.id, { ...params, replyToMessageId });
243
+ },
244
+ replyVenue: (latitude, longitude, title, address, params) => {
245
+ const effectiveMessage = mustGetMsg();
246
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
247
+ return this.sendVenue(effectiveMessage.chat.id, latitude, longitude, title, address, { ...params, replyToMessageId });
248
+ },
249
+ replyVideo: (document, params) => {
250
+ const effectiveMessage = mustGetMsg();
251
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
252
+ return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
253
+ },
254
+ replyAnimation: (document, params) => {
255
+ const effectiveMessage = mustGetMsg();
256
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
257
+ return this.sendAnimation(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
258
+ },
259
+ replyVoice: (document, params) => {
260
+ const effectiveMessage = mustGetMsg();
261
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
262
+ return this.sendVoice(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
263
+ },
264
+ replyAudio: (document, params) => {
265
+ const effectiveMessage = mustGetMsg();
266
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
267
+ return this.sendAudio(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
268
+ },
269
+ replyVideoNote: (videoNote, params) => {
270
+ const effectiveMessage = mustGetMsg();
271
+ const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
272
+ return this.sendVideoNote(effectiveMessage.chat.id, videoNote, { ...params, replyToMessageId });
273
+ },
229
274
  delete: () => {
230
275
  const effectiveMessage = mustGetMsg();
231
276
  return this.deleteMessage(effectiveMessage.chat.id, effectiveMessage.id);
@@ -1658,7 +1703,12 @@ export class Client extends ClientAbstract {
1658
1703
  break;
1659
1704
  }
1660
1705
  case FileType.Document:
1661
- case FileType.Sticker: {
1706
+ case FileType.Sticker:
1707
+ case FileType.VideoNote:
1708
+ case FileType.Video:
1709
+ case FileType.Audio:
1710
+ case FileType.Voice:
1711
+ case FileType.Animation: {
1662
1712
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
1663
1713
  UNREACHABLE();
1664
1714
  }
@@ -2268,37 +2318,255 @@ export class Client extends ClientAbstract {
2268
2318
  * @param document The document to send.
2269
2319
  */
2270
2320
  async sendDocument(chatId, document, params) {
2271
- let media = null;
2272
- const spoiler = params?.hasSpoiler ? true : undefined;
2273
- if (typeof document === "string") {
2274
- const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, FileType.Document);
2275
- if (fileId != null) {
2276
- media = new types.InputMediaDocument({
2277
- id: new types.InputDocument(fileId),
2278
- spoiler,
2279
- });
2280
- }
2281
- }
2282
- if (media == null) {
2283
- if (typeof document === "string" && isHttpUrl(document)) {
2284
- media = new types.InputMediaDocumentExternal({ url: document, spoiler });
2285
- }
2286
- else {
2287
- const [contents, fileName_] = await getFileContents(document);
2288
- const fileName = params?.fileName ?? fileName_;
2289
- const mimeType = params?.mimeType ?? contentType(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
2290
- const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
2291
- media = new types.InputMediaUploadedDocument({
2292
- file,
2293
- spoiler,
2294
- attributes: [new types.DocumentAttributeFilename({ file_name: fileName })],
2295
- mime_type: mimeType,
2296
- });
2297
- }
2298
- }
2299
- const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
2321
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, document, params, FileType.Document, []);
2300
2322
  return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
2301
2323
  }
2324
+ /**
2325
+ * Send a video.
2326
+ *
2327
+ * @method
2328
+ * @param chatId The chat to send the video to.
2329
+ * @param video The video to send.
2330
+ */
2331
+ async sendVideo(chatId, video, params) {
2332
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, video, params, FileType.Video, [
2333
+ new types.DocumentAttributeVideo({
2334
+ supports_streaming: params?.supportsStreaming ? true : undefined,
2335
+ w: params?.width ?? 0,
2336
+ h: params?.height ?? 0,
2337
+ duration: params?.duration ?? 0,
2338
+ }),
2339
+ ]);
2340
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "video");
2341
+ }
2342
+ /**
2343
+ * Send an animation.
2344
+ *
2345
+ * @method
2346
+ * @param chatId The chat to send the animation to.
2347
+ * @param animation The animation to send.
2348
+ */
2349
+ async sendAnimation(chatId, animation, params) {
2350
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, animation, params, FileType.Animation, [
2351
+ new types.DocumentAttributeAnimated(),
2352
+ new types.DocumentAttributeVideo({
2353
+ supports_streaming: true,
2354
+ w: params?.width ?? 0,
2355
+ h: params?.height ?? 0,
2356
+ duration: params?.duration ?? 0,
2357
+ }),
2358
+ ]);
2359
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "animation");
2360
+ }
2361
+ /**
2362
+ * Send a voice message.
2363
+ *
2364
+ * @method
2365
+ * @param chatId The chat to send the voice message to.
2366
+ * @param voice The voice to send.
2367
+ */
2368
+ async sendVoice(chatId, voice, params) {
2369
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, voice, params, FileType.Voice, [
2370
+ new types.DocumentAttributeAudio({
2371
+ voice: true,
2372
+ duration: params?.duration ?? 0,
2373
+ }),
2374
+ ]);
2375
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "voice");
2376
+ }
2377
+ /**
2378
+ * Send an audio file.
2379
+ *
2380
+ * @method
2381
+ * @param chatId The chat to send the audio file to.
2382
+ * @param audio The audio to send.
2383
+ */
2384
+ async sendAudio(chatId, audio, params) {
2385
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, FileType.Audio, [
2386
+ new types.DocumentAttributeAudio({
2387
+ duration: params?.duration ?? 0,
2388
+ performer: params?.performer,
2389
+ title: params?.title,
2390
+ }),
2391
+ ]);
2392
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "audio");
2393
+ }
2394
+ /**
2395
+ * Send a video note.
2396
+ *
2397
+ * @method
2398
+ * @param chatId The chat to send the video note to.
2399
+ * @param videoNote The video note to send.
2400
+ */
2401
+ async sendVideoNote(chatId, audio, params) {
2402
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, FileType.VideoNote, [
2403
+ new types.DocumentAttributeVideo({
2404
+ round_message: true,
2405
+ w: params?.length ?? 0,
2406
+ h: params?.length ?? 0,
2407
+ duration: params?.duration ?? 0,
2408
+ }),
2409
+ ], false);
2410
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "videoNote");
2411
+ }
2412
+ /**
2413
+ * Send a location.
2414
+ *
2415
+ * @method
2416
+ * @param chatId The chat to send the location to.
2417
+ * @param latitude The location's latitude.
2418
+ * @param longitude The location's longitude.
2419
+ */
2420
+ async sendLocation(chatId, latitude, longitude, params) {
2421
+ const peer = await this.getInputPeer(chatId);
2422
+ const randomId = getRandomId();
2423
+ const silent = params?.disableNotification ? true : undefined;
2424
+ const noforwards = params?.protectContent ? true : undefined;
2425
+ const replyToMsgId = params?.replyToMessageId;
2426
+ const topMsgId = params?.messageThreadId;
2427
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2428
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2429
+ const result = await this.api.messages.sendMedia({
2430
+ peer,
2431
+ random_id: randomId,
2432
+ silent,
2433
+ noforwards,
2434
+ reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2435
+ send_as: sendAs,
2436
+ reply_markup: replyMarkup,
2437
+ media: params?.livePeriod !== undefined
2438
+ ? new types.InputMediaGeoLive({
2439
+ geo_point: new types.InputGeoPoint({
2440
+ lat: latitude,
2441
+ long: longitude,
2442
+ accuracy_radius: params?.horizontalAccuracy,
2443
+ }),
2444
+ heading: params?.heading,
2445
+ period: params.livePeriod,
2446
+ proximity_notification_radius: params?.proximityAlertRadius,
2447
+ })
2448
+ : new types.InputMediaGeoPoint({
2449
+ geo_point: new types.InputGeoPoint({
2450
+ lat: latitude,
2451
+ long: longitude,
2452
+ accuracy_radius: params?.horizontalAccuracy,
2453
+ }),
2454
+ }),
2455
+ message: "",
2456
+ });
2457
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2458
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "location");
2459
+ }
2460
+ /**
2461
+ * Send a contact.
2462
+ *
2463
+ * @method
2464
+ * @param chatId The chat to send the contact to.
2465
+ * @param firstName The contact's first name.
2466
+ * @param number The contact's phone number.
2467
+ */
2468
+ async sendContact(chatId, firstName, number, params) {
2469
+ const peer = await this.getInputPeer(chatId);
2470
+ const randomId = getRandomId();
2471
+ const silent = params?.disableNotification ? true : undefined;
2472
+ const noforwards = params?.protectContent ? true : undefined;
2473
+ const replyToMsgId = params?.replyToMessageId;
2474
+ const topMsgId = params?.messageThreadId;
2475
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2476
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2477
+ const result = await this.api.messages.sendMedia({
2478
+ peer,
2479
+ random_id: randomId,
2480
+ silent,
2481
+ noforwards,
2482
+ reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2483
+ send_as: sendAs,
2484
+ reply_markup: replyMarkup,
2485
+ media: new types.InputMediaContact({
2486
+ phone_number: number,
2487
+ first_name: firstName,
2488
+ last_name: params?.lastName ?? "",
2489
+ vcard: params?.vcard ?? "",
2490
+ }),
2491
+ message: "",
2492
+ });
2493
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2494
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "contact");
2495
+ }
2496
+ /**
2497
+ * Send a dice.
2498
+ *
2499
+ * @method
2500
+ * @param chatId The chat to send the dice to.
2501
+ */
2502
+ async sendDice(chatId, params) {
2503
+ const peer = await this.getInputPeer(chatId);
2504
+ const randomId = getRandomId();
2505
+ const silent = params?.disableNotification ? true : undefined;
2506
+ const noforwards = params?.protectContent ? true : undefined;
2507
+ const replyToMsgId = params?.replyToMessageId;
2508
+ const topMsgId = params?.messageThreadId;
2509
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2510
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2511
+ const result = await this.api.messages.sendMedia({
2512
+ peer,
2513
+ random_id: randomId,
2514
+ silent,
2515
+ noforwards,
2516
+ reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2517
+ send_as: sendAs,
2518
+ reply_markup: replyMarkup,
2519
+ media: new types.InputMediaDice({
2520
+ emoticon: params?.emoji ?? "🎲",
2521
+ }),
2522
+ message: "",
2523
+ });
2524
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2525
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2526
+ }
2527
+ /**
2528
+ * Send a venue.
2529
+ *
2530
+ * @method
2531
+ * @param chatId The chat to send the venue to.
2532
+ * @param latitude The latitude of the venue.
2533
+ * @param longitude The longitude of the venue.
2534
+ * @param title The title of the venue.
2535
+ * @param address The written address of the venue.
2536
+ */
2537
+ async sendVenue(chatId, latitude, longitude, title, address, params) {
2538
+ const peer = await this.getInputPeer(chatId);
2539
+ const randomId = getRandomId();
2540
+ const silent = params?.disableNotification ? true : undefined;
2541
+ const noforwards = params?.protectContent ? true : undefined;
2542
+ const replyToMsgId = params?.replyToMessageId;
2543
+ const topMsgId = params?.messageThreadId;
2544
+ const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
2545
+ const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
2546
+ const result = await this.api.messages.sendMedia({
2547
+ peer,
2548
+ random_id: randomId,
2549
+ silent,
2550
+ noforwards,
2551
+ reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
2552
+ send_as: sendAs,
2553
+ reply_markup: replyMarkup,
2554
+ media: new types.InputMediaVenue({
2555
+ geo_point: new types.InputGeoPoint({
2556
+ lat: latitude,
2557
+ long: longitude,
2558
+ }),
2559
+ title,
2560
+ address,
2561
+ venue_id: params?.foursquareId ?? "",
2562
+ venue_type: params?.foursquareType ?? "",
2563
+ provider: "foursquare",
2564
+ }),
2565
+ message: "",
2566
+ });
2567
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
2568
+ return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
2569
+ }
2302
2570
  /**
2303
2571
  * Get network statistics. This might not always be available.
2304
2572
  *
@@ -2322,7 +2590,7 @@ export class Client extends ClientAbstract {
2322
2590
  return { messages, cdn };
2323
2591
  }
2324
2592
  /**
2325
- * Get chats from a chat list.
2593
+ * Get chats from a chat list. User-only.
2326
2594
  *
2327
2595
  * @method
2328
2596
  */
@@ -2425,7 +2693,7 @@ export class Client extends ClientAbstract {
2425
2693
  }
2426
2694
  }
2427
2695
  /**
2428
- * Get chat history.
2696
+ * Get chat history. User-only.
2429
2697
  *
2430
2698
  * @param chatId The identifier of the chat to get its history.
2431
2699
  * @method
@@ -2742,6 +3010,40 @@ async function _Client_setMyInfo(info) {
2742
3010
  entities: captionEntities,
2743
3011
  });
2744
3012
  return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
3013
+ }, _Client_sendDocumentInner = async function _Client_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = false) {
3014
+ let media = null;
3015
+ const spoiler = params?.hasSpoiler ? true : undefined;
3016
+ if (typeof document === "string") {
3017
+ const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, fileType);
3018
+ if (fileId != null) {
3019
+ media = new types.InputMediaDocument({
3020
+ id: new types.InputDocument(fileId),
3021
+ spoiler,
3022
+ });
3023
+ }
3024
+ }
3025
+ if (media == null) {
3026
+ if (typeof document === "string" && isHttpUrl(document)) {
3027
+ if (!urlSupported) {
3028
+ throw new Error("URL not supported");
3029
+ }
3030
+ media = new types.InputMediaDocumentExternal({ url: document, spoiler });
3031
+ }
3032
+ else {
3033
+ const [contents, fileName_] = await getFileContents(document);
3034
+ const fileName = params?.fileName ?? fileName_;
3035
+ const mimeType = params?.mimeType ?? contentType(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
3036
+ const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
3037
+ media = new types.InputMediaUploadedDocument({
3038
+ file,
3039
+ spoiler,
3040
+ attributes: [new types.DocumentAttributeFilename({ file_name: fileName }), ...otherAttribs],
3041
+ mime_type: mimeType,
3042
+ });
3043
+ }
3044
+ }
3045
+ const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
3046
+ return message;
2745
3047
  }, _Client_sendChatUpdate = async function _Client_sendChatUpdate(chatId, added) {
2746
3048
  try {
2747
3049
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertUser).call(this, "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.130",
3
+ "version": "0.1.131",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
6
  export declare const LAYER = 167;
7
- export declare const APP_VERSION = "MTKruto 0.1.130";
7
+ export declare const APP_VERSION = "MTKruto 0.1.131";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -79,7 +79,7 @@ exports.PUBLIC_KEYS = Object.freeze([
79
79
  ]);
80
80
  exports.INITIAL_DC = "2";
81
81
  exports.LAYER = 167;
82
- exports.APP_VERSION = "MTKruto 0.1.130";
82
+ exports.APP_VERSION = "MTKruto 0.1.131";
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" ? "en" : navigator.language.split("-")[0];