@mtkruto/node 0.1.123 → 0.1.125
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/0_deps.d.ts +1 -0
- package/esm/0_deps.js +1 -0
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/1_client_abstract.d.ts +1 -1
- package/esm/client/3_types.d.ts +56 -0
- package/esm/client/5_client.d.ts +17 -2
- package/esm/client/5_client.js +165 -57
- package/esm/connection/0_connection.d.ts +4 -0
- package/esm/connection/0_connection.js +6 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.js +33 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.js +60 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.js +61 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.js +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8555 -0
- package/esm/storage/0_storage.d.ts +1 -0
- package/esm/storage/1_storage_indexed_db.d.ts +4 -3
- package/esm/storage/1_storage_indexed_db.js +17 -8
- package/esm/storage/1_storage_local_storage.d.ts +2 -2
- package/esm/storage/1_storage_local_storage.js +3 -0
- package/esm/storage/1_storage_memory.d.ts +1 -0
- package/esm/storage/1_storage_memory.js +3 -0
- package/esm/storage/1_storage_session_storage.d.ts +1 -0
- package/esm/storage/1_storage_session_storage.js +3 -0
- package/esm/transport/0_transport.d.ts +1 -1
- package/esm/transport/0_transport.js +0 -6
- package/esm/transport/1_transport_abridged.d.ts +1 -0
- package/esm/transport/1_transport_abridged.js +9 -5
- package/esm/transport/1_transport_intermediate.d.ts +1 -0
- package/esm/transport/1_transport_intermediate.js +8 -4
- package/esm/types/1_chat.d.ts +2 -15
- package/esm/types/1_chat.js +3 -14
- package/esm/types/1_user.js +4 -2
- package/esm/types/3_message.d.ts +2 -2
- package/esm/types/3_message.js +6 -6
- package/esm/utilities/{0_base64.js → 1_base64.js} +2 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -0
- package/script/0_deps.js +3 -1
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/1_client_abstract.d.ts +1 -1
- package/script/client/3_types.d.ts +56 -0
- package/script/client/5_client.d.ts +17 -2
- package/script/client/5_client.js +164 -56
- package/script/connection/0_connection.d.ts +4 -0
- package/script/connection/0_connection.js +6 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.js +39 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.js +132 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.js +64 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.js +65 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.js +41 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +126 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8557 -0
- package/script/storage/0_storage.d.ts +1 -0
- package/script/storage/1_storage_indexed_db.d.ts +4 -3
- package/script/storage/1_storage_indexed_db.js +17 -8
- package/script/storage/1_storage_local_storage.d.ts +2 -2
- package/script/storage/1_storage_local_storage.js +3 -0
- package/script/storage/1_storage_memory.d.ts +1 -0
- package/script/storage/1_storage_memory.js +3 -0
- package/script/storage/1_storage_session_storage.d.ts +1 -0
- package/script/storage/1_storage_session_storage.js +3 -0
- package/script/transport/0_transport.d.ts +1 -1
- package/script/transport/0_transport.js +0 -6
- package/script/transport/1_transport_abridged.d.ts +1 -0
- package/script/transport/1_transport_abridged.js +9 -5
- package/script/transport/1_transport_intermediate.d.ts +1 -0
- package/script/transport/1_transport_intermediate.js +8 -4
- package/script/types/1_chat.d.ts +2 -15
- package/script/types/1_chat.js +3 -14
- package/script/types/1_user.js +4 -2
- package/script/types/3_message.d.ts +2 -2
- package/script/types/3_message.js +6 -6
- package/script/utilities/{0_base64.js → 1_base64.js} +2 -1
- /package/esm/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
- /package/script/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
package/esm/0_deps.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./deps/deno.land/std@0.208.0/assert/mod.js";
|
|
2
2
|
export * as path from "./deps/deno.land/std@0.208.0/path/mod.js";
|
|
3
3
|
export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.208.0/encoding/base64.js";
|
|
4
|
+
export { contentType } from "./deps/deno.land/std@0.208.0/media_types/content_type.js";
|
|
4
5
|
export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
|
|
5
6
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
|
|
6
7
|
export { Mutex, type MutexInterface } from "async-mutex";
|
package/esm/0_deps.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./deps/deno.land/std@0.208.0/assert/mod.js";
|
|
2
2
|
export * as path from "./deps/deno.land/std@0.208.0/path/mod.js";
|
|
3
3
|
export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.208.0/encoding/base64.js";
|
|
4
|
+
export { contentType } from "./deps/deno.land/std@0.208.0/media_types/content_type.js";
|
|
4
5
|
export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
|
|
5
6
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
|
|
6
7
|
export { Mutex } from "async-mutex";
|
package/esm/1_utilities.d.ts
CHANGED
package/esm/1_utilities.js
CHANGED
package/esm/4_constants.d.ts
CHANGED
|
@@ -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.
|
|
7
|
+
export declare const APP_VERSION = "MTKruto 0.1.125";
|
|
8
8
|
export declare const DEVICE_MODEL: string;
|
|
9
9
|
export declare const LANG_CODE: string;
|
|
10
10
|
export declare const LANG_PACK = "";
|
package/esm/4_constants.js
CHANGED
|
@@ -53,7 +53,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
53
53
|
]);
|
|
54
54
|
export const INITIAL_DC = "2";
|
|
55
55
|
export const LAYER = 167;
|
|
56
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
56
|
+
export const APP_VERSION = "MTKruto 0.1.125";
|
|
57
57
|
// @ts-ignore: lib
|
|
58
58
|
export const 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;
|
|
59
59
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -17,7 +17,7 @@ export interface ClientAbstractParams {
|
|
|
17
17
|
export declare abstract class ClientAbstract {
|
|
18
18
|
#private;
|
|
19
19
|
protected readonly initialDc: DC;
|
|
20
|
-
protected
|
|
20
|
+
protected transportProvider: TransportProvider;
|
|
21
21
|
protected readonly cdn: boolean;
|
|
22
22
|
protected transport?: ReturnType<TransportProvider>;
|
|
23
23
|
constructor(params?: ClientAbstractParams);
|
package/esm/client/3_types.d.ts
CHANGED
|
@@ -287,6 +287,54 @@ export interface SendPhotoParams {
|
|
|
287
287
|
*/
|
|
288
288
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
289
289
|
}
|
|
290
|
+
export interface SendDocumentParams {
|
|
291
|
+
/** The file name to assign. */
|
|
292
|
+
fileName?: string;
|
|
293
|
+
/** The mime type to assign. */
|
|
294
|
+
mimeType?: string;
|
|
295
|
+
/** Size of each upload chunk in bytes. */
|
|
296
|
+
chunkSize?: number;
|
|
297
|
+
/** Upload abort signal. */
|
|
298
|
+
signal?: AbortSignal | null;
|
|
299
|
+
/** The caption of the document. */
|
|
300
|
+
caption?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The caption's entities.
|
|
303
|
+
*/
|
|
304
|
+
captionEntities?: MessageEntity[];
|
|
305
|
+
/**
|
|
306
|
+
* The parse mode to use for the caption. If not provided, the default parse mode will be used.
|
|
307
|
+
*/
|
|
308
|
+
parseMode?: ParseMode;
|
|
309
|
+
/**
|
|
310
|
+
* Whether to mark the document as a spoiler.
|
|
311
|
+
*/
|
|
312
|
+
hasSpoiler?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Whether to send the message in a silent way without making a sound on the recipients' clients.
|
|
315
|
+
*/
|
|
316
|
+
disableNotification?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Whether to protect the contents of the message from copying and forwarding.
|
|
319
|
+
*/
|
|
320
|
+
protectContent?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* The identifier of a message to reply to.
|
|
323
|
+
*/
|
|
324
|
+
replyToMessageId?: number;
|
|
325
|
+
/**
|
|
326
|
+
* The identifier of a thread to send the message to.
|
|
327
|
+
*/
|
|
328
|
+
messageThreadId?: number;
|
|
329
|
+
/**
|
|
330
|
+
* The identifier of the chat to send the message on behalf of. User-only.
|
|
331
|
+
*/
|
|
332
|
+
sendAs?: ChatID;
|
|
333
|
+
/**
|
|
334
|
+
* The reply markup of the message. Bot-only.
|
|
335
|
+
*/
|
|
336
|
+
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
337
|
+
}
|
|
290
338
|
export type ConnectionState = "notConnected" | "updating" | "ready";
|
|
291
339
|
export type AuthorizationState = {
|
|
292
340
|
authorized: boolean;
|
|
@@ -324,4 +372,12 @@ export type FilterUpdate<Update extends Update_, Type extends keyof Update_, Fie
|
|
|
324
372
|
[Field_ in Field]-?: Field extends keyof TypeType ? NonNullable<TypeType[Field]> : never;
|
|
325
373
|
};
|
|
326
374
|
};
|
|
375
|
+
export interface NetworkStatisticsEntry {
|
|
376
|
+
sent: number;
|
|
377
|
+
received: number;
|
|
378
|
+
}
|
|
379
|
+
export interface NetworkStatistics {
|
|
380
|
+
messages: NetworkStatisticsEntry;
|
|
381
|
+
cdn: NetworkStatisticsEntry;
|
|
382
|
+
}
|
|
327
383
|
export {};
|
package/esm/client/5_client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BotCommand, CallbackQuery, ChatAction, ChatID, InlineQuery, InlineQuery
|
|
|
6
6
|
import { Migrate } from "../4_errors.js";
|
|
7
7
|
import { FileSource, With } from "./0_utilities.js";
|
|
8
8
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
9
|
-
import { AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, ClientParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, GetMyCommandsParams, InvokeErrorHandler, ReplyParams, SendMessageParams, SendPhotoParams, SendPollParams, SetMyCommandsParams, Update, UploadParams } from "./3_types.js";
|
|
9
|
+
import { AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, ClientParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, GetMyCommandsParams, InvokeErrorHandler, NetworkStatistics, ReplyParams, SendDocumentParams, SendMessageParams, SendPhotoParams, SendPollParams, SetMyCommandsParams, Update, UploadParams } from "./3_types.js";
|
|
10
10
|
import { Composer, Middleware } from "./4_composer.js";
|
|
11
11
|
declare const getEntity: unique symbol;
|
|
12
12
|
declare const getStickerSetName: unique symbol;
|
|
@@ -43,6 +43,8 @@ export interface Context extends Update {
|
|
|
43
43
|
replyPoll: (question: string, options: [string, string, ...string[]], params?: Omit<SendPollParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "poll">>;
|
|
44
44
|
/** Reply the received message with a photo. */
|
|
45
45
|
replyPhoto: (photo: FileSource, params?: Omit<SendPhotoParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "photo">>;
|
|
46
|
+
/** Reply the received message with a document. */
|
|
47
|
+
replyDocument: (document: FileSource, params?: Omit<SendDocumentParams, "replyToMessageId"> & ReplyParams) => Promise<With<Message, "document">>;
|
|
46
48
|
/** Delete the received message. */
|
|
47
49
|
delete: () => Promise<void>;
|
|
48
50
|
/** Forward the received message. */
|
|
@@ -150,7 +152,6 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
150
152
|
* Alias for `invoke` with its second parameter being `true`.
|
|
151
153
|
*/
|
|
152
154
|
send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
|
|
153
|
-
checkGap(pts: number, ptsCount: number): Promise<void>;
|
|
154
155
|
getUserAccessHash(userId: bigint): Promise<bigint>;
|
|
155
156
|
getInputPeer(id: ChatID): Promise<import("../tl/2_types.js").InputPeerChat_ | import("../tl/2_types.js").InputPeerUser_ | import("../tl/2_types.js").InputPeerChannel_>;
|
|
156
157
|
private [getEntity];
|
|
@@ -379,5 +380,19 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
379
380
|
* @param photo The photo to send.
|
|
380
381
|
*/
|
|
381
382
|
sendPhoto(chatId: ChatID, photo: FileSource, params?: SendPhotoParams): Promise<With<Message, "photo">>;
|
|
383
|
+
/**
|
|
384
|
+
* Send a document.
|
|
385
|
+
*
|
|
386
|
+
* @method
|
|
387
|
+
* @param chatId The chat to send the document to.
|
|
388
|
+
* @param document The document to send.
|
|
389
|
+
*/
|
|
390
|
+
sendDocument(chatId: ChatID, document: FileSource, params?: SendDocumentParams): Promise<With<Message, "document">>;
|
|
391
|
+
/**
|
|
392
|
+
* Get network statistics. This might not always be available.
|
|
393
|
+
*
|
|
394
|
+
* @method
|
|
395
|
+
*/
|
|
396
|
+
getNetworkStatistics(): Promise<NetworkStatistics>;
|
|
382
397
|
}
|
|
383
398
|
export {};
|
package/esm/client/5_client.js
CHANGED
|
@@ -9,8 +9,8 @@ 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_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _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;
|
|
13
|
-
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
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;
|
|
13
|
+
import { contentType, debug, 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";
|
|
16
16
|
import { StorageMemory } from "../3_storage.js";
|
|
@@ -220,6 +220,11 @@ export class Client extends ClientAbstract {
|
|
|
220
220
|
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
221
221
|
return this.sendPhoto(effectiveMessage.chat.id, photo, { ...params, replyToMessageId });
|
|
222
222
|
},
|
|
223
|
+
replyDocument: (document, params) => {
|
|
224
|
+
const effectiveMessage = mustGetMsg();
|
|
225
|
+
const replyToMessageId = getReplyToMessageId(params?.quote, effectiveMessage);
|
|
226
|
+
return this.sendDocument(effectiveMessage.chat.id, document, { ...params, replyToMessageId });
|
|
227
|
+
},
|
|
223
228
|
delete: () => {
|
|
224
229
|
const effectiveMessage = mustGetMsg();
|
|
225
230
|
return this.deleteMessage(effectiveMessage.chat.id, effectiveMessage.id);
|
|
@@ -305,6 +310,7 @@ export class Client extends ClientAbstract {
|
|
|
305
310
|
_Client_connectionInited.set(this, false);
|
|
306
311
|
_Client_lastPropagatedAuthorizationState.set(this, null);
|
|
307
312
|
_Client_selfId.set(this, null);
|
|
313
|
+
_Client_pingLoopAbortSignal.set(this, null);
|
|
308
314
|
_Client_pingInterval.set(this, 60 * 1000); // 60 seconds
|
|
309
315
|
_Client_pingLoopStarted.set(this, false);
|
|
310
316
|
_Client_autoStarted.set(this, false);
|
|
@@ -337,6 +343,7 @@ export class Client extends ClientAbstract {
|
|
|
337
343
|
});
|
|
338
344
|
_Client_handleUpdateQueue.set(this, new Queue("handleUpdate"));
|
|
339
345
|
_Client_processUpdatesQueue.set(this, new Queue("processUpdates"));
|
|
346
|
+
_Client_lastUpdates.set(this, new Date());
|
|
340
347
|
_Client_lastGetMe.set(this, null);
|
|
341
348
|
_Client_usernameResolver.set(this, async (v) => {
|
|
342
349
|
const inputPeer = await this.getInputPeer(v).then((v) => v[as](types.InputPeerUser));
|
|
@@ -356,16 +363,36 @@ export class Client extends ClientAbstract {
|
|
|
356
363
|
__classPrivateFieldSet(this, _Client_autoStart, params?.autoStart ?? true, "f");
|
|
357
364
|
__classPrivateFieldSet(this, _Client_ignoreOutgoing, params?.ignoreOutgoing ?? null, "f");
|
|
358
365
|
__classPrivateFieldSet(this, _Client_prefixes, params?.prefixes, "f");
|
|
366
|
+
const transportProvider = this.transportProvider;
|
|
367
|
+
this.transportProvider = (params) => {
|
|
368
|
+
const transport = transportProvider(params);
|
|
369
|
+
transport.connection.callback = {
|
|
370
|
+
read: async (count) => {
|
|
371
|
+
const key = params.cdn ? "netstat_cdn_read" : "netstat_messages_read";
|
|
372
|
+
await this.storage.incr([key], count);
|
|
373
|
+
},
|
|
374
|
+
write: async (count) => {
|
|
375
|
+
const key = params.cdn ? "netstat_cdn_write" : "netstat_messages_write";
|
|
376
|
+
await this.storage.incr([key], count);
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
return transport;
|
|
380
|
+
};
|
|
359
381
|
if (params?.defaultHandlers ?? true) {
|
|
360
382
|
this.on("connectionState", ({ connectionState }, next) => {
|
|
361
383
|
drop((async () => {
|
|
362
384
|
if (connectionState == "notConnected") {
|
|
385
|
+
if (!this.transport?.transport.initialized) {
|
|
386
|
+
d("not reconnecting");
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
363
389
|
let delay = 5;
|
|
364
390
|
while (!this.connected) {
|
|
365
391
|
d("reconnecting");
|
|
366
392
|
try {
|
|
367
393
|
await this.connect();
|
|
368
394
|
d("reconnected");
|
|
395
|
+
drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "reconnect"));
|
|
369
396
|
break;
|
|
370
397
|
}
|
|
371
398
|
catch (err) {
|
|
@@ -465,7 +492,7 @@ export class Client extends ClientAbstract {
|
|
|
465
492
|
release();
|
|
466
493
|
}
|
|
467
494
|
}
|
|
468
|
-
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
495
|
+
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortSignal = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
469
496
|
__classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
|
|
470
497
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), resolve);
|
|
471
498
|
});
|
|
@@ -493,9 +520,10 @@ export class Client extends ClientAbstract {
|
|
|
493
520
|
await this.reconnect(newDc);
|
|
494
521
|
d("migrated to DC%s", newDc);
|
|
495
522
|
}
|
|
496
|
-
disconnect() {
|
|
523
|
+
async disconnect() {
|
|
497
524
|
__classPrivateFieldSet(this, _Client_connectionInited, false, "f");
|
|
498
|
-
|
|
525
|
+
await super.disconnect();
|
|
526
|
+
__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f")?.abort();
|
|
499
527
|
}
|
|
500
528
|
/**
|
|
501
529
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
@@ -682,6 +710,7 @@ export class Client extends ClientAbstract {
|
|
|
682
710
|
await this.connect();
|
|
683
711
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initConnection).call(this);
|
|
684
712
|
if (!__classPrivateFieldGet(this, _Client_authKeyWasCreated, "f")) {
|
|
713
|
+
drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_fetchState).call(this, "start"));
|
|
685
714
|
return;
|
|
686
715
|
}
|
|
687
716
|
try {
|
|
@@ -703,12 +732,6 @@ export class Client extends ClientAbstract {
|
|
|
703
732
|
send(function_) {
|
|
704
733
|
return this.invoke(function_, true);
|
|
705
734
|
}
|
|
706
|
-
async checkGap(pts, ptsCount) {
|
|
707
|
-
const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
708
|
-
if (localState.pts + ptsCount < pts) {
|
|
709
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
735
|
async getUserAccessHash(userId) {
|
|
713
736
|
const users = await this.invoke(new functions.users.getUsers({ id: [new types.InputUser({ user_id: userId, access_hash: 0n })] }));
|
|
714
737
|
return users[0]?.[as](types.User).access_hash ?? 0n;
|
|
@@ -865,10 +888,19 @@ export class Client extends ClientAbstract {
|
|
|
865
888
|
UNREACHABLE();
|
|
866
889
|
}
|
|
867
890
|
}, _Client_pingLoop = async function _Client_pingLoop() {
|
|
891
|
+
__classPrivateFieldSet(this, _Client_pingLoopAbortSignal, new AbortController(), "f");
|
|
868
892
|
while (this.connected) {
|
|
869
|
-
await new Promise((r) => setTimeout(r, __classPrivateFieldGet(this, _Client_pingInterval, "f")));
|
|
870
893
|
try {
|
|
871
|
-
await
|
|
894
|
+
await new Promise((resolve, reject) => {
|
|
895
|
+
setTimeout(resolve, __classPrivateFieldGet(this, _Client_pingInterval, "f"));
|
|
896
|
+
__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f").signal.onabort = () => {
|
|
897
|
+
reject(__classPrivateFieldGet(this, _Client_pingLoopAbortSignal, "f")?.signal.reason);
|
|
898
|
+
};
|
|
899
|
+
});
|
|
900
|
+
await this.invoke(new functions.ping_delay_disconnect({ ping_id: getRandomId(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / 1000 + 15 }));
|
|
901
|
+
if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * 60 * 1000) {
|
|
902
|
+
drop(__classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "lastUpdates"));
|
|
903
|
+
}
|
|
872
904
|
}
|
|
873
905
|
catch (err) {
|
|
874
906
|
d("ping loop error: %o", err);
|
|
@@ -970,6 +1002,11 @@ export class Client extends ClientAbstract {
|
|
|
970
1002
|
}
|
|
971
1003
|
}
|
|
972
1004
|
}
|
|
1005
|
+
}, _Client_checkGap = async function _Client_checkGap(pts, ptsCount) {
|
|
1006
|
+
const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
1007
|
+
if (localState.pts + ptsCount < pts) {
|
|
1008
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
1009
|
+
}
|
|
973
1010
|
}, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount) {
|
|
974
1011
|
let localPts = await this.storage.getChannelPts(channelId);
|
|
975
1012
|
if (!localPts) {
|
|
@@ -979,6 +1016,7 @@ export class Client extends ClientAbstract {
|
|
|
979
1016
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
|
|
980
1017
|
}
|
|
981
1018
|
}, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
|
|
1019
|
+
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
982
1020
|
/// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
|
|
983
1021
|
///
|
|
984
1022
|
/// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
|
|
@@ -1049,7 +1087,7 @@ export class Client extends ClientAbstract {
|
|
|
1049
1087
|
continue;
|
|
1050
1088
|
}
|
|
1051
1089
|
if (checkGap) {
|
|
1052
|
-
await this.
|
|
1090
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkGap).call(this, update.pts, update.pts_count);
|
|
1053
1091
|
}
|
|
1054
1092
|
localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
1055
1093
|
originalPts ??= localState.pts;
|
|
@@ -1213,6 +1251,7 @@ export class Client extends ClientAbstract {
|
|
|
1213
1251
|
}
|
|
1214
1252
|
finally {
|
|
1215
1253
|
this.stateChangeHandler(this.connected);
|
|
1254
|
+
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
1216
1255
|
}
|
|
1217
1256
|
}, _Client_recoverChannelUpdateGap = async function _Client_recoverChannelUpdateGap(channelId, source) {
|
|
1218
1257
|
dGapC("recovering channel update gap [%o, %s]", channelId, source);
|
|
@@ -2118,26 +2157,10 @@ export class Client extends ClientAbstract {
|
|
|
2118
2157
|
let media = null;
|
|
2119
2158
|
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
2120
2159
|
if (typeof photo === "string") {
|
|
2121
|
-
|
|
2122
|
-
try {
|
|
2123
|
-
fileId = FileID.decode(photo);
|
|
2124
|
-
}
|
|
2125
|
-
catch (err) {
|
|
2126
|
-
d("fileId: %o", err);
|
|
2127
|
-
}
|
|
2160
|
+
const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, photo, FileType.Photo);
|
|
2128
2161
|
if (fileId != null) {
|
|
2129
|
-
if (fileId.fileType != FileType.Photo) {
|
|
2130
|
-
UNREACHABLE();
|
|
2131
|
-
}
|
|
2132
|
-
if (fileId.params.mediaId == undefined || fileId.params.accessHash == undefined || fileId.params.fileReference == undefined) {
|
|
2133
|
-
UNREACHABLE();
|
|
2134
|
-
}
|
|
2135
2162
|
media = new types.InputMediaPhoto({
|
|
2136
|
-
id: new types.InputPhoto(
|
|
2137
|
-
id: fileId.params.mediaId,
|
|
2138
|
-
access_hash: fileId.params.accessHash,
|
|
2139
|
-
file_reference: fileId.params.fileReference,
|
|
2140
|
-
}),
|
|
2163
|
+
id: new types.InputPhoto(fileId),
|
|
2141
2164
|
spoiler,
|
|
2142
2165
|
});
|
|
2143
2166
|
}
|
|
@@ -2152,33 +2175,70 @@ export class Client extends ClientAbstract {
|
|
|
2152
2175
|
media = new types.InputMediaUploadedPhoto({ file, spoiler });
|
|
2153
2176
|
}
|
|
2154
2177
|
}
|
|
2155
|
-
const
|
|
2156
|
-
const randomId = getRandomId();
|
|
2157
|
-
const silent = params?.disableNotification ? true : undefined;
|
|
2158
|
-
const noforwards = params?.protectContent ? true : undefined;
|
|
2159
|
-
const replyToMsgId = params?.replyToMessageId;
|
|
2160
|
-
const topMsgId = params?.messageThreadId;
|
|
2161
|
-
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2162
|
-
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2163
|
-
const caption_ = params?.caption;
|
|
2164
|
-
const parseResult = caption_ !== undefined ? __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
2165
|
-
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
2166
|
-
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
2167
|
-
const result = await this.invoke(new functions.messages.sendMedia({
|
|
2168
|
-
peer,
|
|
2169
|
-
random_id: randomId,
|
|
2170
|
-
silent,
|
|
2171
|
-
noforwards,
|
|
2172
|
-
reply_markup: replyMarkup,
|
|
2173
|
-
reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2174
|
-
send_as: sendAs,
|
|
2175
|
-
media,
|
|
2176
|
-
message: caption ?? "",
|
|
2177
|
-
entities: captionEntities,
|
|
2178
|
-
}));
|
|
2179
|
-
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2178
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
|
|
2180
2179
|
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "photo");
|
|
2181
2180
|
}
|
|
2181
|
+
/**
|
|
2182
|
+
* Send a document.
|
|
2183
|
+
*
|
|
2184
|
+
* @method
|
|
2185
|
+
* @param chatId The chat to send the document to.
|
|
2186
|
+
* @param document The document to send.
|
|
2187
|
+
*/
|
|
2188
|
+
async sendDocument(chatId, document, params) {
|
|
2189
|
+
let media = null;
|
|
2190
|
+
const spoiler = params?.hasSpoiler ? true : undefined;
|
|
2191
|
+
if (typeof document === "string") {
|
|
2192
|
+
const fileId = __classPrivateFieldGet(this, _Client_instances, "m", _Client_resolveFileId).call(this, document, FileType.Document);
|
|
2193
|
+
if (fileId != null) {
|
|
2194
|
+
media = new types.InputMediaDocument({
|
|
2195
|
+
id: new types.InputDocument(fileId),
|
|
2196
|
+
spoiler,
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
if (media == null) {
|
|
2201
|
+
if (typeof document === "string" && isHttpUrl(document)) {
|
|
2202
|
+
media = new types.InputMediaDocumentExternal({ url: document, spoiler });
|
|
2203
|
+
}
|
|
2204
|
+
else {
|
|
2205
|
+
const [contents, fileName_] = await getFileContents(document);
|
|
2206
|
+
const fileName = params?.fileName ?? fileName_;
|
|
2207
|
+
const mimeType = params?.mimeType ?? contentType(fileName.split(".").slice(-1)[0]) ?? "application/octet-stream";
|
|
2208
|
+
const file = await this.upload(contents, { fileName, chunkSize: params?.chunkSize, signal: params?.signal });
|
|
2209
|
+
media = new types.InputMediaUploadedDocument({
|
|
2210
|
+
file,
|
|
2211
|
+
spoiler,
|
|
2212
|
+
attributes: [new types.DocumentAttributeFilename({ file_name: fileName })],
|
|
2213
|
+
mime_type: mimeType,
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
const message = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_sendMedia).call(this, chatId, media, params);
|
|
2218
|
+
return __classPrivateFieldGet(_a, _a, "m", _Client_assertMsgHas).call(_a, message, "document");
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Get network statistics. This might not always be available.
|
|
2222
|
+
*
|
|
2223
|
+
* @method
|
|
2224
|
+
*/
|
|
2225
|
+
async getNetworkStatistics() {
|
|
2226
|
+
const [messagesRead, messagesWrite, cdnRead, cdnWrite] = await Promise.all([
|
|
2227
|
+
this.storage.get(["netstat_messages_read"]),
|
|
2228
|
+
this.storage.get(["netstat_messages_write"]),
|
|
2229
|
+
this.storage.get(["netstat_cdn_read"]),
|
|
2230
|
+
this.storage.get(["netstat_cdn_write"]),
|
|
2231
|
+
]);
|
|
2232
|
+
const messages = {
|
|
2233
|
+
sent: Number(messagesWrite || 0),
|
|
2234
|
+
received: Number(messagesRead || 0),
|
|
2235
|
+
};
|
|
2236
|
+
const cdn = {
|
|
2237
|
+
sent: Number(cdnWrite || 0),
|
|
2238
|
+
received: Number(cdnRead || 0),
|
|
2239
|
+
};
|
|
2240
|
+
return { messages, cdn };
|
|
2241
|
+
}
|
|
2182
2242
|
}
|
|
2183
2243
|
_a = Client, _Client_getMe = async function _Client_getMe() {
|
|
2184
2244
|
if (__classPrivateFieldGet(this, _Client_lastGetMe, "f") != null) {
|
|
@@ -2313,4 +2373,52 @@ async function _Client_setMyInfo(info) {
|
|
|
2313
2373
|
await this.invoke(new functions.bots.setBotInfo({ bot: new types.InputUserSelf(), ...info }));
|
|
2314
2374
|
}, _Client_getMyInfo = function _Client_getMyInfo(languageCode) {
|
|
2315
2375
|
return this.invoke(new functions.bots.getBotInfo({ bot: new types.InputUserSelf(), lang_code: languageCode ?? "" }));
|
|
2376
|
+
}, _Client_resolveFileId = function _Client_resolveFileId(maybeFileId, expectedFileType) {
|
|
2377
|
+
let fileId = null;
|
|
2378
|
+
try {
|
|
2379
|
+
fileId = FileID.decode(maybeFileId);
|
|
2380
|
+
}
|
|
2381
|
+
catch (err) {
|
|
2382
|
+
d("fileId: %o", err);
|
|
2383
|
+
}
|
|
2384
|
+
if (fileId != null) {
|
|
2385
|
+
if (fileId.fileType != expectedFileType) {
|
|
2386
|
+
UNREACHABLE();
|
|
2387
|
+
}
|
|
2388
|
+
if (fileId.params.mediaId == undefined || fileId.params.accessHash == undefined || fileId.params.fileReference == undefined) {
|
|
2389
|
+
UNREACHABLE();
|
|
2390
|
+
}
|
|
2391
|
+
return {
|
|
2392
|
+
id: fileId.params.mediaId,
|
|
2393
|
+
access_hash: fileId.params.accessHash,
|
|
2394
|
+
file_reference: fileId.params.fileReference,
|
|
2395
|
+
};
|
|
2396
|
+
}
|
|
2397
|
+
return null;
|
|
2398
|
+
}, _Client_sendMedia = async function _Client_sendMedia(chatId, media, params) {
|
|
2399
|
+
const peer = await this.getInputPeer(chatId);
|
|
2400
|
+
const randomId = getRandomId();
|
|
2401
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
2402
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
2403
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
2404
|
+
const topMsgId = params?.messageThreadId;
|
|
2405
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined; // TODO: check default sendAs
|
|
2406
|
+
const replyMarkup = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_constructReplyMarkup).call(this, params);
|
|
2407
|
+
const caption_ = params?.caption;
|
|
2408
|
+
const parseResult = caption_ !== undefined ? __classPrivateFieldGet(this, _Client_instances, "m", _Client_parseText).call(this, caption_, { parseMode: params?.parseMode, entities: params?.captionEntities }) : undefined;
|
|
2409
|
+
const caption = parseResult === undefined ? undefined : parseResult[0];
|
|
2410
|
+
const captionEntities = parseResult === undefined ? undefined : parseResult[1];
|
|
2411
|
+
const result = await this.invoke(new functions.messages.sendMedia({
|
|
2412
|
+
peer,
|
|
2413
|
+
random_id: randomId,
|
|
2414
|
+
silent,
|
|
2415
|
+
noforwards,
|
|
2416
|
+
reply_markup: replyMarkup,
|
|
2417
|
+
reply_to: replyToMsgId !== undefined ? new types.InputReplyToMessage({ reply_to_msg_id: replyToMsgId, top_msg_id: topMsgId }) : undefined,
|
|
2418
|
+
send_as: sendAs,
|
|
2419
|
+
media,
|
|
2420
|
+
message: caption ?? "",
|
|
2421
|
+
entities: captionEntities,
|
|
2422
|
+
}));
|
|
2423
|
+
return await __classPrivateFieldGet(this, _Client_instances, "m", _Client_updatesToMessages).call(this, chatId, result).then((v) => v[0]);
|
|
2316
2424
|
};
|
|
@@ -5,6 +5,10 @@ declare abstract class Foundation {
|
|
|
5
5
|
abstract open(): MaybePromise<void>;
|
|
6
6
|
abstract write(p: Uint8Array): MaybePromise<void>;
|
|
7
7
|
abstract close(): MaybePromise<void>;
|
|
8
|
+
callback?: {
|
|
9
|
+
read(count: number): void;
|
|
10
|
+
write(count: number): void;
|
|
11
|
+
};
|
|
8
12
|
}
|
|
9
13
|
export declare abstract class ConnectionUnframed extends Foundation {
|
|
10
14
|
readonly type: "framed";
|