@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.
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/3_types.d.ts +363 -3
- package/esm/client/5_client.d.ts +97 -3
- package/esm/client/5_client.js +335 -33
- package/package.json +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/3_types.d.ts +363 -3
- package/script/client/5_client.d.ts +97 -3
- package/script/client/5_client.js +335 -33
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
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;
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Client = exports.ConnectionError = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
|
|
16
16
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -231,6 +231,51 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
231
231
|
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
232
232
|
return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
233
233
|
},
|
|
234
|
+
replyContact: (firstName, number, params) => {
|
|
235
|
+
const effectiveMessage = mustGetMsg();
|
|
236
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
237
|
+
return this.sendContact(effectiveMessage.chat.id, firstName, number, { ...params, replyToMessageId });
|
|
238
|
+
},
|
|
239
|
+
replyLocation: (latitude, longitude, params) => {
|
|
240
|
+
const effectiveMessage = mustGetMsg();
|
|
241
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
242
|
+
return this.sendLocation(effectiveMessage.chat.id, latitude, longitude, { ...params, replyToMessageId });
|
|
243
|
+
},
|
|
244
|
+
replyDice: (params) => {
|
|
245
|
+
const effectiveMessage = mustGetMsg();
|
|
246
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
247
|
+
return this.sendDice(effectiveMessage.chat.id, { ...params, replyToMessageId });
|
|
248
|
+
},
|
|
249
|
+
replyVenue: (latitude, longitude, title, address, params) => {
|
|
250
|
+
const effectiveMessage = mustGetMsg();
|
|
251
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
252
|
+
return this.sendVenue(effectiveMessage.chat.id, latitude, longitude, title, address, { ...params, replyToMessageId });
|
|
253
|
+
},
|
|
254
|
+
replyVideo: (document, params) => {
|
|
255
|
+
const effectiveMessage = mustGetMsg();
|
|
256
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
257
|
+
return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
258
|
+
},
|
|
259
|
+
replyAnimation: (document, params) => {
|
|
260
|
+
const effectiveMessage = mustGetMsg();
|
|
261
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
262
|
+
return this.sendAnimation(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
263
|
+
},
|
|
264
|
+
replyVoice: (document, params) => {
|
|
265
|
+
const effectiveMessage = mustGetMsg();
|
|
266
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
267
|
+
return this.sendVoice(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
268
|
+
},
|
|
269
|
+
replyAudio: (document, params) => {
|
|
270
|
+
const effectiveMessage = mustGetMsg();
|
|
271
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
272
|
+
return this.sendAudio(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
273
|
+
},
|
|
274
|
+
replyVideoNote: (videoNote, params) => {
|
|
275
|
+
const effectiveMessage = mustGetMsg();
|
|
276
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
277
|
+
return this.sendVideoNote(effectiveMessage.chat.id, videoNote, { ...params, replyToMessageId });
|
|
278
|
+
},
|
|
234
279
|
delete: () => {
|
|
235
280
|
const effectiveMessage = mustGetMsg();
|
|
236
281
|
return this.deleteMessage(effectiveMessage.chat.id, effectiveMessage.id);
|
|
@@ -1663,7 +1708,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1663
1708
|
break;
|
|
1664
1709
|
}
|
|
1665
1710
|
case _3_types_js_1.FileType.Document:
|
|
1666
|
-
case _3_types_js_1.FileType.Sticker:
|
|
1711
|
+
case _3_types_js_1.FileType.Sticker:
|
|
1712
|
+
case _3_types_js_1.FileType.VideoNote:
|
|
1713
|
+
case _3_types_js_1.FileType.Video:
|
|
1714
|
+
case _3_types_js_1.FileType.Audio:
|
|
1715
|
+
case _3_types_js_1.FileType.Voice:
|
|
1716
|
+
case _3_types_js_1.FileType.Animation: {
|
|
1667
1717
|
if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
|
|
1668
1718
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
1669
1719
|
}
|
|
@@ -2273,37 +2323,255 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2273
2323
|
* @param document The document to send.
|
|
2274
2324
|
*/
|
|
2275
2325
|
async sendDocument(chatId, document, params) {
|
|
2276
|
-
|
|
2277
|
-
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
2278
|
-
if (typeof document === "string") {
|
|
2279
|
-
const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, _3_types_js_1.FileType.Document);
|
|
2280
|
-
if (fileId != null) {
|
|
2281
|
-
media = new _2_tl_js_1.types.InputMediaDocument({
|
|
2282
|
-
id: new _2_tl_js_1.types.InputDocument(fileId),
|
|
2283
|
-
spoiler,
|
|
2284
|
-
});
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
if (media == null) {
|
|
2288
|
-
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
2289
|
-
media = new _2_tl_js_1.types.InputMediaDocumentExternal({ url: document, spoiler });
|
|
2290
|
-
}
|
|
2291
|
-
else {
|
|
2292
|
-
const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document);
|
|
2293
|
-
const fileName = params?.fileName ?? fileName_;
|
|
2294
|
-
const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
|
|
2295
|
-
const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
2296
|
-
media = new _2_tl_js_1.types.InputMediaUploadedDocument({
|
|
2297
|
-
file,
|
|
2298
|
-
spoiler,
|
|
2299
|
-
attributes: [new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: fileName })],
|
|
2300
|
-
mime_type: mimeType,
|
|
2301
|
-
});
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
|
|
2326
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, document, params, _3_types_js_1.FileType.Document, []);
|
|
2305
2327
|
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
|
|
2306
2328
|
}
|
|
2329
|
+
/**
|
|
2330
|
+
* Send a video.
|
|
2331
|
+
*
|
|
2332
|
+
* @method
|
|
2333
|
+
* @param chatId The chat to send the video to.
|
|
2334
|
+
* @param video The video to send.
|
|
2335
|
+
*/
|
|
2336
|
+
async sendVideo(chatId, video, params) {
|
|
2337
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, video, params, _3_types_js_1.FileType.Video, [
|
|
2338
|
+
new _2_tl_js_1.types.DocumentAttributeVideo({
|
|
2339
|
+
supports_streaming: params?.supportsStreaming ? true : undefined,
|
|
2340
|
+
w: params?.width ?? 0,
|
|
2341
|
+
h: params?.height ?? 0,
|
|
2342
|
+
duration: params?.duration ?? 0,
|
|
2343
|
+
}),
|
|
2344
|
+
]);
|
|
2345
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "video");
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Send an animation.
|
|
2349
|
+
*
|
|
2350
|
+
* @method
|
|
2351
|
+
* @param chatId The chat to send the animation to.
|
|
2352
|
+
* @param animation The animation to send.
|
|
2353
|
+
*/
|
|
2354
|
+
async sendAnimation(chatId, animation, params) {
|
|
2355
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, animation, params, _3_types_js_1.FileType.Animation, [
|
|
2356
|
+
new _2_tl_js_1.types.DocumentAttributeAnimated(),
|
|
2357
|
+
new _2_tl_js_1.types.DocumentAttributeVideo({
|
|
2358
|
+
supports_streaming: true,
|
|
2359
|
+
w: params?.width ?? 0,
|
|
2360
|
+
h: params?.height ?? 0,
|
|
2361
|
+
duration: params?.duration ?? 0,
|
|
2362
|
+
}),
|
|
2363
|
+
]);
|
|
2364
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "animation");
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Send a voice message.
|
|
2368
|
+
*
|
|
2369
|
+
* @method
|
|
2370
|
+
* @param chatId The chat to send the voice message to.
|
|
2371
|
+
* @param voice The voice to send.
|
|
2372
|
+
*/
|
|
2373
|
+
async sendVoice(chatId, voice, params) {
|
|
2374
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, voice, params, _3_types_js_1.FileType.Voice, [
|
|
2375
|
+
new _2_tl_js_1.types.DocumentAttributeAudio({
|
|
2376
|
+
voice: true,
|
|
2377
|
+
duration: params?.duration ?? 0,
|
|
2378
|
+
}),
|
|
2379
|
+
]);
|
|
2380
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "voice");
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Send an audio file.
|
|
2384
|
+
*
|
|
2385
|
+
* @method
|
|
2386
|
+
* @param chatId The chat to send the audio file to.
|
|
2387
|
+
* @param audio The audio to send.
|
|
2388
|
+
*/
|
|
2389
|
+
async sendAudio(chatId, audio, params) {
|
|
2390
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_1.FileType.Audio, [
|
|
2391
|
+
new _2_tl_js_1.types.DocumentAttributeAudio({
|
|
2392
|
+
duration: params?.duration ?? 0,
|
|
2393
|
+
performer: params?.performer,
|
|
2394
|
+
title: params?.title,
|
|
2395
|
+
}),
|
|
2396
|
+
]);
|
|
2397
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "audio");
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Send a video note.
|
|
2401
|
+
*
|
|
2402
|
+
* @method
|
|
2403
|
+
* @param chatId The chat to send the video note to.
|
|
2404
|
+
* @param videoNote The video note to send.
|
|
2405
|
+
*/
|
|
2406
|
+
async sendVideoNote(chatId, audio, params) {
|
|
2407
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendDocumentInner).call(this, chatId, audio, params, _3_types_js_1.FileType.VideoNote, [
|
|
2408
|
+
new _2_tl_js_1.types.DocumentAttributeVideo({
|
|
2409
|
+
round_message: true,
|
|
2410
|
+
w: params?.length ?? 0,
|
|
2411
|
+
h: params?.length ?? 0,
|
|
2412
|
+
duration: params?.duration ?? 0,
|
|
2413
|
+
}),
|
|
2414
|
+
], false);
|
|
2415
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "videoNote");
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Send a location.
|
|
2419
|
+
*
|
|
2420
|
+
* @method
|
|
2421
|
+
* @param chatId The chat to send the location to.
|
|
2422
|
+
* @param latitude The location's latitude.
|
|
2423
|
+
* @param longitude The location's longitude.
|
|
2424
|
+
*/
|
|
2425
|
+
async sendLocation(chatId, latitude, longitude, params) {
|
|
2426
|
+
const peer = await this.getInputPeer(chatId);
|
|
2427
|
+
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
2428
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
2429
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
2430
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
2431
|
+
const topMsgId = params?.messageThreadId;
|
|
2432
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2433
|
+
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2434
|
+
const result = await this.api.messages.sendMedia({
|
|
2435
|
+
peer,
|
|
2436
|
+
random_id: randomId,
|
|
2437
|
+
silent,
|
|
2438
|
+
noforwards,
|
|
2439
|
+
reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2440
|
+
send_as: sendAs,
|
|
2441
|
+
reply_markup: replyMarkup,
|
|
2442
|
+
media: params?.livePeriod !== undefined
|
|
2443
|
+
? new _2_tl_js_1.types.InputMediaGeoLive({
|
|
2444
|
+
geo_point: new _2_tl_js_1.types.InputGeoPoint({
|
|
2445
|
+
lat: latitude,
|
|
2446
|
+
long: longitude,
|
|
2447
|
+
accuracy_radius: params?.horizontalAccuracy,
|
|
2448
|
+
}),
|
|
2449
|
+
heading: params?.heading,
|
|
2450
|
+
period: params.livePeriod,
|
|
2451
|
+
proximity_notification_radius: params?.proximityAlertRadius,
|
|
2452
|
+
})
|
|
2453
|
+
: new _2_tl_js_1.types.InputMediaGeoPoint({
|
|
2454
|
+
geo_point: new _2_tl_js_1.types.InputGeoPoint({
|
|
2455
|
+
lat: latitude,
|
|
2456
|
+
long: longitude,
|
|
2457
|
+
accuracy_radius: params?.horizontalAccuracy,
|
|
2458
|
+
}),
|
|
2459
|
+
}),
|
|
2460
|
+
message: "",
|
|
2461
|
+
});
|
|
2462
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2463
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "location");
|
|
2464
|
+
}
|
|
2465
|
+
/**
|
|
2466
|
+
* Send a contact.
|
|
2467
|
+
*
|
|
2468
|
+
* @method
|
|
2469
|
+
* @param chatId The chat to send the contact to.
|
|
2470
|
+
* @param firstName The contact's first name.
|
|
2471
|
+
* @param number The contact's phone number.
|
|
2472
|
+
*/
|
|
2473
|
+
async sendContact(chatId, firstName, number, params) {
|
|
2474
|
+
const peer = await this.getInputPeer(chatId);
|
|
2475
|
+
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
2476
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
2477
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
2478
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
2479
|
+
const topMsgId = params?.messageThreadId;
|
|
2480
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2481
|
+
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2482
|
+
const result = await this.api.messages.sendMedia({
|
|
2483
|
+
peer,
|
|
2484
|
+
random_id: randomId,
|
|
2485
|
+
silent,
|
|
2486
|
+
noforwards,
|
|
2487
|
+
reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2488
|
+
send_as: sendAs,
|
|
2489
|
+
reply_markup: replyMarkup,
|
|
2490
|
+
media: new _2_tl_js_1.types.InputMediaContact({
|
|
2491
|
+
phone_number: number,
|
|
2492
|
+
first_name: firstName,
|
|
2493
|
+
last_name: params?.lastName ?? "",
|
|
2494
|
+
vcard: params?.vcard ?? "",
|
|
2495
|
+
}),
|
|
2496
|
+
message: "",
|
|
2497
|
+
});
|
|
2498
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2499
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "contact");
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Send a dice.
|
|
2503
|
+
*
|
|
2504
|
+
* @method
|
|
2505
|
+
* @param chatId The chat to send the dice to.
|
|
2506
|
+
*/
|
|
2507
|
+
async sendDice(chatId, params) {
|
|
2508
|
+
const peer = await this.getInputPeer(chatId);
|
|
2509
|
+
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
2510
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
2511
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
2512
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
2513
|
+
const topMsgId = params?.messageThreadId;
|
|
2514
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2515
|
+
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2516
|
+
const result = await this.api.messages.sendMedia({
|
|
2517
|
+
peer,
|
|
2518
|
+
random_id: randomId,
|
|
2519
|
+
silent,
|
|
2520
|
+
noforwards,
|
|
2521
|
+
reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2522
|
+
send_as: sendAs,
|
|
2523
|
+
reply_markup: replyMarkup,
|
|
2524
|
+
media: new _2_tl_js_1.types.InputMediaDice({
|
|
2525
|
+
emoticon: params?.emoji ?? "🎲",
|
|
2526
|
+
}),
|
|
2527
|
+
message: "",
|
|
2528
|
+
});
|
|
2529
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2530
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Send a venue.
|
|
2534
|
+
*
|
|
2535
|
+
* @method
|
|
2536
|
+
* @param chatId The chat to send the venue to.
|
|
2537
|
+
* @param latitude The latitude of the venue.
|
|
2538
|
+
* @param longitude The longitude of the venue.
|
|
2539
|
+
* @param title The title of the venue.
|
|
2540
|
+
* @param address The written address of the venue.
|
|
2541
|
+
*/
|
|
2542
|
+
async sendVenue(chatId, latitude, longitude, title, address, params) {
|
|
2543
|
+
const peer = await this.getInputPeer(chatId);
|
|
2544
|
+
const randomId = (0, _1_utilities_js_1.getRandomId)();
|
|
2545
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
2546
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
2547
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
2548
|
+
const topMsgId = params?.messageThreadId;
|
|
2549
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2550
|
+
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2551
|
+
const result = await this.api.messages.sendMedia({
|
|
2552
|
+
peer,
|
|
2553
|
+
random_id: randomId,
|
|
2554
|
+
silent,
|
|
2555
|
+
noforwards,
|
|
2556
|
+
reply_to: replyToMsgId !== undefined ? new _2_tl_js_1.types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2557
|
+
send_as: sendAs,
|
|
2558
|
+
reply_markup: replyMarkup,
|
|
2559
|
+
media: new _2_tl_js_1.types.InputMediaVenue({
|
|
2560
|
+
geo_point: new _2_tl_js_1.types.InputGeoPoint({
|
|
2561
|
+
lat: latitude,
|
|
2562
|
+
long: longitude,
|
|
2563
|
+
}),
|
|
2564
|
+
title,
|
|
2565
|
+
address,
|
|
2566
|
+
venue_id: params?.foursquareId ?? "",
|
|
2567
|
+
venue_type: params?.foursquareType ?? "",
|
|
2568
|
+
provider: "foursquare",
|
|
2569
|
+
}),
|
|
2570
|
+
message: "",
|
|
2571
|
+
});
|
|
2572
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2573
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "dice");
|
|
2574
|
+
}
|
|
2307
2575
|
/**
|
|
2308
2576
|
* Get network statistics. This might not always be available.
|
|
2309
2577
|
*
|
|
@@ -2327,7 +2595,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2327
2595
|
return { messages, cdn };
|
|
2328
2596
|
}
|
|
2329
2597
|
/**
|
|
2330
|
-
* Get chats from a chat list.
|
|
2598
|
+
* Get chats from a chat list. User-only.
|
|
2331
2599
|
*
|
|
2332
2600
|
* @method
|
|
2333
2601
|
*/
|
|
@@ -2430,7 +2698,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
2430
2698
|
}
|
|
2431
2699
|
}
|
|
2432
2700
|
/**
|
|
2433
|
-
* Get chat history.
|
|
2701
|
+
* Get chat history. User-only.
|
|
2434
2702
|
*
|
|
2435
2703
|
* @param chatId The identifier of the chat to get its history.
|
|
2436
2704
|
* @method
|
|
@@ -2748,6 +3016,40 @@ async function _Client_setMyInfo(info) {
|
|
|
2748
3016
|
entities: captionEntities,
|
|
2749
3017
|
});
|
|
2750
3018
|
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
3019
|
+
}, _Client_sendDocumentInner = async function _Client_sendDocumentInner(chatId, document, params, fileType, otherAttribs, urlSupported = false) {
|
|
3020
|
+
let media = null;
|
|
3021
|
+
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
3022
|
+
if (typeof document === "string") {
|
|
3023
|
+
const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, fileType);
|
|
3024
|
+
if (fileId != null) {
|
|
3025
|
+
media = new _2_tl_js_1.types.InputMediaDocument({
|
|
3026
|
+
id: new _2_tl_js_1.types.InputDocument(fileId),
|
|
3027
|
+
spoiler,
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
if (media == null) {
|
|
3032
|
+
if (typeof document === "string" && (0, _0_utilities_js_1.isHttpUrl)(document)) {
|
|
3033
|
+
if (!urlSupported) {
|
|
3034
|
+
throw new Error("URL not supported");
|
|
3035
|
+
}
|
|
3036
|
+
media = new _2_tl_js_1.types.InputMediaDocumentExternal({ url: document, spoiler });
|
|
3037
|
+
}
|
|
3038
|
+
else {
|
|
3039
|
+
const [contents, fileName_] = await (0, _0_utilities_js_1.getFileContents)(document);
|
|
3040
|
+
const fileName = params?.fileName ?? fileName_;
|
|
3041
|
+
const mimeType = params?.mimeType ?? (0, _0_deps_js_1.contentType)(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
|
|
3042
|
+
const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
3043
|
+
media = new _2_tl_js_1.types.InputMediaUploadedDocument({
|
|
3044
|
+
file,
|
|
3045
|
+
spoiler,
|
|
3046
|
+
attributes: [new _2_tl_js_1.types.DocumentAttributeFilename({ file_name: fileName }), ...otherAttribs],
|
|
3047
|
+
mime_type: mimeType,
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
|
|
3052
|
+
return message;
|
|
2751
3053
|
}, _Client_sendChatUpdate = async function _Client_sendChatUpdate(chatId, added) {
|
|
2752
3054
|
try {
|
|
2753
3055
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_assertUser).call(this, "");
|