@mtkruto/node 0.153.0 → 0.160.0
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/3_types.d.ts +3 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +3 -0
- package/esm/4_constants.d.ts +1 -0
- package/esm/4_constants.d.ts.map +1 -1
- package/esm/4_constants.js +1 -0
- package/esm/client/0_markdown.js +4 -4
- package/esm/client/0_params.d.ts +11 -1
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +100 -3
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/1_client_plain.d.ts +1 -1
- package/esm/client/1_client_plain.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +25 -13
- package/esm/client/2_client_encrypted.d.ts +6 -3
- package/esm/client/2_client_encrypted.d.ts.map +1 -1
- package/esm/client/2_client_encrypted.js +166 -49
- package/esm/client/2_file_manager.js +1 -1
- package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +3 -2
- package/esm/client/2_payment_manager.js +2 -2
- package/esm/client/2_takeout_manager.js +2 -2
- package/esm/client/2_update_manager.d.ts.map +1 -1
- package/esm/client/2_update_manager.js +16 -11
- package/esm/client/3_account_manager.js +3 -3
- package/esm/client/3_message_manager.d.ts +11 -0
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +195 -74
- package/esm/client/3_sticker_set_manager.js +3 -3
- package/esm/client/3_video_chat_manager.js +1 -1
- package/esm/client/4_callback_query_manager.js +2 -2
- package/esm/client/4_chat_list_manager.js +3 -3
- package/esm/client/4_chat_manager.d.ts +3 -2
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +12 -5
- package/esm/client/4_contact_manager.js +1 -1
- package/esm/client/4_gift_manager.js +11 -11
- package/esm/client/4_inline_query_manager.js +1 -1
- package/esm/client/4_story_manager.d.ts +3 -1
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +17 -3
- package/esm/client/6_client.d.ts +102 -3
- package/esm/client/6_client.d.ts.map +1 -1
- package/esm/client/6_client.js +130 -2
- package/esm/client/6_client_dispatcher.d.ts +100 -3
- package/esm/client/6_client_dispatcher.d.ts.map +1 -1
- package/esm/client/6_client_dispatcher.js +126 -1
- package/esm/connection/0_get_tls_header.d.ts.map +1 -1
- package/esm/connection/0_get_tls_header.js +19 -0
- package/esm/connection/1_connection_web_socket.js +2 -2
- package/esm/session/0_session_state.d.ts +1 -0
- package/esm/session/0_session_state.d.ts.map +1 -1
- package/esm/session/0_session_state.js +8 -4
- package/esm/session/1_session.d.ts +1 -0
- package/esm/session/1_session.d.ts.map +1 -1
- package/esm/session/1_session.js +3 -0
- package/esm/session/2_session_encrypted.d.ts +11 -6
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +20 -12
- package/esm/storage/1_utilities.js +2 -2
- package/esm/transport/2_transport_provider_web_socket.js +1 -1
- package/esm/types/0_button_style.js +1 -1
- package/esm/types/0_chat_member_rights.js +34 -34
- package/esm/types/0_chat_photo.js +2 -2
- package/esm/types/0_dice.d.ts +1 -1
- package/esm/types/0_dice.d.ts.map +1 -1
- package/esm/types/0_giveaway_parameters.js +1 -1
- package/esm/types/0_live_stream_channel.d.ts +1 -1
- package/esm/types/0_live_stream_channel.d.ts.map +1 -1
- package/esm/types/0_report_reason.d.ts +53 -0
- package/esm/types/0_report_reason.d.ts.map +1 -0
- package/esm/types/0_report_reason.js +45 -0
- package/esm/types/0_story_report_option.d.ts +26 -0
- package/esm/types/0_story_report_option.d.ts.map +1 -0
- package/esm/types/0_story_report_option.js +25 -0
- package/esm/types/0_video_chat.js +2 -2
- package/esm/types/1_inline_keyboard_button.d.ts +2 -2
- package/esm/types/1_message_reaction.js +1 -1
- package/esm/types/1_sticker.js +1 -1
- package/esm/types/1_story_reaction.js +1 -1
- package/esm/types/1_story_report_result.d.ts +37 -0
- package/esm/types/1_story_report_result.d.ts.map +1 -0
- package/esm/types/1_story_report_result.js +36 -0
- package/esm/types/2_chat.js +2 -2
- package/esm/types/2_chat_member.js +3 -3
- package/esm/types/2_message_entity.js +1 -1
- package/esm/types/2_story_interactive_area.js +3 -3
- package/esm/types/3_chat_settings.js +1 -1
- package/esm/types/3_forward_header.js +3 -3
- package/esm/types/3_inline_query.js +1 -1
- package/esm/types/3_invite_link.js +2 -2
- package/esm/types/3_story.js +3 -3
- package/esm/types/4_gift.js +1 -1
- package/esm/types/5_gift_non_upgraded_information.js +8 -8
- package/esm/types/5_gift_upgraded_information.js +5 -5
- package/esm/types/6_poll_media.d.ts +1 -1
- package/esm/types/6_poll_media.d.ts.map +1 -1
- package/esm/types/7_inline_query_result.js +8 -8
- package/esm/types/7_poll_option.d.ts +1 -1
- package/esm/types/7_poll_option.d.ts.map +1 -1
- package/esm/types/8_inline_query_answer.js +1 -1
- package/esm/types/9_message.js +3 -3
- package/esm/utilities/0_env.js +1 -1
- package/package.json +1 -1
- package/script/3_types.d.ts +3 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +3 -0
- package/script/4_constants.d.ts +1 -0
- package/script/4_constants.d.ts.map +1 -1
- package/script/4_constants.js +2 -1
- package/script/client/0_markdown.js +4 -4
- package/script/client/0_params.d.ts +11 -1
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +100 -3
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/1_client_plain.d.ts +1 -1
- package/script/client/1_client_plain.d.ts.map +1 -1
- package/script/client/1_client_plain.js +24 -12
- package/script/client/2_client_encrypted.d.ts +6 -3
- package/script/client/2_client_encrypted.d.ts.map +1 -1
- package/script/client/2_client_encrypted.js +166 -49
- package/script/client/2_file_manager.js +1 -1
- package/script/client/2_network_statistics_manager.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +3 -2
- package/script/client/2_payment_manager.js +2 -2
- package/script/client/2_takeout_manager.js +2 -2
- package/script/client/2_update_manager.d.ts.map +1 -1
- package/script/client/2_update_manager.js +16 -11
- package/script/client/3_account_manager.js +3 -3
- package/script/client/3_message_manager.d.ts +11 -0
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +194 -73
- package/script/client/3_sticker_set_manager.js +3 -3
- package/script/client/3_video_chat_manager.js +1 -1
- package/script/client/4_callback_query_manager.js +2 -2
- package/script/client/4_chat_list_manager.js +3 -3
- package/script/client/4_chat_manager.d.ts +3 -2
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +11 -4
- package/script/client/4_contact_manager.js +1 -1
- package/script/client/4_gift_manager.js +11 -11
- package/script/client/4_inline_query_manager.js +1 -1
- package/script/client/4_story_manager.d.ts +3 -1
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +15 -1
- package/script/client/6_client.d.ts +102 -3
- package/script/client/6_client.d.ts.map +1 -1
- package/script/client/6_client.js +130 -2
- package/script/client/6_client_dispatcher.d.ts +100 -3
- package/script/client/6_client_dispatcher.d.ts.map +1 -1
- package/script/client/6_client_dispatcher.js +126 -1
- package/script/connection/0_get_tls_header.d.ts.map +1 -1
- package/script/connection/0_get_tls_header.js +19 -0
- package/script/connection/1_connection_web_socket.js +2 -2
- package/script/session/0_session_state.d.ts +1 -0
- package/script/session/0_session_state.d.ts.map +1 -1
- package/script/session/0_session_state.js +8 -4
- package/script/session/1_session.d.ts +1 -0
- package/script/session/1_session.d.ts.map +1 -1
- package/script/session/1_session.js +3 -0
- package/script/session/2_session_encrypted.d.ts +11 -6
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +20 -12
- package/script/storage/1_utilities.js +2 -2
- package/script/transport/2_transport_provider_web_socket.js +1 -1
- package/script/types/0_button_style.js +1 -1
- package/script/types/0_chat_member_rights.js +34 -34
- package/script/types/0_chat_photo.js +2 -2
- package/script/types/0_dice.d.ts +1 -1
- package/script/types/0_dice.d.ts.map +1 -1
- package/script/types/0_giveaway_parameters.js +1 -1
- package/script/types/0_live_stream_channel.d.ts +1 -1
- package/script/types/0_live_stream_channel.d.ts.map +1 -1
- package/script/types/0_report_reason.d.ts +53 -0
- package/script/types/0_report_reason.d.ts.map +1 -0
- package/script/types/0_report_reason.js +48 -0
- package/script/types/0_story_report_option.d.ts +26 -0
- package/script/types/0_story_report_option.d.ts.map +1 -0
- package/script/types/0_story_report_option.js +28 -0
- package/script/types/0_video_chat.js +2 -2
- package/script/types/1_inline_keyboard_button.d.ts +2 -2
- package/script/types/1_message_reaction.js +1 -1
- package/script/types/1_sticker.js +1 -1
- package/script/types/1_story_reaction.js +1 -1
- package/script/types/1_story_report_result.d.ts +37 -0
- package/script/types/1_story_report_result.d.ts.map +1 -0
- package/script/types/1_story_report_result.js +39 -0
- package/script/types/2_chat.js +2 -2
- package/script/types/2_chat_member.js +3 -3
- package/script/types/2_message_entity.js +1 -1
- package/script/types/2_story_interactive_area.js +3 -3
- package/script/types/3_chat_settings.js +1 -1
- package/script/types/3_forward_header.js +3 -3
- package/script/types/3_inline_query.js +1 -1
- package/script/types/3_invite_link.js +2 -2
- package/script/types/3_story.js +3 -3
- package/script/types/4_gift.js +1 -1
- package/script/types/5_gift_non_upgraded_information.js +8 -8
- package/script/types/5_gift_upgraded_information.js +5 -5
- package/script/types/6_poll_media.d.ts +1 -1
- package/script/types/6_poll_media.d.ts.map +1 -1
- package/script/types/7_inline_query_result.js +8 -8
- package/script/types/7_poll_option.d.ts +1 -1
- package/script/types/7_poll_option.d.ts.map +1 -1
- package/script/types/8_inline_query_answer.js +1 -1
- package/script/types/9_message.js +3 -3
- package/script/utilities/0_env.js +1 -1
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
1
20
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
21
|
import { concat, decodeHex } from "../0_deps.js";
|
|
3
22
|
import { hmacSha256, intFromBytes, intToBytes, modExp } from "../1_utilities.js";
|
|
@@ -54,7 +54,7 @@ export class ConnectionWebSocket {
|
|
|
54
54
|
const unlock = await mutex.lock();
|
|
55
55
|
const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : unreachable())).arrayBuffer());
|
|
56
56
|
this.#buffer = concat([this.#buffer, data]);
|
|
57
|
-
if (this.#nextResolve !== null && this.#buffer.
|
|
57
|
+
if (this.#nextResolve !== null && this.#buffer.byteLength >= this.#nextResolve[0]) {
|
|
58
58
|
this.#nextResolve[1].resolve();
|
|
59
59
|
this.#nextResolve = null;
|
|
60
60
|
}
|
|
@@ -96,7 +96,7 @@ export class ConnectionWebSocket {
|
|
|
96
96
|
const unlock = await this.#rMutex.lock();
|
|
97
97
|
try {
|
|
98
98
|
this.#assertConnected();
|
|
99
|
-
if (this.#buffer.
|
|
99
|
+
if (this.#buffer.byteLength < p.byteLength) {
|
|
100
100
|
await new Promise((resolve, reject) => this.#nextResolve = [p.byteLength, { resolve, reject }]);
|
|
101
101
|
}
|
|
102
102
|
const slice = this.#buffer.slice(0, p.byteLength);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_session_state.d.ts","sourceRoot":"","sources":["../../src/session/0_session_state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,qBAAa,YAAY;;IACvB,cAAc,SAAK;IACnB,UAAU,SAAM;IAIhB,aAAa,IAAI,MAAM;
|
|
1
|
+
{"version":3,"file":"0_session_state.d.ts","sourceRoot":"","sources":["../../src/session/0_session_state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,qBAAa,YAAY;;IACvB,cAAc,SAAK;IACnB,UAAU,SAAM;IAIhB,aAAa,IAAI,MAAM;IAIvB,oBAAoB,IAAI,MAAM;IAa9B,SAAS,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAS1C,KAAK;CAKN"}
|
|
@@ -24,16 +24,20 @@ export class SessionState {
|
|
|
24
24
|
#seqNo = 0;
|
|
25
25
|
#messageId = 0n;
|
|
26
26
|
nextMessageId() {
|
|
27
|
+
return this.#messageId = this.previewNextMessageId();
|
|
28
|
+
}
|
|
29
|
+
previewNextMessageId() {
|
|
27
30
|
const now = toUnixTimestamp(new Date()) + this.timeDifference;
|
|
28
31
|
const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
|
|
29
32
|
const newMessageId = (BigInt(Math.floor(now)) << 32n) || (BigInt(nanoseconds) << 2n);
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
let messageId = this.#messageId;
|
|
34
|
+
if (messageId >= newMessageId) {
|
|
35
|
+
messageId += 4n;
|
|
32
36
|
}
|
|
33
37
|
else {
|
|
34
|
-
|
|
38
|
+
messageId = newMessageId;
|
|
35
39
|
}
|
|
36
|
-
return
|
|
40
|
+
return messageId;
|
|
37
41
|
}
|
|
38
42
|
nextSeqNo(contentRelated) {
|
|
39
43
|
let seqNo = this.#seqNo * 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B,wIAAwI;IACxI,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IA6BD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B,wIAAwI;IACxI,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IA6BD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhD,oBAAoB,IAAI,MAAM;CAG/B"}
|
package/esm/session/1_session.js
CHANGED
|
@@ -17,23 +17,28 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
+
import { TransportError } from "../0_errors.js";
|
|
21
|
+
import { type MaybePromise } from "../1_utilities.js";
|
|
20
22
|
import { Mtproto } from "../2_tl.js";
|
|
21
23
|
import type { DC } from "../3_transport.js";
|
|
22
24
|
import { Session, type SessionParams } from "./1_session.js";
|
|
23
25
|
export interface Handlers {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
onTransportError?: (transportError: TransportError) => MaybePromise<void>;
|
|
27
|
+
onUpdate?: (body: Uint8Array) => MaybePromise<void>;
|
|
28
|
+
onNewServerSalt?: (serverSalt: bigint) => MaybePromise<void>;
|
|
29
|
+
onMessageFailed?: (id: bigint, reason: unknown) => MaybePromise<void>;
|
|
30
|
+
onPong?: (pong: Mtproto.pong) => MaybePromise<void>;
|
|
31
|
+
onRpcError?: (id: bigint, error: Mtproto.rpc_error) => MaybePromise<void>;
|
|
32
|
+
onRpcResult?: (id: bigint, result: Uint8Array) => MaybePromise<void>;
|
|
30
33
|
}
|
|
31
34
|
export declare class SessionEncrypted extends Session implements Session {
|
|
32
35
|
#private;
|
|
33
36
|
handlers: Handlers;
|
|
34
37
|
constructor(dc: DC, params?: SessionParams);
|
|
35
38
|
setAuthKey(key: Uint8Array<ArrayBuffer>): Promise<void>;
|
|
39
|
+
get id(): bigint;
|
|
36
40
|
get authKey(): Uint8Array<ArrayBuffer>;
|
|
41
|
+
get authKeyId(): bigint;
|
|
37
42
|
connect(): Promise<void>;
|
|
38
43
|
disconnect(): void;
|
|
39
44
|
send(body: Uint8Array<ArrayBuffer>): Promise<bigint>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAmB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAA+E,KAAK,YAAY,EAAsC,MAAM,mBAAmB,CAAC;AACvK,OAAO,EAAwD,OAAO,EAAuC,MAAM,YAAY,CAAC;AAChI,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAa7D,MAAM,WAAW,QAAQ;IACvB,gBAAgB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1E,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7D,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACtE;AAED,qBAAa,gBAAiB,SAAQ,OAAQ,YAAW,OAAO;;IAI9D,QAAQ,EAAE,QAAQ,CAAM;gBAiBZ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAQpC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;IAM7C,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAErC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B,UAAU,IAAI,IAAI;IA+ErB,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA6X3D"}
|
|
@@ -58,9 +58,15 @@ export class SessionEncrypted extends Session {
|
|
|
58
58
|
this.#authKeyId = intFromBytes(hash.slice(-8));
|
|
59
59
|
this.#authKey = key;
|
|
60
60
|
}
|
|
61
|
+
get id() {
|
|
62
|
+
return this.#id;
|
|
63
|
+
}
|
|
61
64
|
get authKey() {
|
|
62
65
|
return this.#authKey;
|
|
63
66
|
}
|
|
67
|
+
get authKeyId() {
|
|
68
|
+
return this.#authKeyId;
|
|
69
|
+
}
|
|
64
70
|
async connect() {
|
|
65
71
|
if (!this.isConnected) {
|
|
66
72
|
this.#rejectAllPending(new ConnectionError("The connection was closed."));
|
|
@@ -79,6 +85,8 @@ export class SessionEncrypted extends Session {
|
|
|
79
85
|
super.disconnect();
|
|
80
86
|
this.state.reset();
|
|
81
87
|
this.#id = getRandomId();
|
|
88
|
+
this.#receiveLoop.abort();
|
|
89
|
+
this.#sendLoop.abort();
|
|
82
90
|
this.#pingLoop.abort();
|
|
83
91
|
this.#awakeSendLoop?.();
|
|
84
92
|
this.#rejectAllPending(new ConnectionError("The connection was disconnected."));
|
|
@@ -137,11 +145,11 @@ export class SessionEncrypted extends Session {
|
|
|
137
145
|
return;
|
|
138
146
|
}
|
|
139
147
|
// message was not sent by us
|
|
140
|
-
this.handlers.onMessageFailed?.(id, reason);
|
|
148
|
+
drop(this.handlers.onMessageFailed?.(id, reason));
|
|
141
149
|
}
|
|
142
150
|
#setServerSalt(newServerSalt) {
|
|
143
151
|
this.state.serverSalt = newServerSalt;
|
|
144
|
-
this.handlers.onNewServerSalt?.(newServerSalt);
|
|
152
|
+
drop(this.handlers.onNewServerSalt?.(newServerSalt));
|
|
145
153
|
}
|
|
146
154
|
async send(body) {
|
|
147
155
|
if (!this.isDisconnected && !this.isConnected) {
|
|
@@ -176,7 +184,7 @@ export class SessionEncrypted extends Session {
|
|
|
176
184
|
payloadWriter.writeInt64(this.state.serverSalt);
|
|
177
185
|
payloadWriter.writeInt64(this.#id);
|
|
178
186
|
payloadWriter.write(await serializeMessage(message));
|
|
179
|
-
payloadWriter.write(new Uint8Array(mod(-(payloadWriter.buffer.
|
|
187
|
+
payloadWriter.write(new Uint8Array(mod(-(payloadWriter.buffer.byteLength + 12), 16) + 12));
|
|
180
188
|
const payload = payloadWriter.buffer;
|
|
181
189
|
const messageKey = (await sha256(concat([this.#authKey.subarray(88, 120), payload]))).subarray(8, 24);
|
|
182
190
|
const a = await sha256(concat([messageKey, this.#authKey.subarray(0, 36)]));
|
|
@@ -301,11 +309,11 @@ export class SessionEncrypted extends Session {
|
|
|
301
309
|
if (!this.isConnected) {
|
|
302
310
|
this.#LreceiveLoop.debug("aborting as not connected");
|
|
303
311
|
loop.abort();
|
|
304
|
-
return;
|
|
305
312
|
}
|
|
306
|
-
else {
|
|
307
|
-
|
|
313
|
+
else if (err instanceof TransportError) {
|
|
314
|
+
await this.handlers.onTransportError?.(err);
|
|
308
315
|
}
|
|
316
|
+
return;
|
|
309
317
|
}
|
|
310
318
|
try {
|
|
311
319
|
if (message.body instanceof Uint8Array) {
|
|
@@ -322,7 +330,7 @@ export class SessionEncrypted extends Session {
|
|
|
322
330
|
//// RECEIVE LOOP HANDLERS ////
|
|
323
331
|
async #onMessage(msgId, body, containerId) {
|
|
324
332
|
this.#LreceiveLoop.debug("received message with ID", msgId, "and size", body.byteLength, "inside", ...(containerId === null ? ["no container"] : ["container", containerId]));
|
|
325
|
-
const logger = this.#LreceiveLoop.branch(msgId
|
|
333
|
+
const logger = this.#LreceiveLoop.branch(String(msgId));
|
|
326
334
|
let reader = new TLReader(body);
|
|
327
335
|
let id = reader.readInt32(false);
|
|
328
336
|
if (id === GZIP_PACKED) {
|
|
@@ -331,13 +339,13 @@ export class SessionEncrypted extends Session {
|
|
|
331
339
|
id = reader.readInt32(false);
|
|
332
340
|
}
|
|
333
341
|
if (id === RPC_RESULT) {
|
|
334
|
-
this.#onRpcResult(msgId, reader.buffer, logger);
|
|
342
|
+
await this.#onRpcResult(msgId, reader.buffer, logger);
|
|
335
343
|
return;
|
|
336
344
|
}
|
|
337
345
|
if (!Mtproto.schema.identifierToName[id]) {
|
|
338
346
|
logger.debug("identified body as a non-MTProto constructor");
|
|
339
347
|
reader.unreadInt32();
|
|
340
|
-
this.handlers.onUpdate?.(reader.buffer);
|
|
348
|
+
await this.handlers.onUpdate?.(reader.buffer);
|
|
341
349
|
return;
|
|
342
350
|
}
|
|
343
351
|
let type;
|
|
@@ -390,10 +398,10 @@ export class SessionEncrypted extends Session {
|
|
|
390
398
|
if (id === RPC_ERROR) {
|
|
391
399
|
logger.debug("received rpc_error from message", msgId);
|
|
392
400
|
const error = await Mtproto.deserializeType("rpc_error", reader);
|
|
393
|
-
this.handlers.onRpcError?.(reqMsgId, error);
|
|
401
|
+
await this.handlers.onRpcError?.(reqMsgId, error);
|
|
394
402
|
}
|
|
395
403
|
else {
|
|
396
|
-
this.handlers.onRpcResult?.(reqMsgId, reader.buffer);
|
|
404
|
+
await this.handlers.onRpcResult?.(reqMsgId, reader.buffer);
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
407
|
#onMsgDetailedInfo(msgDetailedInfo, logger) {
|
|
@@ -445,7 +453,7 @@ export class SessionEncrypted extends Session {
|
|
|
445
453
|
}
|
|
446
454
|
else {
|
|
447
455
|
// pong is not ours
|
|
448
|
-
this.handlers.onPong?.(pong);
|
|
456
|
+
drop(this.handlers.onPong?.(pong));
|
|
449
457
|
}
|
|
450
458
|
}
|
|
451
459
|
#onNewSessionCreated(msgId, newSessionCreated) {
|
|
@@ -67,7 +67,7 @@ export function fromString(string) {
|
|
|
67
67
|
const [type, value] = [Number(string[0]), string.slice(1)];
|
|
68
68
|
switch (type) {
|
|
69
69
|
case ValueType.Boolean:
|
|
70
|
-
return
|
|
70
|
+
return !!Number(value);
|
|
71
71
|
case ValueType.Number:
|
|
72
72
|
return Number(value);
|
|
73
73
|
case ValueType.String:
|
|
@@ -91,7 +91,7 @@ export function fromString(string) {
|
|
|
91
91
|
return arr;
|
|
92
92
|
}
|
|
93
93
|
case ValueType.Map:
|
|
94
|
-
//deno-lint-ignore no-explicit-any
|
|
94
|
+
// deno-lint-ignore no-explicit-any
|
|
95
95
|
return Object.fromEntries(fromString(`${ValueType.Array}${value}`));
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -33,7 +33,7 @@ const dcToNameMap = {
|
|
|
33
33
|
export const transportProviderWebSocket = (params) => {
|
|
34
34
|
return ({ dc, isMedia }) => {
|
|
35
35
|
params ??= {};
|
|
36
|
-
params.wss ??= typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost"
|
|
36
|
+
params.wss ??= !(typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost");
|
|
37
37
|
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${isMedia ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
38
38
|
const connection = new ConnectionWebSocket(url);
|
|
39
39
|
const dcId = getDcId(dc, isMedia);
|
|
@@ -32,5 +32,5 @@ export function buttonStyleToTlObject(buttonStyle) {
|
|
|
32
32
|
if (buttonStyle === undefined) {
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
|
-
return { _: "keyboardButtonStyle", bg_danger: buttonStyle.background === "danger"
|
|
35
|
+
return { _: "keyboardButtonStyle", bg_danger: buttonStyle.background === "danger" || undefined, bg_primary: buttonStyle.background === "primary" || undefined, bg_success: buttonStyle.background === "success" || undefined, icon: buttonStyle.customEmojiId ? BigInt(buttonStyle.customEmojiId) : undefined };
|
|
36
36
|
}
|
|
@@ -20,45 +20,45 @@
|
|
|
20
20
|
import { cleanObject } from "../1_utilities.js";
|
|
21
21
|
export function constructChatMemberRights(rights) {
|
|
22
22
|
return cleanObject({
|
|
23
|
-
canSendMessages: rights.send_messages
|
|
24
|
-
canSendAudio: rights.send_audios
|
|
25
|
-
canSendDocuments: rights.send_docs
|
|
26
|
-
canSendPhotos: rights.send_photos
|
|
27
|
-
canSendVideos: rights.send_messages
|
|
28
|
-
canSendVideoNotes: rights.send_roundvideos
|
|
29
|
-
canSendVoice: rights.send_voices
|
|
30
|
-
canSendPolls: rights.send_polls
|
|
31
|
-
canSendStickers: rights.send_stickers
|
|
32
|
-
canSendAnimations: rights.send_gifs
|
|
33
|
-
canSendGames: rights.send_games
|
|
34
|
-
canSendInlineBotResults: rights.send_inline
|
|
35
|
-
canAddWebPagePreviews: rights.embed_links
|
|
36
|
-
canChangeInfo: rights.change_info
|
|
37
|
-
canInviteUsers: rights.invite_users
|
|
38
|
-
canPinMessages: rights.pin_messages
|
|
39
|
-
canManageTopics: rights.manage_topics
|
|
23
|
+
canSendMessages: !!rights.send_messages,
|
|
24
|
+
canSendAudio: !!rights.send_audios,
|
|
25
|
+
canSendDocuments: !!rights.send_docs,
|
|
26
|
+
canSendPhotos: !!rights.send_photos,
|
|
27
|
+
canSendVideos: !!rights.send_messages,
|
|
28
|
+
canSendVideoNotes: !!rights.send_roundvideos,
|
|
29
|
+
canSendVoice: !!rights.send_voices,
|
|
30
|
+
canSendPolls: !!rights.send_polls,
|
|
31
|
+
canSendStickers: !!rights.send_stickers,
|
|
32
|
+
canSendAnimations: rights.send_gifs || undefined,
|
|
33
|
+
canSendGames: rights.send_games || undefined,
|
|
34
|
+
canSendInlineBotResults: rights.send_inline || undefined,
|
|
35
|
+
canAddWebPagePreviews: rights.embed_links || undefined,
|
|
36
|
+
canChangeInfo: rights.change_info || undefined,
|
|
37
|
+
canInviteUsers: rights.invite_users || undefined,
|
|
38
|
+
canPinMessages: rights.pin_messages || undefined,
|
|
39
|
+
canManageTopics: rights.manage_topics || undefined,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
export function chatMemberRightsToTlObject(rights, until) {
|
|
43
43
|
return {
|
|
44
44
|
_: "chatBannedRights",
|
|
45
45
|
until_date: until ?? 0,
|
|
46
|
-
send_messages: rights?.canSendMessages
|
|
47
|
-
send_audios: rights?.canSendAudio
|
|
48
|
-
send_docs: rights?.canSendDocuments
|
|
49
|
-
send_photos: rights?.canSendPhotos
|
|
50
|
-
send_videos: rights?.canSendVideos
|
|
51
|
-
send_roundvideos: rights?.canSendVideoNotes
|
|
52
|
-
send_voices: rights?.canSendVoice
|
|
53
|
-
send_polls: rights?.canSendPolls
|
|
54
|
-
send_stickers: rights?.canSendStickers
|
|
55
|
-
send_gifs: rights?.canSendAnimations
|
|
56
|
-
send_games: rights?.canSendGames
|
|
57
|
-
send_inline: rights?.canSendInlineBotResults
|
|
58
|
-
embed_links: rights?.canAddWebPagePreviews
|
|
59
|
-
change_info: rights?.canChangeInfo
|
|
60
|
-
invite_users: rights?.canInviteUsers
|
|
61
|
-
pin_messages: rights?.canPinMessages
|
|
62
|
-
manage_topics: rights?.canManageTopics
|
|
46
|
+
send_messages: rights?.canSendMessages === false || undefined,
|
|
47
|
+
send_audios: rights?.canSendAudio === false || undefined,
|
|
48
|
+
send_docs: rights?.canSendDocuments === false || undefined,
|
|
49
|
+
send_photos: rights?.canSendPhotos === false || undefined,
|
|
50
|
+
send_videos: rights?.canSendVideos === false || undefined,
|
|
51
|
+
send_roundvideos: rights?.canSendVideoNotes === false || undefined,
|
|
52
|
+
send_voices: rights?.canSendVoice === false || undefined,
|
|
53
|
+
send_polls: rights?.canSendPolls === false || undefined,
|
|
54
|
+
send_stickers: rights?.canSendStickers === false || undefined,
|
|
55
|
+
send_gifs: rights?.canSendAnimations === false || undefined,
|
|
56
|
+
send_games: rights?.canSendGames === false || undefined,
|
|
57
|
+
send_inline: rights?.canSendInlineBotResults === false || undefined,
|
|
58
|
+
embed_links: rights?.canAddWebPagePreviews === false || undefined,
|
|
59
|
+
change_info: rights?.canChangeInfo === false || undefined,
|
|
60
|
+
invite_users: rights?.canInviteUsers === false || undefined,
|
|
61
|
+
pin_messages: rights?.canPinMessages === false || undefined,
|
|
62
|
+
manage_topics: rights?.canManageTopics === false || undefined,
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -51,8 +51,8 @@ export function constructChatPhoto(photo, chatId, chatAccessHash) {
|
|
|
51
51
|
smallFileUniqueId,
|
|
52
52
|
bigFileId,
|
|
53
53
|
bigFileUniqueId,
|
|
54
|
-
hasVideo: photo.has_video
|
|
55
|
-
isPersonal: photo.personal
|
|
54
|
+
hasVideo: !!photo.has_video,
|
|
55
|
+
isPersonal: !!photo.personal,
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
}
|
package/esm/types/0_dice.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import type { Api } from "../2_tl.js";
|
|
21
21
|
/** A rolled dice. */
|
|
22
22
|
export interface Dice {
|
|
23
|
-
/** The emoji on which the dice is based
|
|
23
|
+
/** The emoji on which the dice is based. */
|
|
24
24
|
emoji: string;
|
|
25
25
|
/** The result of the roll, which is in the range of 1-6 for the emojis "🎲", "🎯" and "🎳", 1-5 for the emojis "🏀" and "⚽", and 1-64 for the emoji "🎰". */
|
|
26
26
|
value: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_dice.d.ts","sourceRoot":"","sources":["../../src/types/0_dice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,WAAW,IAAI;IACnB
|
|
1
|
+
{"version":3,"file":"0_dice.d.ts","sourceRoot":"","sources":["../../src/types/0_dice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,WAAW,IAAI;IACnB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,6JAA6J;IAC7J,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAE/D"}
|
|
@@ -22,7 +22,7 @@ export function constructGiveawayParameters(g) {
|
|
|
22
22
|
const countries = g.countries_iso2 ?? [];
|
|
23
23
|
const boostedChatId = Api.peerToChatId({ _: "peerChannel", channel_id: g.channels[0] });
|
|
24
24
|
const additionalChatIds = g.channels.slice(1).map((v) => Api.peerToChatId({ _: "peerChannel", channel_id: v }));
|
|
25
|
-
const onlyNewMembers = g.only_new_subscribers
|
|
25
|
+
const onlyNewMembers = !!g.only_new_subscribers;
|
|
26
26
|
const winnerSelectionDate = g.until_date;
|
|
27
27
|
return { boostedChatId, additionalChatIds, winnerSelectionDate, onlyNewMembers, countries };
|
|
28
28
|
}
|
|
@@ -22,7 +22,7 @@ import type { Api } from "../2_tl.js";
|
|
|
22
22
|
export interface LiveStreamChannel {
|
|
23
23
|
/** The live stream channel's unique identifier. */
|
|
24
24
|
id: number;
|
|
25
|
-
/** The scale of the live stream channel's chunks. Duration of each chunk is equal to 1000 / 2 ^ scale.
|
|
25
|
+
/** The scale of the live stream channel's chunks. Duration of each chunk is equal to 1000 / 2 ^ scale. */
|
|
26
26
|
scale: number;
|
|
27
27
|
/** The live stream channel's last timestamp. */
|
|
28
28
|
timestamp: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_live_stream_channel.d.ts","sourceRoot":"","sources":["../../src/types/0_live_stream_channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,6BAA6B;AAC7B,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,
|
|
1
|
+
{"version":3,"file":"0_live_stream_channel.d.ts","sourceRoot":"","sources":["../../src/types/0_live_stream_channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,6BAA6B;AAC7B,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,GAAG,CAAC,sBAAsB,GAAG,iBAAiB,CAMjG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import type { Api } from "../2_tl.js";
|
|
21
|
+
export interface ReportReasonSpam {
|
|
22
|
+
type: "spam";
|
|
23
|
+
}
|
|
24
|
+
export interface ReportReasonViolence {
|
|
25
|
+
type: "violence";
|
|
26
|
+
}
|
|
27
|
+
export interface ReportReasonPornography {
|
|
28
|
+
type: "pornography";
|
|
29
|
+
}
|
|
30
|
+
export interface ReportReasonChildAbuse {
|
|
31
|
+
type: "childAbuse";
|
|
32
|
+
}
|
|
33
|
+
export interface ReportReasonOther {
|
|
34
|
+
type: "other";
|
|
35
|
+
}
|
|
36
|
+
export interface ReportReasonCopyright {
|
|
37
|
+
type: "copyright";
|
|
38
|
+
}
|
|
39
|
+
export interface ReportReasonLocationIrrelevant {
|
|
40
|
+
type: "locationIrrelevant";
|
|
41
|
+
}
|
|
42
|
+
export interface ReportReasonFake {
|
|
43
|
+
type: "fake";
|
|
44
|
+
}
|
|
45
|
+
export interface ReportReasonIllegalDrugs {
|
|
46
|
+
type: "illegalDrugs";
|
|
47
|
+
}
|
|
48
|
+
export interface ReportReasonPersonalDetails {
|
|
49
|
+
type: "personalDetails";
|
|
50
|
+
}
|
|
51
|
+
export type ReportReason = ReportReasonSpam | ReportReasonViolence | ReportReasonPornography | ReportReasonChildAbuse | ReportReasonOther | ReportReasonCopyright | ReportReasonLocationIrrelevant | ReportReasonFake | ReportReasonIllegalDrugs | ReportReasonPersonalDetails;
|
|
52
|
+
export declare function reportReasonToTlObject(reportReason: ReportReason): Api.ReportReason;
|
|
53
|
+
//# sourceMappingURL=0_report_reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0_report_reason.d.ts","sourceRoot":"","sources":["../../src/types/0_report_reason.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,uBAAuB,GAAG,sBAAsB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,8BAA8B,GAAG,gBAAgB,GAAG,wBAAwB,GAAG,2BAA2B,CAAC;AAE/Q,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,GAAG,CAAC,YAAY,CAyBnF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import { unreachable } from "../0_deps.js";
|
|
21
|
+
export function reportReasonToTlObject(reportReason) {
|
|
22
|
+
switch (reportReason.type) {
|
|
23
|
+
case "spam":
|
|
24
|
+
return { _: "inputReportReasonSpam" };
|
|
25
|
+
case "violence":
|
|
26
|
+
return { _: "inputReportReasonViolence" };
|
|
27
|
+
case "pornography":
|
|
28
|
+
return { _: "inputReportReasonPornography" };
|
|
29
|
+
case "childAbuse":
|
|
30
|
+
return { _: "inputReportReasonChildAbuse" };
|
|
31
|
+
case "other":
|
|
32
|
+
return { _: "inputReportReasonOther" };
|
|
33
|
+
case "copyright":
|
|
34
|
+
return { _: "inputReportReasonCopyright" };
|
|
35
|
+
case "locationIrrelevant":
|
|
36
|
+
return { _: "inputReportReasonGeoIrrelevant" };
|
|
37
|
+
case "fake":
|
|
38
|
+
return { _: "inputReportReasonFake" };
|
|
39
|
+
case "illegalDrugs":
|
|
40
|
+
return { _: "inputReportReasonIllegalDrugs" };
|
|
41
|
+
case "personalDetails":
|
|
42
|
+
return { _: "inputReportReasonPersonalDetails" };
|
|
43
|
+
}
|
|
44
|
+
unreachable();
|
|
45
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import type { Api } from "../2_tl.js";
|
|
21
|
+
export interface StoryReportOption {
|
|
22
|
+
text: string;
|
|
23
|
+
option: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function constructStoryReportOption(rr: Api.messageReportOption): StoryReportOption;
|
|
26
|
+
//# sourceMappingURL=0_story_report_option.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0_story_report_option.d.ts","sourceRoot":"","sources":["../../src/types/0_story_report_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,GAAG,CAAC,mBAAmB,GAAG,iBAAiB,CAIzF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import { base64EncodeUrlSafe } from "../1_utilities.js";
|
|
21
|
+
export function constructStoryReportOption(rr) {
|
|
22
|
+
const text = rr.text;
|
|
23
|
+
const option = base64EncodeUrlSafe(rr.option);
|
|
24
|
+
return { text, option };
|
|
25
|
+
}
|
|
@@ -29,7 +29,7 @@ export function constructVideoChat(call) {
|
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
const title = call.title ?? "";
|
|
32
|
-
const liveStream = call.rtmp_stream
|
|
32
|
+
const liveStream = !!call.rtmp_stream;
|
|
33
33
|
const participantCount = call.participants_count;
|
|
34
34
|
if (call.schedule_date) {
|
|
35
35
|
return {
|
|
@@ -47,7 +47,7 @@ export function constructVideoChat(call) {
|
|
|
47
47
|
id,
|
|
48
48
|
title,
|
|
49
49
|
isLiveStream: liveStream,
|
|
50
|
-
isRecording: call.record_video_active
|
|
50
|
+
isRecording: !!call.record_video_active,
|
|
51
51
|
participantCount,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -102,14 +102,14 @@ export interface InlineKeyboardButtonGame extends _InlineKeyboardButtonBase {
|
|
|
102
102
|
type: "callbackGame";
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* An inline keyboard that, when pressed, initiates a payment.
|
|
105
|
+
* An inline keyboard button that, when pressed, initiates a payment.
|
|
106
106
|
* @unlisted
|
|
107
107
|
*/
|
|
108
108
|
export interface InlineKeyboardButtonPay extends _InlineKeyboardButtonBase {
|
|
109
109
|
type: "pay";
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
* An inline keyboard that, when pressed, copies the text inside its `copy` field.
|
|
112
|
+
* An inline keyboard button that, when pressed, copies the text inside its `copy` field.
|
|
113
113
|
* @unlisted
|
|
114
114
|
*/
|
|
115
115
|
export interface InlineKeyboardButtonCopy extends _InlineKeyboardButtonBase {
|