@mtkruto/node 0.0.991 → 0.0.993
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/1_utilities.d.ts +12 -0
- package/esm/1_utilities.js +12 -0
- package/esm/2_connection.d.ts +2 -0
- package/esm/2_connection.js +2 -0
- package/esm/2_tl.d.ts +10 -0
- package/esm/2_tl.js +10 -0
- package/esm/3_storage.d.ts +6 -0
- package/esm/3_storage.js +6 -0
- package/esm/3_transport.d.ts +4 -0
- package/esm/3_transport.js +4 -0
- package/esm/3_types.d.ts +35 -0
- package/esm/3_types.js +35 -0
- package/esm/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/esm/{constants.js → 4_constants.js} +1 -1
- package/esm/5_client.d.ts +2 -0
- package/esm/5_client.js +2 -0
- package/esm/client/0_html.d.ts +1 -1
- package/esm/client/0_html.js +1 -1
- package/esm/client/0_message.d.ts +1 -2
- package/esm/client/0_message.js +7 -14
- package/esm/client/0_password.d.ts +2 -2
- package/esm/client/0_password.js +2 -4
- package/esm/client/0_utilities.d.ts +3 -5
- package/esm/client/0_utilities.js +3 -22
- package/esm/client/1_client_abstract.d.ts +2 -2
- package/esm/client/1_client_abstract.js +3 -3
- package/esm/client/2_client_plain.d.ts +3 -3
- package/esm/client/2_client_plain.js +13 -20
- package/esm/client/3_client.d.ts +95 -18
- package/esm/client/3_client.js +124 -35
- package/esm/connection/0_connection.d.ts +1 -1
- package/esm/connection/1_connection_web_socket.js +1 -1
- package/esm/mod.d.ts +8 -21
- package/esm/mod.js +8 -21
- package/esm/storage/0_storage.d.ts +4 -5
- package/esm/storage/0_storage.js +3 -8
- package/esm/storage/0_utilities.js +2 -2
- package/esm/storage/1_storage_local_storage.d.ts +1 -1
- package/esm/storage/1_storage_memory.d.ts +1 -1
- package/esm/storage/1_storage_session_storage.d.ts +1 -1
- package/esm/tl/0_tl_raw_reader.js +1 -1
- package/esm/tl/0_tl_raw_writer.js +1 -1
- package/esm/tl/1_tl_object.js +1 -1
- package/esm/tl/3_deserialize.js +1 -1
- package/esm/tl/3_utilities.d.ts +3 -0
- package/esm/tl/3_utilities.js +20 -0
- package/esm/tl/4_tl_writer.js +1 -1
- package/esm/transport/0_obfuscation.d.ts +2 -2
- package/esm/transport/0_obfuscation.js +1 -2
- package/esm/transport/0_transport.d.ts +1 -2
- package/esm/transport/1_transport_abridged.d.ts +1 -1
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.d.ts +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/transport/2_transport_provider.d.ts +1 -1
- package/esm/transport/2_transport_provider.js +1 -1
- package/esm/types/!0_file_id.js +6 -9
- package/esm/types/!0_misc.d.ts +7 -0
- package/esm/types/!0_misc.js +1 -0
- package/esm/types/0_audio.d.ts +3 -3
- package/esm/types/0_audio.js +1 -1
- package/esm/types/0_chat_administrator_rights.d.ts +1 -1
- package/esm/types/0_chat_administrator_rights.js +1 -1
- package/esm/types/0_chat_photo.d.ts +3 -3
- package/esm/types/0_chat_photo.js +1 -1
- package/esm/types/0_color.d.ts +2 -0
- package/esm/types/0_color.js +16 -0
- package/esm/types/0_contact.d.ts +2 -2
- package/esm/types/0_dice.d.ts +1 -1
- package/esm/types/0_force_reply.d.ts +1 -1
- package/esm/types/0_force_reply.js +1 -1
- package/esm/types/0_location.d.ts +1 -1
- package/esm/types/0_location.js +1 -2
- package/esm/types/0_mask_position.d.ts +1 -1
- package/esm/types/0_message_entity.d.ts +5 -5
- package/esm/types/0_message_entity.js +1 -1
- package/esm/types/0_poll_option.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.js +2 -2
- package/esm/types/0_thumbnail.d.ts +2 -2
- package/esm/types/0_thumbnail.js +1 -1
- package/esm/types/0_venue.d.ts +1 -1
- package/esm/types/0_venue.js +1 -2
- package/esm/types/0_voice.d.ts +3 -3
- package/esm/types/0_web_app_info.d.ts +2 -2
- package/esm/types/1_animation.d.ts +3 -3
- package/esm/types/1_animation.js +1 -1
- package/esm/types/1_chat.d.ts +5 -4
- package/esm/types/1_chat.js +8 -9
- package/esm/types/1_document.d.ts +4 -4
- package/esm/types/1_document.js +1 -1
- package/esm/types/1_inline_keyboard_button.d.ts +4 -4
- package/esm/types/1_inline_keyboard_button.js +2 -2
- package/esm/types/1_keyboard_button.d.ts +8 -8
- package/esm/types/1_keyboard_button.js +2 -2
- package/esm/types/1_photo.d.ts +2 -2
- package/esm/types/1_photo.js +1 -1
- package/esm/types/1_poll.d.ts +8 -8
- package/esm/types/1_poll.js +1 -1
- package/esm/types/1_sticker.d.ts +3 -3
- package/esm/types/1_sticker.js +1 -2
- package/esm/types/1_user.d.ts +4 -3
- package/esm/types/1_user.js +4 -4
- package/esm/types/1_video.d.ts +3 -3
- package/esm/types/1_video.js +1 -1
- package/esm/types/1_video_note.d.ts +2 -2
- package/esm/types/1_video_note.js +1 -1
- package/esm/types/2_game.d.ts +3 -3
- package/esm/types/2_game.js +2 -3
- package/esm/types/2_inline_keyboard_markup.d.ts +2 -2
- package/esm/types/2_inline_keyboard_markup.js +1 -1
- package/esm/types/2_inline_query.d.ts +19 -0
- package/esm/types/2_inline_query.js +41 -0
- package/esm/types/2_reply_keyboard_markup.d.ts +2 -2
- package/esm/types/2_reply_keyboard_markup.js +1 -1
- package/esm/types/3_message.d.ts +21 -23
- package/esm/types/3_message.js +16 -18
- package/esm/types/4_callback_query.d.ts +14 -0
- package/esm/types/4_callback_query.js +24 -0
- package/esm/utilities/0_base64.js +1 -1
- package/esm/utilities/0_crypto.js +1 -1
- package/esm/utilities/0_queue.js +1 -1
- package/esm/utilities/1_auth.js +1 -1
- package/package.json +1 -1
- package/script/1_utilities.d.ts +12 -0
- package/script/1_utilities.js +28 -0
- package/script/2_connection.d.ts +2 -0
- package/script/2_connection.js +18 -0
- package/script/2_tl.d.ts +10 -0
- package/script/2_tl.js +40 -0
- package/script/3_storage.d.ts +6 -0
- package/script/3_storage.js +22 -0
- package/script/3_transport.d.ts +4 -0
- package/script/3_transport.js +20 -0
- package/script/3_types.d.ts +35 -0
- package/script/3_types.js +51 -0
- package/script/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/script/{constants.js → 4_constants.js} +1 -1
- package/script/5_client.d.ts +2 -0
- package/script/5_client.js +18 -0
- package/script/client/0_html.d.ts +1 -1
- package/script/client/0_html.js +2 -2
- package/script/client/0_message.d.ts +1 -2
- package/script/client/0_message.js +32 -39
- package/script/client/0_password.d.ts +2 -2
- package/script/client/0_password.js +20 -22
- package/script/client/0_utilities.d.ts +3 -5
- package/script/client/0_utilities.js +24 -68
- package/script/client/1_client_abstract.d.ts +2 -2
- package/script/client/1_client_abstract.js +6 -6
- package/script/client/2_client_plain.d.ts +3 -3
- package/script/client/2_client_plain.js +45 -52
- package/script/client/3_client.d.ts +95 -18
- package/script/client/3_client.js +368 -303
- package/script/connection/0_connection.d.ts +1 -1
- package/script/connection/1_connection_web_socket.js +5 -5
- package/script/mod.d.ts +8 -21
- package/script/mod.js +18 -33
- package/script/storage/0_storage.d.ts +4 -5
- package/script/storage/0_storage.js +11 -39
- package/script/storage/0_utilities.js +6 -6
- package/script/storage/1_storage_local_storage.d.ts +1 -1
- package/script/storage/1_storage_memory.d.ts +1 -1
- package/script/storage/1_storage_session_storage.d.ts +1 -1
- package/script/tl/0_tl_raw_reader.js +6 -6
- package/script/tl/0_tl_raw_writer.js +7 -7
- package/script/tl/1_tl_object.js +3 -3
- package/script/tl/3_deserialize.js +2 -2
- package/script/tl/3_utilities.d.ts +3 -0
- package/script/tl/3_utilities.js +48 -0
- package/script/tl/4_tl_writer.js +2 -2
- package/script/transport/0_obfuscation.d.ts +2 -2
- package/script/transport/0_obfuscation.js +5 -6
- package/script/transport/0_transport.d.ts +1 -2
- package/script/transport/1_transport_abridged.d.ts +1 -1
- package/script/transport/1_transport_abridged.js +3 -3
- package/script/transport/1_transport_intermediate.d.ts +1 -1
- package/script/transport/1_transport_intermediate.js +3 -3
- package/script/transport/2_transport_provider.d.ts +1 -1
- package/script/transport/2_transport_provider.js +2 -2
- package/script/types/!0_file_id.js +24 -27
- package/script/types/!0_misc.d.ts +7 -0
- package/script/types/!0_misc.js +2 -0
- package/script/types/0_audio.d.ts +3 -3
- package/script/types/0_audio.js +2 -25
- package/script/types/0_chat_administrator_rights.d.ts +1 -1
- package/script/types/0_chat_administrator_rights.js +2 -25
- package/script/types/0_chat_photo.d.ts +3 -3
- package/script/types/0_chat_photo.js +2 -25
- package/script/types/0_color.d.ts +2 -0
- package/script/types/{!0_id_color.js → 0_color.js} +10 -10
- package/script/types/0_contact.d.ts +2 -2
- package/script/types/0_dice.d.ts +1 -1
- package/script/types/0_force_reply.d.ts +1 -1
- package/script/types/0_force_reply.js +2 -25
- package/script/types/0_location.d.ts +1 -1
- package/script/types/0_location.js +5 -29
- package/script/types/0_mask_position.d.ts +1 -1
- package/script/types/0_message_entity.d.ts +5 -5
- package/script/types/0_message_entity.js +39 -62
- package/script/types/0_poll_option.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.js +4 -27
- package/script/types/0_thumbnail.d.ts +2 -2
- package/script/types/0_thumbnail.js +2 -25
- package/script/types/0_venue.d.ts +1 -1
- package/script/types/0_venue.js +2 -26
- package/script/types/0_voice.d.ts +3 -3
- package/script/types/0_web_app_info.d.ts +2 -2
- package/script/types/1_animation.d.ts +3 -3
- package/script/types/1_animation.js +2 -25
- package/script/types/1_chat.d.ts +5 -4
- package/script/types/1_chat.js +20 -44
- package/script/types/1_document.d.ts +4 -4
- package/script/types/1_document.js +2 -25
- package/script/types/1_inline_keyboard_button.d.ts +4 -4
- package/script/types/1_inline_keyboard_button.js +19 -42
- package/script/types/1_keyboard_button.d.ts +8 -8
- package/script/types/1_keyboard_button.js +24 -47
- package/script/types/1_photo.d.ts +2 -2
- package/script/types/1_photo.js +4 -27
- package/script/types/1_poll.d.ts +8 -8
- package/script/types/1_poll.js +2 -2
- package/script/types/1_sticker.d.ts +3 -3
- package/script/types/1_sticker.js +6 -30
- package/script/types/1_user.d.ts +4 -3
- package/script/types/1_user.js +6 -29
- package/script/types/1_video.d.ts +3 -3
- package/script/types/1_video.js +2 -25
- package/script/types/1_video_note.d.ts +2 -2
- package/script/types/1_video_note.js +2 -25
- package/script/types/2_game.d.ts +3 -3
- package/script/types/2_game.js +6 -30
- package/script/types/2_inline_keyboard_markup.d.ts +2 -2
- package/script/types/2_inline_keyboard_markup.js +3 -26
- package/script/types/2_inline_query.d.ts +19 -0
- package/script/types/2_inline_query.js +45 -0
- package/script/types/2_reply_keyboard_markup.d.ts +2 -2
- package/script/types/2_reply_keyboard_markup.js +3 -26
- package/script/types/3_message.d.ts +21 -23
- package/script/types/3_message.js +94 -119
- package/script/types/4_callback_query.d.ts +14 -0
- package/script/types/4_callback_query.js +28 -0
- package/script/utilities/0_base64.js +3 -3
- package/script/utilities/0_crypto.js +3 -3
- package/script/utilities/0_queue.js +2 -2
- package/script/utilities/1_auth.js +5 -5
- package/esm/types/!0_id_color.d.ts +0 -1
- package/esm/types/!0_id_color.js +0 -16
- package/script/types/!0_id_color.d.ts +0 -1
- /package/esm/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/esm/{deps.js → 0_deps.js} +0 -0
- /package/script/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/script/{deps.js → 0_deps.js} +0 -0
package/esm/client/3_client.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import { MessageEntity } from "../types/0_message_entity.js";
|
|
8
|
-
import { ForceReply } from "../types/0_force_reply.js";
|
|
9
|
-
import { InlineKeyboardMarkup } from "../types/2_inline_keyboard_markup.js";
|
|
10
|
-
import { ReplyKeyboardMarkup } from "../types/2_reply_keyboard_markup.js";
|
|
11
|
-
import { Message } from "../types/3_message.js";
|
|
12
|
-
import { Storage } from "../storage/0_storage.js";
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { functions, ReadObject, types } from "../2_tl.js";
|
|
3
|
+
import { Storage } from "../3_storage.js";
|
|
4
|
+
import { DC } from "../3_transport.js";
|
|
5
|
+
import { CallbackQuery, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, // high-level Telegram API message
|
|
6
|
+
MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
13
7
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
14
8
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
15
9
|
export declare const getEntity: unique symbol;
|
|
16
10
|
export declare const getStickerSetName: unique symbol;
|
|
17
11
|
export declare const handleMigrationError: unique symbol;
|
|
12
|
+
export declare const getMessageWithReply: unique symbol;
|
|
18
13
|
export declare const restartAuth: unique symbol;
|
|
19
14
|
export declare enum ParseMode {
|
|
20
15
|
None = "none",
|
|
@@ -59,6 +54,16 @@ export interface ClientParams extends ClientPlainParams {
|
|
|
59
54
|
*/
|
|
60
55
|
autoStart?: boolean;
|
|
61
56
|
}
|
|
57
|
+
export interface AnswerCallbackQueryParams {
|
|
58
|
+
/** Text of the answer */
|
|
59
|
+
text?: string;
|
|
60
|
+
/** Pass true to show an alert to the user instead of a toast notification */
|
|
61
|
+
alert?: boolean;
|
|
62
|
+
/** URL to be opened */
|
|
63
|
+
url?: string;
|
|
64
|
+
/** Time during which the result of the query can be cached, in seconds */
|
|
65
|
+
cacheTime?: number;
|
|
66
|
+
}
|
|
62
67
|
/**
|
|
63
68
|
* A chat identifier as provided by MTKruto or a string starting with a @ that is followed by a username.
|
|
64
69
|
*/
|
|
@@ -93,11 +98,11 @@ export interface SendMessagesParams {
|
|
|
93
98
|
*/
|
|
94
99
|
messageThreadId?: number;
|
|
95
100
|
/**
|
|
96
|
-
* The identifier of the chat to send the message on behalf of.
|
|
101
|
+
* The identifier of the chat to send the message on behalf of. User-only.
|
|
97
102
|
*/
|
|
98
103
|
sendAs?: ChatID;
|
|
99
104
|
/**
|
|
100
|
-
* The reply markup of the message.
|
|
105
|
+
* The reply markup of the message. Bot-only.
|
|
101
106
|
*/
|
|
102
107
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
103
108
|
}
|
|
@@ -115,7 +120,7 @@ export interface EditMessageParams {
|
|
|
115
120
|
*/
|
|
116
121
|
disableWebPagePreview?: boolean;
|
|
117
122
|
/**
|
|
118
|
-
* The reply markup of the message.
|
|
123
|
+
* The reply markup of the message. Bot-only.
|
|
119
124
|
*/
|
|
120
125
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
121
126
|
}
|
|
@@ -130,7 +135,7 @@ export interface ForwardMessagesParams {
|
|
|
130
135
|
*/
|
|
131
136
|
protectContent?: boolean;
|
|
132
137
|
/**
|
|
133
|
-
* The identifier of the chat to forward the message on behalf of.
|
|
138
|
+
* The identifier of the chat to forward the message on behalf of. User-only.
|
|
134
139
|
*/
|
|
135
140
|
sendAs?: ChatID;
|
|
136
141
|
/**
|
|
@@ -269,6 +274,7 @@ export declare class Client extends ClientAbstract {
|
|
|
269
274
|
* @param text The new text of the message.
|
|
270
275
|
*/
|
|
271
276
|
editMessageText(chatId: ChatID, messageId: number, text: string, params?: EditMessageParams): Promise<void>;
|
|
277
|
+
private getMessagesInner;
|
|
272
278
|
/**
|
|
273
279
|
* Retrieve multiple messages.
|
|
274
280
|
*
|
|
@@ -276,6 +282,7 @@ export declare class Client extends ClientAbstract {
|
|
|
276
282
|
* @param messageIds The identifiers of the messages to retrieve.
|
|
277
283
|
*/
|
|
278
284
|
getMessages(chatId_: ChatID, messageIds: number[]): Promise<Omit<Message, "replyToMessage">[]>;
|
|
285
|
+
[getMessageWithReply](chatId: ChatID, messageId: number): Promise<Message | null>;
|
|
279
286
|
/**
|
|
280
287
|
* Retrieve a single message.
|
|
281
288
|
*
|
|
@@ -310,26 +317,96 @@ export declare class Client extends ClientAbstract {
|
|
|
310
317
|
/**
|
|
311
318
|
* Get information on the currently authorized user.
|
|
312
319
|
*/
|
|
313
|
-
getMe(): Promise<import("../
|
|
320
|
+
getMe(): Promise<import("../3_types.js").User>;
|
|
314
321
|
private handleUpdate;
|
|
315
322
|
handler: Handler;
|
|
316
323
|
use(middleware: Handler): void;
|
|
317
324
|
on<U extends keyof Update, K extends keyof Update[U]>(filter: U extends FilterableUpdates ? U | [U, K, ...K[]] : U, handler: Handler<Pick<{
|
|
318
325
|
[P in U]: With<Update[U], K>;
|
|
319
326
|
}, U>>): void;
|
|
327
|
+
/**
|
|
328
|
+
* Answer a callback query. Bot-only.
|
|
329
|
+
*
|
|
330
|
+
* @param id ID of the callback query to answer.
|
|
331
|
+
*/
|
|
332
|
+
answerCallbackQuery(id: string, params?: AnswerCallbackQueryParams): Promise<void>;
|
|
333
|
+
sendPoll(chatId: ChatID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<void>;
|
|
334
|
+
}
|
|
335
|
+
export interface SendPollParams {
|
|
336
|
+
/**
|
|
337
|
+
* True, if the poll needs to be anonymous, defaults to True */
|
|
338
|
+
isAnonymous?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* The type of the poll. Defaults to regular. */
|
|
341
|
+
type?: "quiz" | "regular";
|
|
342
|
+
/**
|
|
343
|
+
* True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False */
|
|
344
|
+
allowMultipleAnswers?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Index of the correct option. Required for quizzes. */
|
|
347
|
+
correctOptionIndex?: number;
|
|
348
|
+
/**
|
|
349
|
+
* Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing */
|
|
350
|
+
explanation?: string;
|
|
351
|
+
/**
|
|
352
|
+
* The parse mode to use for the explanation. If not provided, the default parse mode will be used.
|
|
353
|
+
*/
|
|
354
|
+
explanationParseMode?: ParseMode;
|
|
355
|
+
/**
|
|
356
|
+
* The explanation's entities.
|
|
357
|
+
*/
|
|
358
|
+
explanationEntities?: MessageEntity[];
|
|
359
|
+
/**
|
|
360
|
+
* Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date.
|
|
361
|
+
*/
|
|
362
|
+
openPeriod?: number;
|
|
363
|
+
/**
|
|
364
|
+
* Point in time when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period.
|
|
365
|
+
*/
|
|
366
|
+
closeDate?: Date;
|
|
367
|
+
/**
|
|
368
|
+
* Pass True if the poll needs to be immediately closed. This can be useful for poll preview.
|
|
369
|
+
*/
|
|
370
|
+
isClosed?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Whether to send the message in a silent way without making a sound on the recipients' clients.
|
|
373
|
+
*/
|
|
374
|
+
disableNotification?: boolean;
|
|
375
|
+
/**
|
|
376
|
+
* The identifier of a message to reply to.
|
|
377
|
+
*/
|
|
378
|
+
replyToMessageId?: number;
|
|
379
|
+
/**
|
|
380
|
+
* The identifier of a thread to send the message to.
|
|
381
|
+
*/
|
|
382
|
+
messageThreadId?: number;
|
|
383
|
+
/**
|
|
384
|
+
* The identifier of the chat to send the message on behalf of. User-only.
|
|
385
|
+
*/
|
|
386
|
+
sendAs?: ChatID;
|
|
387
|
+
/**
|
|
388
|
+
* The reply markup of the message. Bot-only.
|
|
389
|
+
*/
|
|
390
|
+
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
391
|
+
/**
|
|
392
|
+
* Whether to protect the contents of the message from copying and forwarding.
|
|
393
|
+
*/
|
|
394
|
+
protectContent?: boolean;
|
|
320
395
|
}
|
|
321
396
|
type With<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
322
397
|
export type ConnectionState = "not-connected" | "updating" | "ready";
|
|
323
398
|
export type AuthorizationState = {
|
|
324
399
|
authorized: boolean;
|
|
325
400
|
};
|
|
326
|
-
type FilterableUpdates = "message" | "editedMessage";
|
|
401
|
+
type FilterableUpdates = "message" | "editedMessage" | "callbackQuery";
|
|
327
402
|
export interface Update {
|
|
328
403
|
message: Message;
|
|
329
404
|
editedMessage: Message;
|
|
330
405
|
connectionState: ConnectionState;
|
|
331
406
|
authorizationState: AuthorizationState;
|
|
332
407
|
deletedMessages: [Message, ...Message[]];
|
|
408
|
+
callbackQuery: CallbackQuery;
|
|
409
|
+
inlineQuery: InlineQuery;
|
|
333
410
|
}
|
|
334
411
|
export interface Handler<U extends Partial<Update> = Partial<Update>> {
|
|
335
412
|
(update: U, next: () => Promise<void>): MaybePromise<void>;
|
package/esm/client/3_client.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
import { debug, gunzip, Mutex } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { TLError } from "../tl/0_tl_raw_reader.js";
|
|
10
|
-
import { as } from "../tl/1_tl_object.js";
|
|
11
|
-
import * as types from "../tl/2_types.js";
|
|
12
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
13
|
-
import * as functions from "../tl/3_functions.js";
|
|
14
|
-
import { RPCResult } from "../tl/5_rpc_result.js";
|
|
15
|
-
import { Message as Message_ } from "../tl/6_message.js"; // MTProto API message
|
|
16
|
-
import { MessageContainer } from "../tl/7_message_container.js";
|
|
17
|
-
import { FileID, FileType, ThumbnailSource } from "../types/!0_file_id.js";
|
|
18
|
-
import { replyKeyboardRemoveToTlObject } from "../types/0_reply_keyboard_remove.js";
|
|
19
|
-
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
20
|
-
import { forceReplyToTlObject } from "../types/0_force_reply.js";
|
|
21
|
-
import { constructUser } from "../types/1_user.js";
|
|
22
|
-
import { inlineKeyboardMarkupToTlObject } from "../types/2_inline_keyboard_markup.js";
|
|
23
|
-
import { replyKeyboardMarkupToTlObject } from "../types/2_reply_keyboard_markup.js";
|
|
24
|
-
import { constructMessage } from "../types/3_message.js"; // high-level wrapper for Telegram API's message
|
|
25
|
-
import { StorageMemory } from "../storage/1_storage_memory.js";
|
|
1
|
+
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
2
|
+
import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
3
|
+
import { as, functions, getChannelChatId, Message as Message_, // MTProto API message
|
|
4
|
+
MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types, } from "../2_tl.js";
|
|
5
|
+
import { StorageMemory } from "../3_storage.js";
|
|
6
|
+
import { constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, forceReplyToTlObject, inlineKeyboardMarkupToTlObject, messageEntityToTlObject, replyKeyboardMarkupToTlObject, replyKeyboardRemoveToTlObject, ThumbnailSource, } from "../3_types.js";
|
|
7
|
+
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
8
|
+
import { isChannelPtsUpdate, isPtsUpdate } from "./0_utilities.js";
|
|
26
9
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
27
10
|
import { checkPassword } from "./0_password.js";
|
|
28
11
|
import { parseHtml } from "./0_html.js";
|
|
@@ -36,6 +19,7 @@ const dRecv = debug("Client/receiveLoop");
|
|
|
36
19
|
export const getEntity = Symbol();
|
|
37
20
|
export const getStickerSetName = Symbol();
|
|
38
21
|
export const handleMigrationError = Symbol();
|
|
22
|
+
export const getMessageWithReply = Symbol();
|
|
39
23
|
export const restartAuth = Symbol();
|
|
40
24
|
export var ParseMode;
|
|
41
25
|
(function (ParseMode) {
|
|
@@ -820,7 +804,7 @@ export class Client extends ClientAbstract {
|
|
|
820
804
|
let originalPts = null;
|
|
821
805
|
const channelPtsMap = new Map();
|
|
822
806
|
for (const update of updates) {
|
|
823
|
-
if (
|
|
807
|
+
if (isPtsUpdate(update)) {
|
|
824
808
|
if (update.pts == 0) {
|
|
825
809
|
continue;
|
|
826
810
|
}
|
|
@@ -834,7 +818,7 @@ export class Client extends ClientAbstract {
|
|
|
834
818
|
localState.pts = update.pts;
|
|
835
819
|
}
|
|
836
820
|
}
|
|
837
|
-
else if (
|
|
821
|
+
else if (isChannelPtsUpdate(update)) {
|
|
838
822
|
if (update.pts == 0) {
|
|
839
823
|
continue;
|
|
840
824
|
}
|
|
@@ -1304,13 +1288,7 @@ export class Client extends ClientAbstract {
|
|
|
1304
1288
|
const noWebpage = params?.disableWebPagePreview ? true : undefined;
|
|
1305
1289
|
await this.invoke(new functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
|
|
1306
1290
|
}
|
|
1307
|
-
|
|
1308
|
-
* Retrieve multiple messages.
|
|
1309
|
-
*
|
|
1310
|
-
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1311
|
-
* @param messageIds The identifiers of the messages to retrieve.
|
|
1312
|
-
*/
|
|
1313
|
-
async getMessages(chatId_, messageIds) {
|
|
1291
|
+
async getMessagesInner(chatId_, messageIds) {
|
|
1314
1292
|
const peer = await this.getInputPeer(chatId_);
|
|
1315
1293
|
let messages_ = new Array();
|
|
1316
1294
|
const chatId = peerToChatId(peer);
|
|
@@ -1341,10 +1319,25 @@ export class Client extends ClientAbstract {
|
|
|
1341
1319
|
}
|
|
1342
1320
|
const messages = new Array();
|
|
1343
1321
|
for (const message_ of messages_) {
|
|
1344
|
-
|
|
1322
|
+
const message = await constructMessage(message_, this[getEntity].bind(this), null, this[getStickerSetName].bind(this));
|
|
1323
|
+
const isReplyToMessage = message_ instanceof types.Message && message_.replyTo instanceof types.MessageReplyHeader;
|
|
1324
|
+
messages.push({ message, isReplyToMessage });
|
|
1345
1325
|
}
|
|
1346
1326
|
return messages;
|
|
1347
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Retrieve multiple messages.
|
|
1330
|
+
*
|
|
1331
|
+
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1332
|
+
* @param messageIds The identifiers of the messages to retrieve.
|
|
1333
|
+
*/
|
|
1334
|
+
async getMessages(chatId_, messageIds) {
|
|
1335
|
+
return await this.getMessagesInner(chatId_, messageIds).then((v) => v.map((v) => v.message));
|
|
1336
|
+
}
|
|
1337
|
+
async [getMessageWithReply](chatId, messageId) {
|
|
1338
|
+
const messages = await this.getMessagesInner(chatId, [messageId]);
|
|
1339
|
+
return messages[0]?.message ?? null;
|
|
1340
|
+
}
|
|
1348
1341
|
/**
|
|
1349
1342
|
* Retrieve a single message.
|
|
1350
1343
|
*
|
|
@@ -1524,6 +1517,12 @@ export class Client extends ClientAbstract {
|
|
|
1524
1517
|
await this.handler({ deletedMessages: deletedMessages }, resolve);
|
|
1525
1518
|
}
|
|
1526
1519
|
}
|
|
1520
|
+
if (update instanceof types.UpdateBotCallbackQuery || update instanceof types.UpdateInlineBotCallbackQuery) {
|
|
1521
|
+
await this.handler({ callbackQuery: await constructCallbackQuery(update, this[getEntity].bind(this), this[getMessageWithReply].bind(this)) }, resolve);
|
|
1522
|
+
}
|
|
1523
|
+
else if (update instanceof types.UpdateBotInlineQuery) {
|
|
1524
|
+
await this.handler({ inlineQuery: await constructInlineQuery(update, this[getEntity].bind(this)) }, resolve);
|
|
1525
|
+
}
|
|
1527
1526
|
}
|
|
1528
1527
|
use(middleware) {
|
|
1529
1528
|
const handler = this.handler;
|
|
@@ -1560,5 +1559,95 @@ export class Client extends ClientAbstract {
|
|
|
1560
1559
|
}
|
|
1561
1560
|
});
|
|
1562
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Answer a callback query. Bot-only.
|
|
1564
|
+
*
|
|
1565
|
+
* @param id ID of the callback query to answer.
|
|
1566
|
+
*/
|
|
1567
|
+
async answerCallbackQuery(id, params) {
|
|
1568
|
+
await this.invoke(new functions.MessagesSetBotCallbackAnswer({
|
|
1569
|
+
queryId: BigInt(id),
|
|
1570
|
+
cacheTime: params?.cacheTime ?? 0,
|
|
1571
|
+
message: params?.text,
|
|
1572
|
+
alert: params?.alert ? true : undefined,
|
|
1573
|
+
}));
|
|
1574
|
+
}
|
|
1575
|
+
async sendPoll(chatId, question, options, params) {
|
|
1576
|
+
const peer = await this.getInputPeer(chatId);
|
|
1577
|
+
const randomId = getRandomId();
|
|
1578
|
+
const silent = params?.disableNotification ? true : undefined;
|
|
1579
|
+
const noforwards = params?.protectContent ? true : undefined;
|
|
1580
|
+
const replyToMsgId = params?.replyToMessageId;
|
|
1581
|
+
const topMsgId = params?.messageThreadId;
|
|
1582
|
+
const sendAs = params?.sendAs ? await this.getInputPeer(params.sendAs) : undefined;
|
|
1583
|
+
let replyMarkup = undefined;
|
|
1584
|
+
if (params?.replyMarkup) {
|
|
1585
|
+
if ("inlineKeyboard" in params.replyMarkup) {
|
|
1586
|
+
replyMarkup = await inlineKeyboardMarkupToTlObject(params.replyMarkup, async (v) => {
|
|
1587
|
+
const inputPeer = await this.getInputPeer(v).then((v) => v[as](types.InputPeerUser));
|
|
1588
|
+
return new types.InputUser({ userId: inputPeer.userId, accessHash: inputPeer.accessHash });
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
else if ("keyboard" in params.replyMarkup) {
|
|
1592
|
+
replyMarkup = replyKeyboardMarkupToTlObject(params.replyMarkup);
|
|
1593
|
+
}
|
|
1594
|
+
else if ("removeKeyboard" in params.replyMarkup) {
|
|
1595
|
+
replyMarkup = replyKeyboardRemoveToTlObject(params.replyMarkup);
|
|
1596
|
+
}
|
|
1597
|
+
else if ("forceReply" in params.replyMarkup) {
|
|
1598
|
+
replyMarkup = forceReplyToTlObject(params.replyMarkup);
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
throw new Error("The replyMarkup parameter has an unexpected type");
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
let explanation = params?.explanation;
|
|
1605
|
+
const explanationEntities_ = params?.explanationEntities ?? [];
|
|
1606
|
+
if (explanation !== undefined) {
|
|
1607
|
+
const parseMode = params?.explanationParseMode ?? this.parseMode;
|
|
1608
|
+
switch (parseMode) {
|
|
1609
|
+
case ParseMode.None:
|
|
1610
|
+
break;
|
|
1611
|
+
case ParseMode.HTML: {
|
|
1612
|
+
const [newText, entitiesToPush] = parseHtml(explanation);
|
|
1613
|
+
explanation = newText;
|
|
1614
|
+
for (const entity of entitiesToPush) {
|
|
1615
|
+
explanationEntities_.push(entity);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
const solution = explanation === undefined ? undefined : explanation;
|
|
1621
|
+
const solutionEntities = explanationEntities_?.length > 0 ? explanationEntities_.map((v) => messageEntityToTlObject(v)) : undefined;
|
|
1622
|
+
const answers = options.map((v, i) => new types.PollAnswer({ option: new Uint8Array([i]), text: v }));
|
|
1623
|
+
const poll = new types.Poll({
|
|
1624
|
+
id: getRandomId(),
|
|
1625
|
+
answers,
|
|
1626
|
+
question,
|
|
1627
|
+
closed: params?.isClosed ? true : undefined,
|
|
1628
|
+
closeDate: params?.closeDate ? Math.floor(params.closeDate.getTime() / 1000) : undefined,
|
|
1629
|
+
closePeriod: params?.openPeriod ? params.openPeriod : undefined,
|
|
1630
|
+
multipleChoice: params?.allowMultipleAnswers ? true : undefined,
|
|
1631
|
+
publicVoters: params?.isAnonymous === false ? true : undefined,
|
|
1632
|
+
quiz: params?.type == "quiz" ? true : undefined,
|
|
1633
|
+
});
|
|
1634
|
+
const media = new types.InputMediaPoll({
|
|
1635
|
+
poll,
|
|
1636
|
+
correctAnswers: params?.correctOptionIndex ? [new Uint8Array([params.correctOptionIndex])] : undefined,
|
|
1637
|
+
solution,
|
|
1638
|
+
solutionEntities,
|
|
1639
|
+
});
|
|
1640
|
+
await this.invoke(new functions.MessagesSendMedia({
|
|
1641
|
+
peer,
|
|
1642
|
+
randomId,
|
|
1643
|
+
silent,
|
|
1644
|
+
noforwards,
|
|
1645
|
+
replyMarkup,
|
|
1646
|
+
replyTo: replyToMsgId !== undefined ? new types.InputReplyToMessage({ replyToMsgId, topMsgId }) : undefined,
|
|
1647
|
+
sendAs,
|
|
1648
|
+
media,
|
|
1649
|
+
message: "",
|
|
1650
|
+
}));
|
|
1651
|
+
}
|
|
1563
1652
|
}
|
|
1564
1653
|
const resolve = () => Promise.resolve();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { debug, Mutex } from "../
|
|
2
|
+
import { debug, Mutex } from "../0_deps.js";
|
|
3
3
|
import { ConnectionUnframed } from "./0_connection.js";
|
|
4
4
|
const d = debug("ConnectionWebSocket");
|
|
5
5
|
export class ConnectionWebSocket extends ConnectionUnframed {
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export declare const utils: {
|
|
4
4
|
checkPassword: typeof checkPassword;
|
|
5
5
|
getRandomId: typeof getRandomId;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export *
|
|
9
|
-
export *
|
|
10
|
-
export * from "./
|
|
11
|
-
export
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./client/3_client.js";
|
|
15
|
-
export * from "./storage/0_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_memory.js";
|
|
17
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
18
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
19
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
20
|
-
export * from "./transport/1_transport_abridged.js";
|
|
21
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
22
|
-
export * from "./transport/0_transport.js";
|
|
23
|
-
export * from "./transport/2_transport_provider.js";
|
|
24
|
-
export * from "./connection/0_connection.js";
|
|
25
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
26
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
7
|
+
export * as tl from "./2_tl.js";
|
|
8
|
+
export * from "./2_connection.js";
|
|
9
|
+
export * from "./3_storage.js";
|
|
10
|
+
export * from "./3_transport.js";
|
|
11
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
12
|
+
export * from "./5_client.js";
|
|
13
|
+
export * from "./3_types.js";
|
package/esm/mod.js
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export const utils = { checkPassword, getRandomId };
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
6
|
-
export *
|
|
7
|
-
export * from "./
|
|
8
|
-
export
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./client/3_client.js";
|
|
12
|
-
export * from "./storage/0_storage.js";
|
|
13
|
-
export * from "./storage/1_storage_memory.js";
|
|
14
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
15
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
17
|
-
export * from "./transport/1_transport_abridged.js";
|
|
18
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
19
|
-
export * from "./transport/0_transport.js";
|
|
20
|
-
export * from "./transport/2_transport_provider.js";
|
|
21
|
-
export * from "./connection/0_connection.js";
|
|
22
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
23
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
4
|
+
export * as tl from "./2_tl.js";
|
|
5
|
+
export * from "./2_connection.js";
|
|
6
|
+
export * from "./3_storage.js";
|
|
7
|
+
export * from "./3_transport.js";
|
|
8
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
9
|
+
export * from "./5_client.js";
|
|
10
|
+
export * from "./3_types.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as types from "../tl/2_types.js";
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { TLObject, types } from "../2_tl.js";
|
|
3
|
+
import { DC } from "../3_transport.js";
|
|
5
4
|
export type StorageKeyPart = string | number | bigint | Uint8Array;
|
|
6
5
|
export declare abstract class Storage {
|
|
7
6
|
private _authKeyId;
|
|
@@ -21,7 +20,7 @@ export declare abstract class Storage {
|
|
|
21
20
|
updateUsernames(type: "user" | "channel", id: bigint, usernames: string[]): Promise<void>;
|
|
22
21
|
getUsername(username: string): Promise<["channel" | "user", bigint, Date] | null>;
|
|
23
22
|
setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
|
|
24
|
-
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../
|
|
23
|
+
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
|
|
25
24
|
setState(state: types.UpdatesState): Promise<void>;
|
|
26
25
|
getState(): Promise<types.UpdatesState | null>;
|
|
27
26
|
setMessage(chatId: number, messageId: number, message: types.TypeMessage | null): Promise<void>;
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { UNREACHABLE } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { serialize } from "../tl/1_tl_object.js";
|
|
5
|
-
import * as types from "../tl/2_types.js";
|
|
6
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
7
|
-
import { rleDecode, rleEncode } from "../utilities/0_rle.js";
|
|
8
|
-
import { ZERO_CHANNEL_ID } from "../constants.js";
|
|
1
|
+
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { serialize, TLReader, types } from "../2_tl.js";
|
|
3
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
9
4
|
const KPARTS__DC = ["dc"];
|
|
10
5
|
const KPARTS__AUTH_KEY = ["authKey"];
|
|
11
6
|
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { base64Decode, base64Encode } from "../
|
|
2
|
-
import { UNREACHABLE } from "../
|
|
1
|
+
import { base64Decode, base64Encode } from "../0_deps.js";
|
|
2
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
3
3
|
export var ValueType;
|
|
4
4
|
(function (ValueType) {
|
|
5
5
|
ValueType[ValueType["Boolean"] = 0] = "Boolean";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
4
|
protected map: Map<string, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageSessionStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
package/esm/tl/1_tl_object.js
CHANGED
package/esm/tl/3_deserialize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertEquals } from "../
|
|
1
|
+
import { assertEquals } from "../0_deps.js";
|
|
2
2
|
import { analyzeOptionalParam, flags, isOptionalParam, isTLObjectConstructor, paramDesc } from "./1_tl_object.js";
|
|
3
3
|
import { map } from "./2_types.js";
|
|
4
4
|
function deserializeSingleParam(reader, type, ntype) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
3
|
+
import * as types from "./2_types.js";
|
|
4
|
+
export function getChannelChatId(channelId) {
|
|
5
|
+
return ZERO_CHANNEL_ID + -Number(channelId);
|
|
6
|
+
}
|
|
7
|
+
export function peerToChatId(peer) {
|
|
8
|
+
if (peer instanceof types.PeerUser || peer instanceof types.InputPeerUser) {
|
|
9
|
+
return Number(peer.userId);
|
|
10
|
+
}
|
|
11
|
+
else if (peer instanceof types.PeerChat || peer instanceof types.InputPeerChat) {
|
|
12
|
+
return -Number(peer.chatId);
|
|
13
|
+
}
|
|
14
|
+
else if (peer instanceof types.PeerChannel || peer instanceof types.InputPeerChannel) {
|
|
15
|
+
return getChannelChatId(peer.channelId);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
UNREACHABLE();
|
|
19
|
+
}
|
|
20
|
+
}
|
package/esm/tl/4_tl_writer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CTR } from "../
|
|
2
|
-
import { Connection } from "../
|
|
1
|
+
import { CTR } from "../1_utilities.js";
|
|
2
|
+
import { Connection } from "../2_connection.js";
|
|
3
3
|
export declare function getObfuscationParameters(protocol: number, connection: Connection): Promise<{
|
|
4
4
|
encryptionCTR: CTR;
|
|
5
5
|
decryptionCTR: CTR;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { bufferFromBigInt, concat } from "../
|
|
3
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
2
|
+
import { bufferFromBigInt, concat, CTR } from "../1_utilities.js";
|
|
4
3
|
export async function getObfuscationParameters(protocol, connection) {
|
|
5
4
|
const dc = 0xFCFF;
|
|
6
5
|
let init;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
1
|
+
import { CTR, MaybePromise } from "../1_utilities.js";
|
|
3
2
|
export declare abstract class Transport {
|
|
4
3
|
protected initialized: boolean;
|
|
5
4
|
protected obfuscationParameters: {
|