@mtkruto/node 0.1.201 → 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.js +14 -13
- package/esm/connection/1_connection_web_socket.js +3 -2
- package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → 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.js +13 -12
- package/script/connection/1_connection_web_socket.js +2 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.3 → 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/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/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/0_reaction.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
export function constructReaction(reaction) {
|
|
4
4
|
if (reaction instanceof types.ReactionEmoji) {
|
|
@@ -8,7 +8,7 @@ export function constructReaction(reaction) {
|
|
|
8
8
|
return { type: "customEmoji", id: String(reaction.document_id) };
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
|
|
11
|
+
unreachable();
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export function reactionToTlObject(reaction) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
export async function botCommandScopeToTlObject(scope, getInputPeer) {
|
|
4
4
|
switch (scope.type) {
|
|
@@ -17,11 +17,11 @@ export async function botCommandScopeToTlObject(scope, getInputPeer) {
|
|
|
17
17
|
case "chatMember": {
|
|
18
18
|
const user = await getInputPeer(scope.userId);
|
|
19
19
|
if (!(user instanceof types.InputPeerUser)) {
|
|
20
|
-
|
|
20
|
+
unreachable();
|
|
21
21
|
}
|
|
22
22
|
return new types.BotCommandScopePeerUser({ peer: await getInputPeer(scope.chatId), user_id: new types.InputUser({ user_id: user.user_id, access_hash: user.access_hash }) });
|
|
23
23
|
}
|
|
24
24
|
default:
|
|
25
|
-
|
|
25
|
+
unreachable();
|
|
26
26
|
}
|
|
27
27
|
}
|
package/esm/types/1_chat_p.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, getColorFromPeerId, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructRestrictionReason } from "./0_restriction_reason.js";
|
|
4
5
|
export function constructChatP(chat) {
|
|
@@ -82,6 +83,6 @@ export function constructChatP(chat) {
|
|
|
82
83
|
return cleanObject(chat_);
|
|
83
84
|
}
|
|
84
85
|
else {
|
|
85
|
-
|
|
86
|
+
unreachable();
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { chatAdministratorRightsToTlObject, constructChatAdministratorRights } from "./0_chat_administrator_rights.js";
|
|
4
4
|
export function constructKeyboardButton(button_) {
|
|
@@ -55,7 +55,7 @@ export function constructKeyboardButton(button_) {
|
|
|
55
55
|
return button;
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
|
|
58
|
+
unreachable();
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
else if (button_ instanceof types.KeyboardButtonRequestPhone) {
|
|
@@ -75,7 +75,7 @@ export function constructKeyboardButton(button_) {
|
|
|
75
75
|
return { text: button_.text, miniApp: { url: button_.url } };
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
|
|
78
|
+
unreachable();
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
export function keyboardButtonToTlObject(button) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { peerToChatId, types } from "../2_tl.js";
|
|
3
3
|
import { constructReaction } from "./0_reaction.js";
|
|
4
4
|
export function constructMessageReaction(reaction_, recentReactions) {
|
|
@@ -11,7 +11,7 @@ export function constructMessageReaction(reaction_, recentReactions) {
|
|
|
11
11
|
return v.reaction instanceof types.ReactionCustomEmoji && v.reaction.document_id == reaction_.reaction.document_id;
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
|
-
|
|
14
|
+
unreachable();
|
|
15
15
|
}
|
|
16
16
|
})
|
|
17
17
|
.map((v) => peerToChatId(v.peer_id));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
async function resolveUsers(ids, getEntity) {
|
|
4
4
|
const users = new Array();
|
|
5
5
|
for (const id of ids) {
|
|
6
6
|
const entity = await getEntity(new types.PeerUser({ user_id: BigInt(id) }));
|
|
7
7
|
if (!(entity instanceof types.User)) {
|
|
8
|
-
|
|
8
|
+
unreachable();
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
users.push(new types.InputUser({ user_id: entity.id, access_hash: entity.access_hash ?? 0n }));
|
|
@@ -34,7 +34,7 @@ export async function storyPrivacyToTlObject(privacy, getEntity) {
|
|
|
34
34
|
}
|
|
35
35
|
else if ("only" in privacy) {
|
|
36
36
|
if (!privacy.only.length) {
|
|
37
|
-
|
|
37
|
+
unreachable();
|
|
38
38
|
}
|
|
39
39
|
const users = await resolveUsers(privacy.only, getEntity);
|
|
40
40
|
rules.push(new types.InputPrivacyValueAllowUsers({ users }));
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, fromUnixTimestamp } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructChatAdministratorRights } from "./0_chat_administrator_rights.js";
|
|
4
5
|
import { constructChatMemberRights } from "./0_chat_member_rights.js";
|
|
5
6
|
import { constructUser } from "./1_user.js";
|
|
6
7
|
export async function constructChatMember(participant, getEntity) {
|
|
7
|
-
const user_ = "user_id" in participant ? await getEntity(new types.PeerUser(participant)) : "peer" in participant ? participant.peer instanceof types.PeerUser ? await getEntity(participant.peer) :
|
|
8
|
+
const user_ = "user_id" in participant ? await getEntity(new types.PeerUser(participant)) : "peer" in participant ? participant.peer instanceof types.PeerUser ? await getEntity(participant.peer) : unreachable() : unreachable(); // TODO: support other peer types
|
|
8
9
|
if (user_ == null)
|
|
9
|
-
|
|
10
|
+
unreachable();
|
|
10
11
|
const user = constructUser(user_);
|
|
11
12
|
if (participant instanceof types.ChannelParticipant || participant instanceof types.ChatParticipant) {
|
|
12
13
|
return {
|
|
@@ -51,7 +52,7 @@ export async function constructChatMember(participant, getEntity) {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
else if (participant instanceof types.ChannelParticipantSelf) {
|
|
54
|
-
|
|
55
|
+
unreachable(); // TODO: implement
|
|
55
56
|
}
|
|
56
57
|
else if (participant instanceof types.ChannelParticipantLeft) {
|
|
57
58
|
return { status: "left", user };
|
|
@@ -84,6 +85,6 @@ export async function constructChatMember(participant, getEntity) {
|
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
87
|
-
|
|
88
|
+
unreachable();
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { base64EncodeUrlSafe, cleanObject } from "../1_utilities.js";
|
|
2
3
|
import { serialize, types } from "../2_tl.js";
|
|
3
4
|
import { constructLocation } from "./0_location.js";
|
|
4
5
|
import { constructUser } from "./1_user.js";
|
|
5
6
|
export async function constructChosenInlineResult(ubis, getEntity) {
|
|
6
7
|
const entity = await getEntity(new types.PeerUser(ubis));
|
|
7
8
|
if (!entity || !(entity instanceof types.User)) {
|
|
8
|
-
|
|
9
|
+
unreachable();
|
|
9
10
|
}
|
|
10
11
|
return cleanObject({
|
|
11
12
|
resultId: ubis.id,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { fromUnixTimestamp } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructChatP } from "./1_chat_p.js";
|
|
4
5
|
export function constructInactiveChat(chat_, lastActivity) {
|
|
5
6
|
if (chat_ instanceof types.ChatEmpty) {
|
|
6
|
-
|
|
7
|
+
unreachable();
|
|
7
8
|
}
|
|
8
9
|
const chat = constructChatP(chat_);
|
|
9
10
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { constructMiniAppInfo } from "./0_mini_app_info.js";
|
|
4
4
|
export function constructInlineKeyboardButton(button_) {
|
|
@@ -29,7 +29,7 @@ export function constructInlineKeyboardButton(button_) {
|
|
|
29
29
|
return { text: button_.text, callbackGame: {} };
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
|
|
32
|
+
unreachable();
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
|
|
@@ -61,6 +61,6 @@ export async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
|
|
|
61
61
|
return new types.KeyboardButtonBuy({ text: button.text });
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
|
|
64
|
+
unreachable();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { constructLocation } from "./0_location.js";
|
|
4
4
|
import { constructUser } from "./1_user.js";
|
|
5
5
|
export async function constructInlineQuery(query_, getEntity) {
|
|
6
6
|
const user_ = await getEntity(new types.PeerUser({ user_id: query_.user_id }));
|
|
7
7
|
if (user_ == null) {
|
|
8
|
-
|
|
8
|
+
unreachable();
|
|
9
9
|
}
|
|
10
10
|
const user = constructUser(user_);
|
|
11
11
|
let chatType;
|
|
@@ -26,7 +26,7 @@ export async function constructInlineQuery(query_, getEntity) {
|
|
|
26
26
|
chatType = "channel";
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
|
|
29
|
+
unreachable();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
const location = query_.geo !== undefined && query_.geo instanceof types.GeoPoint ? constructLocation(query_.geo) : undefined;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, fromUnixTimestamp } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructUser } from "./1_user.js";
|
|
4
5
|
export async function constructInviteLink(inviteLink_, getEntity) {
|
|
5
6
|
const entity = await getEntity(new types.PeerUser({ user_id: inviteLink_.admin_id }));
|
|
6
7
|
if (!entity) {
|
|
7
|
-
|
|
8
|
+
unreachable();
|
|
8
9
|
}
|
|
9
10
|
const inviteLink = inviteLink_.link;
|
|
10
11
|
const creator = constructUser(entity);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { as, types } from "../2_tl.js";
|
|
3
3
|
import { FileType, serializeFileId, toUniqueFileId } from "./_file_id.js";
|
|
4
4
|
import { constructPhoto } from "./1_photo.js";
|
|
@@ -6,7 +6,7 @@ import { constructVideo } from "./1_video.js";
|
|
|
6
6
|
export function constructStoryContent(media) {
|
|
7
7
|
if (media instanceof types.MessageMediaPhoto) {
|
|
8
8
|
if (!media.photo) {
|
|
9
|
-
|
|
9
|
+
unreachable();
|
|
10
10
|
}
|
|
11
11
|
const photo = constructPhoto(media.photo[as](types.Photo));
|
|
12
12
|
return { photo };
|
|
@@ -14,11 +14,11 @@ export function constructStoryContent(media) {
|
|
|
14
14
|
else if (media instanceof types.MessageMediaDocument) {
|
|
15
15
|
const document = media.document;
|
|
16
16
|
if (!(document instanceof types.Document)) {
|
|
17
|
-
|
|
17
|
+
unreachable();
|
|
18
18
|
}
|
|
19
19
|
const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
|
|
20
20
|
if (!video) {
|
|
21
|
-
|
|
21
|
+
unreachable();
|
|
22
22
|
}
|
|
23
23
|
const fileId_ = { type: FileType.Video, dcId: document.dc_id, fileReference: document.file_reference, location: { type: "common", id: document.id, accessHash: document.access_hash } };
|
|
24
24
|
const fileUniqueId = toUniqueFileId(fileId_);
|
|
@@ -27,6 +27,6 @@ export function constructStoryContent(media) {
|
|
|
27
27
|
return { video: video_ };
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
|
|
30
|
+
unreachable();
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { chatIdToPeer, peerToChatId, types } from "../2_tl.js";
|
|
3
3
|
import { constructLocation } from "./0_location.js";
|
|
4
4
|
import { constructReaction, reactionToTlObject } from "./0_reaction.js";
|
|
@@ -16,7 +16,7 @@ export function constructStoryInteractiveArea(area) {
|
|
|
16
16
|
const position = constructStoryInteractiveAreaPosition(area.coordinates);
|
|
17
17
|
if (area instanceof types.MediaAreaGeoPoint) {
|
|
18
18
|
if (area.geo instanceof types.GeoPointEmpty) {
|
|
19
|
-
|
|
19
|
+
unreachable(); // will this ever be empty?
|
|
20
20
|
}
|
|
21
21
|
const location = constructLocation(area.geo);
|
|
22
22
|
return { position, location };
|
|
@@ -45,7 +45,7 @@ export function constructStoryInteractiveArea(area) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
|
|
48
|
+
unreachable();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
function storyInteractiveAreaPositionToTlObject(position) {
|
|
@@ -87,12 +87,12 @@ export async function storyInteractiveAreaToTlObject(area, getEntity) {
|
|
|
87
87
|
else if ("messageReference" in area) {
|
|
88
88
|
const entity = await getEntity(chatIdToPeer(area.messageReference.chatId));
|
|
89
89
|
if (!(entity instanceof types.Channel)) {
|
|
90
|
-
|
|
90
|
+
unreachable();
|
|
91
91
|
}
|
|
92
92
|
const channel = new types.InputChannel({ channel_id: entity.id, access_hash: entity.access_hash ?? 0n });
|
|
93
93
|
return new types.InputMediaAreaChannelPost({ coordinates, channel, msg_id: area.messageReference.messageId });
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
|
-
|
|
96
|
+
unreachable();
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, fromUnixTimestamp } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructChatP } from "./1_chat_p.js";
|
|
4
5
|
import { constructUser } from "./1_user.js";
|
|
@@ -6,12 +7,12 @@ import { constructChatMember } from "./2_chat_member.js";
|
|
|
6
7
|
import { constructInviteLink } from "./2_invite_link.js";
|
|
7
8
|
export async function constructChatMemberUpdated(update, getEntity) {
|
|
8
9
|
if (!update.prev_participant && !update.new_participant) {
|
|
9
|
-
|
|
10
|
+
unreachable();
|
|
10
11
|
}
|
|
11
12
|
const chat_ = await getEntity("channel_id" in update ? new types.PeerChannel(update) : new types.PeerChat(update));
|
|
12
13
|
const from_ = await getEntity(new types.PeerUser({ user_id: update.actor_id }));
|
|
13
14
|
if (!chat_ || !from_) {
|
|
14
|
-
|
|
15
|
+
unreachable();
|
|
15
16
|
}
|
|
16
17
|
const userPeer = new types.PeerUser(update);
|
|
17
18
|
const chat = constructChatP(chat_);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject } from "../1_utilities.js";
|
|
2
3
|
import { types } from "../2_tl.js";
|
|
3
4
|
import { constructKeyboardButton, keyboardButtonToTlObject } from "./1_keyboard_button.js";
|
|
4
5
|
import { constructInlineKeyboardButton, inlineKeyboardButtonToTlObject } from "./2_inline_keyboard_button.js";
|
|
@@ -95,7 +96,7 @@ export function constructReplyMarkup(replyMarkup) {
|
|
|
95
96
|
return constructForceReply(replyMarkup);
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
|
|
99
|
+
unreachable();
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
export async function replyMarkupToTlObject(replyMarkup, usernameResolver) {
|
|
@@ -112,6 +113,6 @@ export async function replyMarkupToTlObject(replyMarkup, usernameResolver) {
|
|
|
112
113
|
return forceReplyToTlObject(replyMarkup);
|
|
113
114
|
}
|
|
114
115
|
else {
|
|
115
|
-
|
|
116
|
+
unreachable();
|
|
116
117
|
}
|
|
117
118
|
}
|
package/esm/types/3_story.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
|
+
import { cleanObject, fromUnixTimestamp } from "../1_utilities.js";
|
|
2
3
|
import { constructMessageEntity } from "./0_message_entity.js";
|
|
3
4
|
import { constructChatP } from "./1_chat_p.js";
|
|
4
5
|
import { constructStoryPrivacy } from "./1_story_privacy.js";
|
|
@@ -9,7 +10,7 @@ export async function constructStory(story, peer, getEntity) {
|
|
|
9
10
|
const id = story.id;
|
|
10
11
|
const entity = await getEntity(peer);
|
|
11
12
|
if (!entity) {
|
|
12
|
-
|
|
13
|
+
unreachable();
|
|
13
14
|
}
|
|
14
15
|
const chat = constructChatP(entity);
|
|
15
16
|
const date = fromUnixTimestamp(story.date);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unreachable } from "../0_deps.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { deserializeFileId } from "./_file_id.js";
|
|
4
4
|
import { replyMarkupToTlObject } from "./3_reply_markup.js";
|
|
@@ -182,7 +182,7 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
|
|
|
182
182
|
title,
|
|
183
183
|
description,
|
|
184
184
|
document: new types.InputDocument({
|
|
185
|
-
id: "id" in fileId.location ? fileId.location.id :
|
|
185
|
+
id: "id" in fileId.location ? fileId.location.id : unreachable(),
|
|
186
186
|
access_hash: fileId.location.accessHash,
|
|
187
187
|
file_reference: fileId.fileReference ?? new Uint8Array(),
|
|
188
188
|
}),
|
|
@@ -223,7 +223,7 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
|
|
|
223
223
|
}
|
|
224
224
|
else if (result_.type == "article") {
|
|
225
225
|
if (!("messageText" in result_.inputMessageContent)) {
|
|
226
|
-
|
|
226
|
+
unreachable();
|
|
227
227
|
}
|
|
228
228
|
const [message, entities] = await parseText(result_.inputMessageContent.messageText, { entities: result_.inputMessageContent.entities, parseMode: result_.inputMessageContent.parseMode });
|
|
229
229
|
const noWebpage = result_.inputMessageContent?.linkPreview?.disable ? true : undefined;
|
|
@@ -261,7 +261,7 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
|
|
|
261
261
|
}
|
|
262
262
|
else if (result_.type == "venue") {
|
|
263
263
|
if (!result_.fourSquareId || !result_.foursquareType) {
|
|
264
|
-
|
|
264
|
+
unreachable();
|
|
265
265
|
}
|
|
266
266
|
return new types.InputBotInlineResult({
|
|
267
267
|
id,
|
|
@@ -281,6 +281,6 @@ export async function inlineQueryResultToTlObject(result_, parseText, usernameRe
|
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
else {
|
|
284
|
-
|
|
284
|
+
unreachable();
|
|
285
285
|
}
|
|
286
286
|
}
|
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) {
|