@mtkruto/node 0.1.200 → 0.1.300
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 -1
- package/esm/0_deps.js +2 -1
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_errors.js +3 -3
- package/esm/client/0_markdown.js +5 -5
- package/esm/client/0_utilities.d.ts +6 -0
- package/esm/client/0_utilities.js +35 -4
- package/esm/client/1_account_manager.js +4 -4
- package/esm/client/1_client_encrypted.js +4 -4
- package/esm/client/1_client_plain.js +3 -3
- package/esm/client/1_file_manager.js +6 -5
- package/esm/client/1_reaction_manager.js +2 -2
- package/esm/client/1_update_manager.js +9 -8
- package/esm/client/2_message_manager.js +47 -24
- package/esm/client/3_callback_query_manager.js +2 -0
- package/esm/client/3_chat_list_manager.js +13 -12
- package/esm/client/3_inline_query_manager.js +4 -2
- package/esm/client/3_story_manager.js +7 -5
- package/esm/client/4_client.d.ts +5 -8
- package/esm/client/4_client.js +19 -27
- package/esm/connection/1_connection_web_socket.js +3 -2
- package/{script/deps/deno.land/x/tgcrypto@0.3.3 → esm/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
- package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.js +6 -5
- package/esm/storage/1_utilities.d.ts +0 -1
- package/esm/storage/1_utilities.js +2 -3
- package/esm/storage/2_storage_local_storage.js +1 -4
- package/esm/storage/2_storage_session_storage.js +1 -4
- package/esm/tl/3_utilities.js +5 -4
- package/esm/transport/2_transport_provider.js +4 -4
- package/esm/types/0_message_entity.js +3 -3
- package/esm/types/0_message_search_filter.js +2 -2
- package/esm/types/0_reaction.js +2 -2
- package/esm/types/1_bot_command_scope.js +3 -3
- package/esm/types/1_chat_p.js +3 -2
- package/esm/types/1_keyboard_button.js +3 -3
- package/esm/types/1_message_reaction.js +2 -2
- package/esm/types/1_story_privacy.js +3 -3
- package/esm/types/2_chat_member.js +6 -5
- package/esm/types/2_chosen_inline_result.js +3 -2
- package/esm/types/2_inactive_chat.js +3 -2
- package/esm/types/2_inline_keyboard_button.js +3 -3
- package/esm/types/2_inline_query.js +3 -3
- package/esm/types/2_invite_link.js +3 -2
- package/esm/types/2_story_content.js +5 -5
- package/esm/types/2_story_interactive_area.js +5 -5
- package/esm/types/3_chat_member_updated.js +4 -3
- package/esm/types/3_reply_markup.js +4 -3
- package/esm/types/3_story.js +3 -2
- package/esm/types/4_inline_query_result.js +5 -5
- package/esm/types/4_message.js +17 -16
- package/esm/types/5_callback_query.js +4 -3
- package/esm/types/5_chat.js +8 -7
- package/esm/types/_file_id.js +9 -8
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +25 -0
- package/esm/utilities/0_logger.d.ts +8 -0
- package/esm/utilities/0_logger.js +9 -5
- package/esm/utilities/1_math.d.ts +1 -0
- package/esm/utilities/1_math.js +51 -0
- package/esm/utilities/1_misc.js +2 -2
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -1
- package/script/0_deps.js +3 -3
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_errors.js +3 -3
- package/script/client/0_markdown.js +5 -5
- package/script/client/0_utilities.d.ts +6 -0
- package/script/client/0_utilities.js +41 -4
- package/script/client/1_account_manager.js +4 -4
- package/script/client/1_client_encrypted.js +2 -2
- package/script/client/1_client_plain.js +2 -2
- package/script/client/1_file_manager.js +5 -4
- package/script/client/1_reaction_manager.js +2 -2
- package/script/client/1_update_manager.js +8 -7
- package/script/client/2_message_manager.js +51 -28
- package/script/client/3_callback_query_manager.js +2 -0
- package/script/client/3_chat_list_manager.js +12 -11
- package/script/client/3_inline_query_manager.js +4 -2
- package/script/client/3_story_manager.js +4 -2
- package/script/client/4_client.d.ts +5 -8
- package/script/client/4_client.js +18 -26
- package/script/connection/1_connection_web_socket.js +2 -1
- package/{esm/deps/deno.land/x/tgcrypto@0.3.3 → script/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
- package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
- package/script/mod.d.ts +1 -1
- package/script/mod.js +2 -1
- package/script/storage/0_storage.js +5 -4
- package/script/storage/1_utilities.d.ts +0 -1
- package/script/storage/1_utilities.js +3 -4
- package/script/storage/2_storage_local_storage.js +0 -3
- package/script/storage/2_storage_session_storage.js +0 -3
- package/script/tl/3_utilities.js +4 -3
- package/script/transport/2_transport_provider.js +4 -4
- package/script/types/0_message_entity.js +3 -3
- package/script/types/0_message_search_filter.js +2 -2
- package/script/types/0_reaction.js +2 -2
- package/script/types/1_bot_command_scope.js +3 -3
- package/script/types/1_chat_p.js +2 -1
- package/script/types/1_keyboard_button.js +3 -3
- package/script/types/1_message_reaction.js +2 -2
- package/script/types/1_story_privacy.js +3 -3
- package/script/types/2_chat_member.js +5 -4
- package/script/types/2_chosen_inline_result.js +2 -1
- package/script/types/2_inactive_chat.js +2 -1
- package/script/types/2_inline_keyboard_button.js +3 -3
- package/script/types/2_inline_query.js +3 -3
- package/script/types/2_invite_link.js +2 -1
- package/script/types/2_story_content.js +5 -5
- package/script/types/2_story_interactive_area.js +5 -5
- package/script/types/3_chat_member_updated.js +3 -2
- package/script/types/3_reply_markup.js +3 -2
- package/script/types/3_story.js +2 -1
- package/script/types/4_inline_query_result.js +5 -5
- package/script/types/4_message.js +16 -15
- package/script/types/5_callback_query.js +3 -2
- package/script/types/5_chat.js +7 -6
- package/script/types/_file_id.js +8 -7
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +27 -1
- package/script/utilities/0_logger.d.ts +8 -0
- package/script/utilities/0_logger.js +11 -6
- package/script/utilities/1_math.d.ts +1 -0
- package/script/utilities/1_math.js +55 -0
- package/script/utilities/1_misc.js +2 -2
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -203
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -274
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -51
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -191
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -385
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -431
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1046
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -52
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -122
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -24
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -121
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -30
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2127
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -108
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -1
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -95
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -128
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -110
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -120
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -6
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -110
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -75
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
- package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -101
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
- package/esm/utilities/0_control.d.ts +0 -1
- package/esm/utilities/0_control.js +0 -3
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -207
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -301
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -55
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -222
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -404
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -438
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1052
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -88
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -128
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -30
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -129
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -32
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2129
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -110
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -3
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -114
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -134
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -118
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -129
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -22
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -119
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -86
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
- package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -112
- package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
- package/script/utilities/0_control.d.ts +0 -1
- package/script/utilities/0_control.js +0 -7
- /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
package/esm/types/4_message.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, fromUnixTimestamp, getLogger, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
2
3
|
import { as, types } from "../2_tl.js";
|
|
3
4
|
import { FileType, toUniqueFileId } from "./_file_id.js";
|
|
4
5
|
import { serializeFileId } from "./_file_id.js";
|
|
@@ -69,7 +70,7 @@ const keys = {
|
|
|
69
70
|
export function assertMessageType(message, type) {
|
|
70
71
|
for (const key of keys[type]) {
|
|
71
72
|
if (!(key in message) || message[key] === undefined) {
|
|
72
|
-
|
|
73
|
+
unreachable();
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
return message;
|
|
@@ -81,7 +82,7 @@ async function getSender(message_, getEntity) {
|
|
|
81
82
|
return { from: constructUser(entity) };
|
|
82
83
|
}
|
|
83
84
|
else {
|
|
84
|
-
|
|
85
|
+
unreachable();
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
else if (message_.from_id instanceof types.PeerChannel) {
|
|
@@ -90,7 +91,7 @@ async function getSender(message_, getEntity) {
|
|
|
90
91
|
return { senderChat: constructChatP(entity) };
|
|
91
92
|
}
|
|
92
93
|
else {
|
|
93
|
-
|
|
94
|
+
unreachable();
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
}
|
|
@@ -121,7 +122,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
121
122
|
Object.assign(message, await getSender(message_, getEntity));
|
|
122
123
|
if (message_.action instanceof types.MessageActionChatAddUser || message_.action instanceof types.MessageActionChatJoinedByLink || message_.action instanceof types.MessageActionChatJoinedByRequest) {
|
|
123
124
|
const newChatMembers = new Array();
|
|
124
|
-
const users = "users" in message_.action ? message_.action.users : [message_.from_id && "user_id" in message_.from_id ? message_.from_id.user_id :
|
|
125
|
+
const users = "users" in message_.action ? message_.action.users : [message_.from_id && "user_id" in message_.from_id ? message_.from_id.user_id : unreachable()];
|
|
125
126
|
for (const user_ of users) {
|
|
126
127
|
const entity = await getEntity(new types.PeerUser({ user_id: user_ }));
|
|
127
128
|
if (entity) {
|
|
@@ -129,7 +130,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
129
130
|
newChatMembers.push(user);
|
|
130
131
|
}
|
|
131
132
|
else {
|
|
132
|
-
|
|
133
|
+
unreachable();
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
return { ...message, newChatMembers };
|
|
@@ -176,7 +177,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
176
177
|
return { ...message, supergroupCreated };
|
|
177
178
|
}
|
|
178
179
|
else {
|
|
179
|
-
//
|
|
180
|
+
// unreachable();
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
else if (message_.action instanceof types.MessageActionChatMigrateTo) {
|
|
@@ -251,7 +252,7 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
251
252
|
}
|
|
252
253
|
export async function constructMessage(message_, getEntity, getMessage, getStickerSetName, getReply_ = true, business) {
|
|
253
254
|
if (!(message_ instanceof types.Message) && !(message_ instanceof types.MessageService)) {
|
|
254
|
-
|
|
255
|
+
unreachable();
|
|
255
256
|
}
|
|
256
257
|
let link;
|
|
257
258
|
let chat_ = null;
|
|
@@ -261,7 +262,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
261
262
|
chat_ = constructChatP(entity);
|
|
262
263
|
}
|
|
263
264
|
else {
|
|
264
|
-
|
|
265
|
+
unreachable();
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
else if (message_.peer_id instanceof types.PeerChat) {
|
|
@@ -270,7 +271,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
270
271
|
chat_ = constructChatP(entity);
|
|
271
272
|
}
|
|
272
273
|
else {
|
|
273
|
-
|
|
274
|
+
unreachable();
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
else if (message_.peer_id instanceof types.PeerChannel) {
|
|
@@ -280,11 +281,11 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
280
281
|
chat_ = constructChatP(entity);
|
|
281
282
|
}
|
|
282
283
|
else {
|
|
283
|
-
|
|
284
|
+
unreachable();
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
else {
|
|
287
|
-
|
|
288
|
+
unreachable();
|
|
288
289
|
}
|
|
289
290
|
if (message_ instanceof types.MessageService) {
|
|
290
291
|
return await constructServiceMessage(message_, chat_, getEntity, getMessage);
|
|
@@ -331,7 +332,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
331
332
|
message.viaBot = constructUser(viaBot);
|
|
332
333
|
}
|
|
333
334
|
else {
|
|
334
|
-
|
|
335
|
+
unreachable();
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
338
|
if (message_.via_business_bot_id != undefined) {
|
|
@@ -340,7 +341,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
340
341
|
message.viaBusinessBot = constructUser(viaBusinessBot);
|
|
341
342
|
}
|
|
342
343
|
else {
|
|
343
|
-
|
|
344
|
+
unreachable();
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
347
|
if (message_.post_author != undefined) {
|
|
@@ -396,7 +397,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
396
397
|
let m = null;
|
|
397
398
|
if (message_.media instanceof types.MessageMediaPhoto) {
|
|
398
399
|
if (!message_.media.photo) {
|
|
399
|
-
|
|
400
|
+
unreachable();
|
|
400
401
|
}
|
|
401
402
|
const photo = constructPhoto(message_.media.photo[as](types.Photo));
|
|
402
403
|
m = { ...messageMedia, photo };
|
|
@@ -486,7 +487,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
486
487
|
m = { ...messageText, linkPreview };
|
|
487
488
|
}
|
|
488
489
|
else {
|
|
489
|
-
m = { ...message, linkPreview: { ...linkPreview, url: linkPreview.url ? linkPreview.url :
|
|
490
|
+
m = { ...message, linkPreview: { ...linkPreview, url: linkPreview.url ? linkPreview.url : unreachable() } };
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
493
|
else if (message_.media instanceof types.MessageMediaGiveaway) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
1
2
|
import { InputError } from "../0_errors.js";
|
|
2
|
-
import { base64DecodeUrlSafe, base64EncodeUrlSafe, cleanObject
|
|
3
|
+
import { base64DecodeUrlSafe, base64EncodeUrlSafe, cleanObject } from "../1_utilities.js";
|
|
3
4
|
import { peerToChatId, serialize, TLReader, types } from "../2_tl.js";
|
|
4
5
|
import { constructUser } from "./1_user.js";
|
|
5
6
|
const ERR_INVALID_INLINE_MESSAGE_ID = new InputError("Invalid inline message ID");
|
|
@@ -20,7 +21,7 @@ export function deserializeInlineMessageId(inlineMessageId) {
|
|
|
20
21
|
export async function constructCallbackQuery(callbackQuery, getEntity, getMessage) {
|
|
21
22
|
const user_ = await getEntity(new types.PeerUser({ user_id: callbackQuery.user_id }));
|
|
22
23
|
if (!user_) {
|
|
23
|
-
|
|
24
|
+
unreachable();
|
|
24
25
|
}
|
|
25
26
|
const user = constructUser(user_);
|
|
26
27
|
const id = String(callbackQuery.query_id);
|
|
@@ -30,7 +31,7 @@ export async function constructCallbackQuery(callbackQuery, getEntity, getMessag
|
|
|
30
31
|
if (callbackQuery instanceof types.UpdateBotCallbackQuery) {
|
|
31
32
|
const message = await getMessage(peerToChatId(callbackQuery.peer), Number(callbackQuery.msg_id));
|
|
32
33
|
if (message == null) {
|
|
33
|
-
|
|
34
|
+
unreachable();
|
|
34
35
|
}
|
|
35
36
|
return cleanObject({ id, from: user, message, chatInstance, data, gameShortName });
|
|
36
37
|
}
|
package/esm/types/5_chat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject } from "../1_utilities.js";
|
|
2
3
|
import { chatIdToPeer, peerToChatId, types } from "../2_tl.js";
|
|
3
4
|
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
4
5
|
import { constructChatP } from "./1_chat_p.js";
|
|
@@ -18,7 +19,7 @@ function getChatPAlsoPhoto(entity) {
|
|
|
18
19
|
also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
|
|
22
|
+
unreachable();
|
|
22
23
|
}
|
|
23
24
|
let photo = undefined;
|
|
24
25
|
if (entity.photo instanceof types.UserProfilePhoto) {
|
|
@@ -39,7 +40,7 @@ export function getChatOrder(lastMessage, pinned) {
|
|
|
39
40
|
export async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
|
|
40
41
|
const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
|
|
41
42
|
if (!topMessage_) {
|
|
42
|
-
|
|
43
|
+
unreachable();
|
|
43
44
|
}
|
|
44
45
|
const pinned = pinnedChats.indexOf(peerToChatId(dialog.peer));
|
|
45
46
|
const lastMessage = await constructMessage(topMessage_, getEntity, getMessage, getStickerSetName, false);
|
|
@@ -47,9 +48,9 @@ export async function constructChat(dialog, dialogs, pinnedChats, getEntity, get
|
|
|
47
48
|
const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
|
|
48
49
|
const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
|
|
49
50
|
const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
|
|
50
|
-
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof types.User && v.id == userId) :
|
|
51
|
+
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof types.User && v.id == userId) : unreachable();
|
|
51
52
|
if (!chat__) {
|
|
52
|
-
|
|
53
|
+
unreachable();
|
|
53
54
|
}
|
|
54
55
|
const chat_ = chat__;
|
|
55
56
|
const { chatP, also, photo } = getChatPAlsoPhoto(chat_);
|
|
@@ -66,7 +67,7 @@ export async function constructChat(dialog, dialogs, pinnedChats, getEntity, get
|
|
|
66
67
|
return cleanObject({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
67
68
|
}
|
|
68
69
|
else {
|
|
69
|
-
|
|
70
|
+
unreachable();
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
export function constructChat2(entity, pinned, lastMessage) {
|
|
@@ -86,7 +87,7 @@ export function constructChat2(entity, pinned, lastMessage) {
|
|
|
86
87
|
return cleanObject({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
87
88
|
}
|
|
88
89
|
else {
|
|
89
|
-
|
|
90
|
+
unreachable();
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
export async function constructChat3(chatId, pinned, lastMessage, getEntity) {
|
package/esm/types/_file_id.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
1
2
|
import { InputError } from "../0_errors.js";
|
|
2
|
-
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode
|
|
3
|
+
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode } from "../1_utilities.js";
|
|
3
4
|
import { TLReader, TLWriter } from "../2_tl.js";
|
|
4
5
|
const NEXT_VERSION = 53;
|
|
5
6
|
const PERSISTENT_ID_VERSION = 4;
|
|
@@ -122,7 +123,7 @@ function serializePhotoSource(photoSource, writer) {
|
|
|
122
123
|
writer.writeInt32(photoSource.version);
|
|
123
124
|
break;
|
|
124
125
|
default:
|
|
125
|
-
|
|
126
|
+
unreachable();
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
function getPhotoSourceCompareType(source) {
|
|
@@ -132,7 +133,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
132
133
|
case PhotoSourceType.Thumbnail: {
|
|
133
134
|
const type = source.thumbnailType;
|
|
134
135
|
if (!(0 <= type && type <= 127)) {
|
|
135
|
-
|
|
136
|
+
unreachable();
|
|
136
137
|
}
|
|
137
138
|
if (type == "a".charCodeAt(0)) {
|
|
138
139
|
return 0;
|
|
@@ -158,7 +159,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
158
159
|
default:
|
|
159
160
|
break;
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
+
unreachable();
|
|
162
163
|
}
|
|
163
164
|
function writePhotoSourceUniqueId(photoSource, writer) {
|
|
164
165
|
const compareType = getPhotoSourceCompareType(photoSource);
|
|
@@ -169,8 +170,8 @@ function writePhotoSourceUniqueId(photoSource, writer) {
|
|
|
169
170
|
if (compareType == 2) {
|
|
170
171
|
writer.write(new Uint8Array([0x02]));
|
|
171
172
|
}
|
|
172
|
-
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId :
|
|
173
|
-
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version :
|
|
173
|
+
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : unreachable());
|
|
174
|
+
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : unreachable());
|
|
174
175
|
}
|
|
175
176
|
function getFileTypeClass(fileType) {
|
|
176
177
|
switch (fileType) {
|
|
@@ -204,7 +205,7 @@ function getFileTypeClass(fileType) {
|
|
|
204
205
|
case FileType.None:
|
|
205
206
|
case FileType.Size:
|
|
206
207
|
default:
|
|
207
|
-
|
|
208
|
+
unreachable();
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
function isWeb(fileType) {
|
|
@@ -279,7 +280,7 @@ export function toUniqueFileId(fileId) {
|
|
|
279
280
|
switch (fileId.location.source.type) {
|
|
280
281
|
case PhotoSourceType.Legacy:
|
|
281
282
|
case PhotoSourceType.StickerSetThumbnail:
|
|
282
|
-
|
|
283
|
+
unreachable();
|
|
283
284
|
/* falls through */
|
|
284
285
|
case PhotoSourceType.FullLegacy:
|
|
285
286
|
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
@@ -5,3 +5,4 @@ export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, s
|
|
|
5
5
|
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
6
6
|
/** Get a random ID. Useful when calling API functions directly. */
|
|
7
7
|
export declare function getRandomId(): bigint;
|
|
8
|
+
export declare function gcd(a: bigint, b: bigint): bigint;
|
|
@@ -41,3 +41,28 @@ export function getRandomBigInt(byteLength, little, signed) {
|
|
|
41
41
|
export function getRandomId() {
|
|
42
42
|
return getRandomBigInt(8, true, true);
|
|
43
43
|
}
|
|
44
|
+
export function gcd(a, b) {
|
|
45
|
+
if (a == 0n) {
|
|
46
|
+
return b;
|
|
47
|
+
}
|
|
48
|
+
while ((a & 1n) == 0n) {
|
|
49
|
+
a >>= 1n;
|
|
50
|
+
}
|
|
51
|
+
while (true) {
|
|
52
|
+
if (a > b) {
|
|
53
|
+
a = (a - b) >> 1n;
|
|
54
|
+
while ((a & 1n) == 0n) {
|
|
55
|
+
a >>= 1n;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (b > a) {
|
|
59
|
+
b = (b - a) >> 1n;
|
|
60
|
+
while ((b & 1n) == 0n) {
|
|
61
|
+
b >>= 1n;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return a;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export declare function setLogVerbosity(verbosity_: number): void;
|
|
2
|
+
export interface LoggingProvider {
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
warn(...args: any[]): void;
|
|
5
|
+
info(...args: any[]): void;
|
|
6
|
+
debug(...args: any[]): void;
|
|
7
|
+
log(...args: any[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function setLoggingProvider(provider_: LoggingProvider): void;
|
|
2
10
|
export declare const ERROR = 1;
|
|
3
11
|
export declare const WARNING = 2;
|
|
4
12
|
export declare const INFO = 3;
|
|
@@ -4,6 +4,10 @@ let verbosity = Number("LOG_VERBOSITY" in dntShim.dntGlobalThis ? dntShim.dntGlo
|
|
|
4
4
|
export function setLogVerbosity(verbosity_) {
|
|
5
5
|
verbosity = verbosity_;
|
|
6
6
|
}
|
|
7
|
+
let provider = console;
|
|
8
|
+
export function setLoggingProvider(provider_) {
|
|
9
|
+
provider = provider_;
|
|
10
|
+
}
|
|
7
11
|
export const ERROR = 1;
|
|
8
12
|
export const WARNING = 2;
|
|
9
13
|
export const INFO = 3;
|
|
@@ -70,19 +74,19 @@ export function getLogger(scope) {
|
|
|
70
74
|
let fn;
|
|
71
75
|
switch (verbosity_) {
|
|
72
76
|
case ERROR:
|
|
73
|
-
fn =
|
|
77
|
+
fn = provider.error;
|
|
74
78
|
break;
|
|
75
79
|
case WARNING:
|
|
76
|
-
fn =
|
|
80
|
+
fn = provider.warn;
|
|
77
81
|
break;
|
|
78
82
|
case INFO:
|
|
79
|
-
fn =
|
|
83
|
+
fn = provider.info;
|
|
80
84
|
break;
|
|
81
85
|
case DEBUG:
|
|
82
|
-
fn =
|
|
86
|
+
fn = provider.debug;
|
|
83
87
|
break;
|
|
84
88
|
default:
|
|
85
|
-
fn =
|
|
89
|
+
fn = provider.log;
|
|
86
90
|
}
|
|
87
91
|
fn(`[${verbosity_} ${scope}]`, ...args);
|
|
88
92
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function factorize(pq: bigint): [bigint, bigint];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { gcd, getRandomId, mod } from "./0_bigint.js";
|
|
3
|
+
function getRandomNumberInRange(min, max) {
|
|
4
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
5
|
+
}
|
|
6
|
+
export function factorize(pq) {
|
|
7
|
+
let a;
|
|
8
|
+
let b;
|
|
9
|
+
let p = 0n;
|
|
10
|
+
let q;
|
|
11
|
+
const one = 1n;
|
|
12
|
+
let found = false;
|
|
13
|
+
for (let i = 0, iter = 0; !found && (i < 3 || iter < 1000); i++) {
|
|
14
|
+
const t = BigInt(getRandomNumberInRange(17, 32)) % (pq - 1n);
|
|
15
|
+
a = getRandomId();
|
|
16
|
+
b = a;
|
|
17
|
+
const lim = 1 << (i + 23);
|
|
18
|
+
for (let j = 1; j < lim; j++) {
|
|
19
|
+
iter++;
|
|
20
|
+
a = mod(a * a, pq);
|
|
21
|
+
a += t;
|
|
22
|
+
if (a >= pq) {
|
|
23
|
+
a = a - pq;
|
|
24
|
+
}
|
|
25
|
+
if (a > b) {
|
|
26
|
+
q = a - b;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
q = b - a;
|
|
30
|
+
}
|
|
31
|
+
p = gcd(q, pq);
|
|
32
|
+
if (p != one) {
|
|
33
|
+
found = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if ((j & (j - 1)) == 0) {
|
|
37
|
+
b = a;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (found) {
|
|
42
|
+
q = pq / p;
|
|
43
|
+
if (p > q) {
|
|
44
|
+
return [q, p];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return [p, q];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
unreachable();
|
|
51
|
+
}
|
package/esm/utilities/1_misc.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
export function drop(promise) {
|
|
3
3
|
promise.catch(() => { });
|
|
4
4
|
}
|
|
5
5
|
export function mustPrompt(message) {
|
|
6
6
|
const result = prompt(message);
|
|
7
7
|
if (result == null) {
|
|
8
|
-
throw
|
|
8
|
+
throw unreachable();
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
return result;
|
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.221.0/encodin
|
|
|
4
4
|
import { contentType as contentType_ } from "./deps/deno.land/std@0.221.0/media_types/content_type.js";
|
|
5
5
|
export declare const contentType: typeof contentType_;
|
|
6
6
|
export declare function extension(mimeType: string): string;
|
|
7
|
-
export { ctr256,
|
|
7
|
+
export { ctr256, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.4.0/mod.js";
|
|
8
8
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/mod.js";
|
|
9
9
|
export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
|
package/script/0_deps.js
CHANGED
|
@@ -26,7 +26,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Parser = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.
|
|
29
|
+
exports.Parser = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.ctr256 = exports.extension = exports.contentType = exports.encodeBase64 = exports.decodeBase64 = exports.path = void 0;
|
|
30
|
+
// connection/1_connection_tcp.ts must be updated too when updating std.
|
|
30
31
|
__exportStar(require("./deps/deno.land/std@0.221.0/assert/mod.js"), exports);
|
|
31
32
|
exports.path = __importStar(require("./deps/deno.land/std@0.221.0/path/mod.js"));
|
|
32
33
|
var base64_js_1 = require("./deps/deno.land/std@0.221.0/encoding/base64.js");
|
|
@@ -52,9 +53,8 @@ function extension(mimeType) {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
exports.extension = extension;
|
|
55
|
-
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.
|
|
56
|
+
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.4.0/mod.js");
|
|
56
57
|
Object.defineProperty(exports, "ctr256", { enumerable: true, get: function () { return mod_js_1.ctr256; } });
|
|
57
|
-
Object.defineProperty(exports, "factorize", { enumerable: true, get: function () { return mod_js_1.factorize; } });
|
|
58
58
|
Object.defineProperty(exports, "ige256Decrypt", { enumerable: true, get: function () { return mod_js_1.ige256Decrypt; } });
|
|
59
59
|
Object.defineProperty(exports, "ige256Encrypt", { enumerable: true, get: function () { return mod_js_1.ige256Encrypt; } });
|
|
60
60
|
Object.defineProperty(exports, "initTgCrypto", { enumerable: true, get: function () { return mod_js_1.init; } });
|
package/script/1_utilities.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from "./utilities/0_bigint.js";
|
|
|
2
2
|
export * from "./utilities/0_buffer.js";
|
|
3
3
|
export * from "./utilities/0_cache_map.js";
|
|
4
4
|
export * from "./utilities/0_color.js";
|
|
5
|
-
export * from "./utilities/0_control.js";
|
|
6
5
|
export * from "./utilities/0_crypto.js";
|
|
7
6
|
export * from "./utilities/0_hash.js";
|
|
8
7
|
export * from "./utilities/0_logger.js";
|
|
@@ -12,5 +11,6 @@ export * from "./utilities/0_rle.js";
|
|
|
12
11
|
export * from "./utilities/0_types.js";
|
|
13
12
|
export * from "./utilities/1_auth.js";
|
|
14
13
|
export * from "./utilities/1_base64.js";
|
|
14
|
+
export * from "./utilities/1_math.js";
|
|
15
15
|
export * from "./utilities/1_misc.js";
|
|
16
16
|
export * from "./utilities/1_queue.js";
|
package/script/1_utilities.js
CHANGED
|
@@ -18,7 +18,6 @@ __exportStar(require("./utilities/0_bigint.js"), exports);
|
|
|
18
18
|
__exportStar(require("./utilities/0_buffer.js"), exports);
|
|
19
19
|
__exportStar(require("./utilities/0_cache_map.js"), exports);
|
|
20
20
|
__exportStar(require("./utilities/0_color.js"), exports);
|
|
21
|
-
__exportStar(require("./utilities/0_control.js"), exports);
|
|
22
21
|
__exportStar(require("./utilities/0_crypto.js"), exports);
|
|
23
22
|
__exportStar(require("./utilities/0_hash.js"), exports);
|
|
24
23
|
__exportStar(require("./utilities/0_logger.js"), exports);
|
|
@@ -28,5 +27,6 @@ __exportStar(require("./utilities/0_rle.js"), exports);
|
|
|
28
27
|
__exportStar(require("./utilities/0_types.js"), exports);
|
|
29
28
|
__exportStar(require("./utilities/1_auth.js"), exports);
|
|
30
29
|
__exportStar(require("./utilities/1_base64.js"), exports);
|
|
30
|
+
__exportStar(require("./utilities/1_math.js"), exports);
|
|
31
31
|
__exportStar(require("./utilities/1_misc.js"), exports);
|
|
32
32
|
__exportStar(require("./utilities/1_queue.js"), exports);
|
package/script/4_errors.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.upgradeInstance = exports.StatsMigrate = exports.FileMigrate = exports.PhoneMigrate = exports.UserMigrate = exports.Migrate = exports.FloodWait = void 0;
|
|
18
|
-
const
|
|
18
|
+
const _0_deps_js_1 = require("./0_deps.js");
|
|
19
19
|
const _3_errors_js_1 = require("./3_errors.js");
|
|
20
20
|
__exportStar(require("./3_errors.js"), exports);
|
|
21
21
|
class FloodWait extends _3_errors_js_1.ErrorWithCall {
|
|
@@ -30,7 +30,7 @@ class FloodWait extends _3_errors_js_1.ErrorWithCall {
|
|
|
30
30
|
const p = params.error_message.split("_");
|
|
31
31
|
this.seconds = Number(p[p.length - 1]);
|
|
32
32
|
if (isNaN(this.seconds)) {
|
|
33
|
-
(0,
|
|
33
|
+
(0, _0_deps_js_1.unreachable)();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -47,7 +47,7 @@ class Migrate extends _3_errors_js_1.ErrorWithCall {
|
|
|
47
47
|
const p = params.error_message.split("_");
|
|
48
48
|
this.dc = Number(p[p.length - 1]);
|
|
49
49
|
if (isNaN(this.dc)) {
|
|
50
|
-
(0,
|
|
50
|
+
(0, _0_deps_js_1.unreachable)();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMarkdown = exports.CODEPOINTS = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Copyright (
|
|
6
|
-
* Copyright (
|
|
5
|
+
* Copyright (C) 2023 Dunkan
|
|
6
|
+
* Copyright (C) 2024 Roj
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
9
9
|
const _3_types_js_1 = require("../3_types.js");
|
|
10
10
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
11
11
|
const enc = new TextEncoder();
|
|
@@ -139,7 +139,7 @@ function parseMarkdown(text_) {
|
|
|
139
139
|
case "customEmoji":
|
|
140
140
|
return c === exports.CODEPOINTS["]"];
|
|
141
141
|
default:
|
|
142
|
-
(0,
|
|
142
|
+
(0, _0_deps_js_1.unreachable)();
|
|
143
143
|
}
|
|
144
144
|
})();
|
|
145
145
|
}
|
|
@@ -292,7 +292,7 @@ function parseMarkdown(text_) {
|
|
|
292
292
|
break;
|
|
293
293
|
}
|
|
294
294
|
default:
|
|
295
|
-
(0,
|
|
295
|
+
(0, _0_deps_js_1.unreachable)();
|
|
296
296
|
}
|
|
297
297
|
if (!skipEntity) {
|
|
298
298
|
const entityOffset = nestedEntities.at(-1).entityOffset;
|
|
@@ -4,3 +4,9 @@ export declare function getFileContents(source: FileSource, fileName?: string):
|
|
|
4
4
|
export declare function isHttpUrl(string: string): boolean;
|
|
5
5
|
export declare function getUsername(string: string): string;
|
|
6
6
|
export declare function getChatListId(chatList: string): 0 | 1;
|
|
7
|
+
export declare function checkMessageId(messageId: number): number;
|
|
8
|
+
export declare function checkStoryId(storyId: number): number;
|
|
9
|
+
export declare function checkPollOption(option: string): void;
|
|
10
|
+
export declare function checkArray<T>(array: T[], check: (value: T) => void): void;
|
|
11
|
+
export declare function checkCallbackQueryId(id: string): void;
|
|
12
|
+
export declare function checkInlineQueryId(id: string): void;
|
|
@@ -23,11 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getChatListId = exports.getUsername = exports.isHttpUrl = exports.getFileContents = exports.resolve = void 0;
|
|
26
|
+
exports.checkInlineQueryId = exports.checkCallbackQueryId = exports.checkArray = exports.checkPollOption = exports.checkStoryId = exports.checkMessageId = exports.getChatListId = exports.getUsername = exports.isHttpUrl = exports.getFileContents = exports.resolve = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
28
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
29
29
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
30
|
-
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
31
30
|
const resolve = () => Promise.resolve();
|
|
32
31
|
exports.resolve = resolve;
|
|
33
32
|
async function getFileContents(source, fileName = "") {
|
|
@@ -55,7 +54,7 @@ async function getFileContents(source, fileName = "") {
|
|
|
55
54
|
fileName = _0_deps_js_1.path.basename(path_);
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
58
|
-
(0,
|
|
57
|
+
(0, _0_deps_js_1.unreachable)();
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
const res = await fetch(url);
|
|
@@ -153,7 +152,45 @@ function getChatListId(chatList) {
|
|
|
153
152
|
case "archived":
|
|
154
153
|
return 1;
|
|
155
154
|
default:
|
|
156
|
-
(0,
|
|
155
|
+
(0, _0_deps_js_1.unreachable)();
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
exports.getChatListId = getChatListId;
|
|
159
|
+
function checkMessageId(messageId) {
|
|
160
|
+
if (typeof messageId !== "number" || isNaN(messageId) || !messageId) {
|
|
161
|
+
throw new _0_errors_js_1.InputError("Invalid message ID");
|
|
162
|
+
}
|
|
163
|
+
return messageId;
|
|
164
|
+
}
|
|
165
|
+
exports.checkMessageId = checkMessageId;
|
|
166
|
+
function checkStoryId(storyId) {
|
|
167
|
+
if (typeof storyId !== "number" || isNaN(storyId) || !storyId) {
|
|
168
|
+
throw new _0_errors_js_1.InputError("Invalid story ID");
|
|
169
|
+
}
|
|
170
|
+
return storyId;
|
|
171
|
+
}
|
|
172
|
+
exports.checkStoryId = checkStoryId;
|
|
173
|
+
function checkPollOption(option) {
|
|
174
|
+
if (!option.trim()) {
|
|
175
|
+
throw new _0_errors_js_1.InputError("Poll option must not be empty.");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.checkPollOption = checkPollOption;
|
|
179
|
+
function checkArray(array, check) {
|
|
180
|
+
for (const item of array) {
|
|
181
|
+
check(item);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.checkArray = checkArray;
|
|
185
|
+
function checkCallbackQueryId(id) {
|
|
186
|
+
if (typeof id !== "string" || !id.trim()) {
|
|
187
|
+
throw new _0_errors_js_1.InputError("Invalid callback query ID.");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.checkCallbackQueryId = checkCallbackQueryId;
|
|
191
|
+
function checkInlineQueryId(id) {
|
|
192
|
+
if (typeof id !== "string" || !id.trim()) {
|
|
193
|
+
throw new _0_errors_js_1.InputError("Invalid inline query ID.");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.checkInlineQueryId = checkInlineQueryId;
|