@mtkruto/node 0.1.500 → 0.1.700

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.
Files changed (179) hide show
  1. package/esm/3_types.d.ts +6 -1
  2. package/esm/3_types.js +6 -1
  3. package/esm/4_errors.js +2 -4
  4. package/esm/5_client.d.ts +1 -1
  5. package/esm/5_client.js +1 -1
  6. package/esm/client/0_params.d.ts +33 -7
  7. package/esm/client/0_storage_operations.d.ts +182 -0
  8. package/esm/client/0_storage_operations.js +611 -0
  9. package/esm/client/1_composer.d.ts +2 -0
  10. package/esm/client/1_composer.js +28 -0
  11. package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
  12. package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
  13. package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
  14. package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  15. package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
  16. package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
  17. package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  18. package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
  19. package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
  20. package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  21. package/esm/client/3_video_chat_manager.d.ts +43 -0
  22. package/esm/client/3_video_chat_manager.js +194 -0
  23. package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  24. package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  25. package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
  26. package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
  27. package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  28. package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  29. package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  30. package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
  31. package/esm/client/{4_client.js → 5_client.js} +172 -73
  32. package/esm/connection/0_connection.d.ts +6 -15
  33. package/esm/connection/0_connection.js +1 -38
  34. package/esm/connection/1_connection_web_socket.d.ts +3 -2
  35. package/esm/connection/1_connection_web_socket.js +7 -3
  36. package/esm/mod.d.ts +1 -1
  37. package/esm/mod.js +1 -1
  38. package/esm/storage/0_storage.d.ts +9 -145
  39. package/esm/storage/0_storage.js +1 -526
  40. package/esm/storage/2_storage_indexed_db.d.ts +3 -2
  41. package/esm/storage/2_storage_indexed_db.js +9 -8
  42. package/esm/storage/2_storage_local_storage.d.ts +3 -2
  43. package/esm/storage/2_storage_local_storage.js +5 -4
  44. package/esm/storage/2_storage_memory.d.ts +4 -4
  45. package/esm/storage/2_storage_memory.js +12 -19
  46. package/esm/storage/2_storage_session_storage.d.ts +2 -1
  47. package/esm/storage/2_storage_session_storage.js +5 -4
  48. package/esm/tl/3_utilities.d.ts +1 -1
  49. package/esm/tl/3_utilities.js +3 -3
  50. package/esm/types/0_birthday.d.ts +27 -0
  51. package/esm/types/0_birthday.js +26 -0
  52. package/esm/types/0_giveaway_parameters.d.ts +1 -1
  53. package/esm/types/0_id.d.ts +1 -1
  54. package/esm/types/0_live_stream_channel.d.ts +30 -0
  55. package/esm/types/0_live_stream_channel.js +26 -0
  56. package/esm/types/0_opening_hours.d.ts +25 -0
  57. package/esm/types/0_opening_hours.js +25 -0
  58. package/esm/types/0_video_chat.d.ts +60 -0
  59. package/esm/types/0_video_chat.js +53 -0
  60. package/esm/types/1_chat_p.d.ts +4 -0
  61. package/esm/types/1_chat_p.js +1 -0
  62. package/esm/types/2_business_connection.d.ts +6 -0
  63. package/esm/types/2_chat.d.ts +62 -0
  64. package/esm/types/2_chat.js +66 -0
  65. package/esm/types/2_inactive_chat.d.ts +1 -1
  66. package/esm/types/2_invite_link.d.ts +1 -1
  67. package/esm/types/2_message_reaction_count.d.ts +1 -1
  68. package/esm/types/2_message_reactions.d.ts +1 -1
  69. package/esm/types/3_chat_member_updated.d.ts +1 -1
  70. package/esm/types/4_message.d.ts +3 -3
  71. package/esm/types/5_chat_list_item.d.ts +35 -0
  72. package/esm/types/5_chat_list_item.js +86 -0
  73. package/esm/types/6_update.d.ts +14 -5
  74. package/esm/types/_file_id.d.ts +1 -0
  75. package/esm/utilities/0_bigint.d.ts +1 -0
  76. package/esm/utilities/0_bigint.js +7 -3
  77. package/package.json +1 -1
  78. package/script/3_types.d.ts +6 -1
  79. package/script/3_types.js +6 -1
  80. package/script/4_errors.js +2 -4
  81. package/script/5_client.d.ts +1 -1
  82. package/script/5_client.js +1 -1
  83. package/script/client/0_params.d.ts +33 -7
  84. package/script/client/0_storage_operations.d.ts +182 -0
  85. package/script/client/0_storage_operations.js +615 -0
  86. package/script/client/1_composer.d.ts +2 -0
  87. package/script/client/1_composer.js +28 -0
  88. package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
  89. package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
  90. package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
  91. package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  92. package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
  93. package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
  94. package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  95. package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
  96. package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
  97. package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  98. package/script/client/3_video_chat_manager.d.ts +43 -0
  99. package/script/client/3_video_chat_manager.js +198 -0
  100. package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  101. package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  102. package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
  103. package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
  104. package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  105. package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  106. package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  107. package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
  108. package/script/client/{4_client.js → 5_client.js} +192 -93
  109. package/script/connection/0_connection.d.ts +6 -15
  110. package/script/connection/0_connection.js +0 -41
  111. package/script/connection/1_connection_web_socket.d.ts +3 -2
  112. package/script/connection/1_connection_web_socket.js +7 -3
  113. package/script/mod.d.ts +1 -1
  114. package/script/mod.js +1 -1
  115. package/script/storage/0_storage.d.ts +9 -145
  116. package/script/storage/0_storage.js +0 -528
  117. package/script/storage/2_storage_indexed_db.d.ts +3 -2
  118. package/script/storage/2_storage_indexed_db.js +9 -8
  119. package/script/storage/2_storage_local_storage.d.ts +3 -2
  120. package/script/storage/2_storage_local_storage.js +5 -4
  121. package/script/storage/2_storage_memory.d.ts +4 -4
  122. package/script/storage/2_storage_memory.js +12 -19
  123. package/script/storage/2_storage_session_storage.d.ts +2 -1
  124. package/script/storage/2_storage_session_storage.js +5 -4
  125. package/script/tl/3_utilities.d.ts +1 -1
  126. package/script/tl/3_utilities.js +3 -3
  127. package/script/types/0_birthday.d.ts +27 -0
  128. package/script/types/0_birthday.js +30 -0
  129. package/script/types/0_giveaway_parameters.d.ts +1 -1
  130. package/script/types/0_id.d.ts +1 -1
  131. package/script/types/0_live_stream_channel.d.ts +30 -0
  132. package/script/types/0_live_stream_channel.js +30 -0
  133. package/script/types/0_opening_hours.d.ts +25 -0
  134. package/script/types/0_opening_hours.js +29 -0
  135. package/script/types/0_video_chat.d.ts +60 -0
  136. package/script/types/0_video_chat.js +57 -0
  137. package/script/types/1_chat_p.d.ts +4 -0
  138. package/script/types/1_chat_p.js +1 -0
  139. package/script/types/2_business_connection.d.ts +6 -0
  140. package/script/types/2_chat.d.ts +62 -0
  141. package/script/types/2_chat.js +70 -0
  142. package/script/types/2_inactive_chat.d.ts +1 -1
  143. package/script/types/2_invite_link.d.ts +1 -1
  144. package/script/types/2_message_reaction_count.d.ts +1 -1
  145. package/script/types/2_message_reactions.d.ts +1 -1
  146. package/script/types/3_chat_member_updated.d.ts +1 -1
  147. package/script/types/4_message.d.ts +3 -3
  148. package/script/types/5_chat_list_item.d.ts +35 -0
  149. package/script/types/5_chat_list_item.js +94 -0
  150. package/script/types/6_update.d.ts +14 -5
  151. package/script/types/_file_id.d.ts +1 -0
  152. package/script/utilities/0_bigint.d.ts +1 -0
  153. package/script/utilities/0_bigint.js +7 -3
  154. package/esm/types/5_chat.d.ts +0 -59
  155. package/esm/types/5_chat.js +0 -126
  156. package/script/types/5_chat.d.ts +0 -59
  157. package/script/types/5_chat.js +0 -134
  158. /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  159. /package/esm/{3_storage.js → 2_storage.js} +0 -0
  160. /package/esm/client/{0_types.js → 1_types.js} +0 -0
  161. /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  162. /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  163. /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  164. /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  165. /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  166. /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  167. /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  168. /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
  169. /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  170. /package/script/{3_storage.js → 2_storage.js} +0 -0
  171. /package/script/client/{0_types.js → 1_types.js} +0 -0
  172. /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  173. /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  174. /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  175. /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  176. /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  177. /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  178. /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  179. /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
@@ -27,7 +27,7 @@ export interface MessageReactionCount {
27
27
  chat: ChatP;
28
28
  /** The message's identifier. */
29
29
  messageId: number;
30
- /** This reaction state's point of time. */
30
+ /** The point in time in which the change was made. */
31
31
  date: Date;
32
32
  /** The reactions made to the post. */
33
33
  reactions: ReactionCount[];
@@ -32,7 +32,7 @@ export interface MessageReactions {
32
32
  user?: User;
33
33
  /** The chat that changed its reactions to the message. Unset if done on behalf of a user. */
34
34
  actorChat?: ChatP;
35
- /** The point of time in which the change was made. */
35
+ /** The point in time in which the change was made. */
36
36
  date: Date;
37
37
  /** The previous reactions. */
38
38
  oldReactions: Reaction[];
@@ -29,7 +29,7 @@ export interface ChatMemberUpdated {
29
29
  chat: ChatP;
30
30
  /** The one who made the change. */
31
31
  from: User;
32
- /** The point of time in which the chat member's status was changed. */
32
+ /** The point in time in which the chat member's status was changed. */
33
33
  date: Date;
34
34
  /** The old status of the chat member. */
35
35
  oldChatMember: ChatMember;
@@ -57,7 +57,7 @@ export interface _MessageBase {
57
57
  from?: User;
58
58
  /** The chat which the message was sent on behalf of. */
59
59
  senderChat?: ChatP;
60
- /** The point of time in which the message was sent. */
60
+ /** The point in time in which the message was sent. */
61
61
  date: Date;
62
62
  /** The chat where the message was sent to. */
63
63
  chat: ChatP;
@@ -73,7 +73,7 @@ export interface _MessageBase {
73
73
  forwardSignature?: string;
74
74
  /** The name of the original sender of the message. */
75
75
  forwardSenderName?: string;
76
- /** The point of time in which the original message was sent. */
76
+ /** The point in time in which the original message was sent. */
77
77
  forwardDate?: Date;
78
78
  /** Whether the message was sent in a topic thread. */
79
79
  isTopicMessage: boolean;
@@ -89,7 +89,7 @@ export interface _MessageBase {
89
89
  replyQuote?: ReplyQuote;
90
90
  /** The inline bot that was used to send this message. */
91
91
  viaBot?: User;
92
- /** The point of time in which the message's last edit was made. */
92
+ /** The point in time in which the message's last edit was made. */
93
93
  editDate?: Date;
94
94
  /** Whether the contents of the message is protected. */
95
95
  hasProtectedContent?: boolean;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2024 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 { enums, types } from "../2_tl.js";
21
+ import { EntityGetter } from "./_getters.js";
22
+ import { ChatP } from "./1_chat_p.js";
23
+ import { StickerSetNameGetter } from "./1_sticker.js";
24
+ import { Message, MessageGetter } from "./4_message.js";
25
+ export interface ChatListItem {
26
+ chat: ChatP;
27
+ order: string;
28
+ pinned: number;
29
+ lastMessage?: Omit<Message, "replyToMessage">;
30
+ }
31
+ export declare function getChatListItemOrder(lastMessage: Omit<Message, "replyToMessage"> | undefined, pinned: number): string;
32
+ export declare function constructChatListItem(chatId: number, pinned: number, lastMessageId: number, getEntity: EntityGetter, getMessage: MessageGetter): Promise<ChatListItem | null>;
33
+ export declare function constructChatListItem2(entity: types.User | types.Chat | types.ChatForbidden | types.Channel | types.ChannelForbidden, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined): ChatListItem;
34
+ export declare function constructChatListItem3(chatId: number, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined, getEntity: EntityGetter): Promise<ChatListItem | null>;
35
+ export declare function constructChatListItem4(dialog: enums.Dialog, dialogs: types.messages.Dialogs | types.messages.DialogsSlice, pinnedChats: number[], getEntity: EntityGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<ChatListItem>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructChatListItem4 = exports.constructChatListItem3 = exports.constructChatListItem2 = exports.constructChatListItem = exports.getChatListItemOrder = void 0;
23
+ const _0_deps_js_1 = require("../0_deps.js");
24
+ const _2_tl_js_1 = require("../2_tl.js");
25
+ const _1_chat_p_js_1 = require("./1_chat_p.js");
26
+ const _4_message_js_1 = require("./4_message.js");
27
+ function getChatListItemOrder(lastMessage, pinned) {
28
+ const p = pinned == -1 ? "" : `P${100 - pinned}`;
29
+ if (!lastMessage) {
30
+ return p + "0";
31
+ }
32
+ return p + String((BigInt(Math.floor(lastMessage.date.getTime())) << 32n) + BigInt(lastMessage.id));
33
+ }
34
+ exports.getChatListItemOrder = getChatListItemOrder;
35
+ async function constructChatListItem(chatId, pinned, lastMessageId, getEntity, getMessage) {
36
+ const entity = await getEntity((0, _2_tl_js_1.chatIdToPeer)(chatId));
37
+ if (entity == null) {
38
+ return null;
39
+ }
40
+ const lastMessage_ = lastMessageId > 0 ? await getMessage(chatId, lastMessageId) : null;
41
+ const lastMessage = lastMessage_ == null ? undefined : lastMessage_;
42
+ return {
43
+ chat: (0, _1_chat_p_js_1.constructChatP)(entity),
44
+ order: getChatListItemOrder(lastMessage, pinned),
45
+ pinned,
46
+ lastMessage,
47
+ };
48
+ }
49
+ exports.constructChatListItem = constructChatListItem;
50
+ function constructChatListItem2(entity, pinned, lastMessage) {
51
+ return {
52
+ chat: (0, _1_chat_p_js_1.constructChatP)(entity),
53
+ order: getChatListItemOrder(lastMessage, pinned),
54
+ pinned,
55
+ lastMessage,
56
+ };
57
+ }
58
+ exports.constructChatListItem2 = constructChatListItem2;
59
+ async function constructChatListItem3(chatId, pinned, lastMessage, getEntity) {
60
+ const entity = await getEntity((0, _2_tl_js_1.chatIdToPeer)(chatId));
61
+ if (entity == null) {
62
+ return null;
63
+ }
64
+ return {
65
+ chat: (0, _1_chat_p_js_1.constructChatP)(entity),
66
+ order: getChatListItemOrder(lastMessage, pinned),
67
+ pinned,
68
+ lastMessage,
69
+ };
70
+ }
71
+ exports.constructChatListItem3 = constructChatListItem3;
72
+ async function constructChatListItem4(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
73
+ const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
74
+ if (!topMessage_) {
75
+ (0, _0_deps_js_1.unreachable)();
76
+ }
77
+ const pinned = pinnedChats.indexOf((0, _2_tl_js_1.peerToChatId)(dialog.peer));
78
+ const lastMessage = await (0, _4_message_js_1.constructMessage)(topMessage_, getEntity, getMessage, getStickerSetName, false);
79
+ const order = getChatListItemOrder(lastMessage, pinned);
80
+ const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
81
+ const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
82
+ const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
83
+ const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0, _0_deps_js_1.unreachable)();
84
+ if (!chat__) {
85
+ (0, _0_deps_js_1.unreachable)();
86
+ }
87
+ return {
88
+ chat: (0, _1_chat_p_js_1.constructChatP)(chat__),
89
+ order,
90
+ lastMessage,
91
+ pinned,
92
+ };
93
+ }
94
+ exports.constructChatListItem4 = constructChatListItem4;
@@ -31,7 +31,8 @@ import { ChatMemberUpdated } from "./3_chat_member_updated.js";
31
31
  import { Story } from "./3_story.js";
32
32
  import { Message } from "./4_message.js";
33
33
  import { CallbackQuery } from "./5_callback_query.js";
34
- import { Chat } from "./5_chat.js";
34
+ import { ChatListItem } from "./5_chat_list_item.js";
35
+ import { VideoChat } from "./0_video_chat.js";
35
36
  /**
36
37
  * A client's connection state was changed.
37
38
  *
@@ -165,14 +166,14 @@ export interface UpdateChosenInlineResult {
165
166
  */
166
167
  export interface UpdateNewChat {
167
168
  /** The newly added chat. */
168
- newChat: Chat;
169
+ newChat: ChatListItem;
169
170
  }
170
171
  /**
171
172
  * A chat in the chat list was edited. User-only.
172
173
  * @unlisted
173
174
  */
174
175
  export interface UpdateEditedChat {
175
- editedChat: Chat;
176
+ editedChat: ChatListItem;
176
177
  }
177
178
  /**
178
179
  * A chat was removed from the chat list. User-only.
@@ -242,6 +243,13 @@ export interface UpdateNewStory {
242
243
  export interface UpdateBusinessConnection {
243
244
  businessConnection: BusinessConnection;
244
245
  }
246
+ /**
247
+ * A video chat was started, scheduled, or ended.
248
+ * @unlisted
249
+ */
250
+ export interface UpdateVideoChat {
251
+ videoChat: VideoChat;
252
+ }
245
253
  /** @unlisted */
246
254
  export interface UpdateMap {
247
255
  message: UpdateNewMessage;
@@ -263,8 +271,9 @@ export interface UpdateMap {
263
271
  deletedStory: UpdateDeletedStory;
264
272
  story: UpdateNewStory;
265
273
  businessConnection: UpdateBusinessConnection;
274
+ videoChat: UpdateVideoChat;
266
275
  }
267
276
  /** @unlisted */
268
- export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection>;
277
+ export type UpdateIntersection<T> = T & Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateEditedMessage & UpdateDeletedMessages & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection & UpdateVideoChat>;
269
278
  /** An incoming update. */
270
- export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection;
279
+ export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateEditedMessage | UpdateDeletedMessages | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection | UpdateVideoChat;
@@ -110,6 +110,7 @@ type FileLocation = {
110
110
  id: bigint;
111
111
  accessHash: bigint;
112
112
  };
113
+ /** @unlisted */
113
114
  export interface FileId {
114
115
  type: FileType;
115
116
  dcId: number;
@@ -4,5 +4,6 @@ export declare function mod(n: number, m: number): number;
4
4
  export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, signed?: boolean): bigint;
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
+ export declare function getRandomId(number: true): number;
7
8
  export declare function getRandomId(): bigint;
8
9
  export declare function gcd(a: bigint, b: bigint): bigint;
@@ -86,9 +86,13 @@ function getRandomBigInt(byteLength, little, signed) {
86
86
  return bigIntFromBuffer(randomBytes, little, signed);
87
87
  }
88
88
  exports.getRandomBigInt = getRandomBigInt;
89
- /** Get a random ID. Useful when calling API functions directly. */
90
- function getRandomId() {
91
- return getRandomBigInt(8, true, true);
89
+ function getRandomId(number) {
90
+ if (number) {
91
+ return Number(getRandomBigInt(4, true, true));
92
+ }
93
+ else {
94
+ return getRandomBigInt(8, true, true);
95
+ }
92
96
  }
93
97
  exports.getRandomId = getRandomId;
94
98
  function gcd(a, b) {
@@ -1,59 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2024 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 { enums, types } from "../2_tl.js";
21
- import { EntityGetter } from "./_getters.js";
22
- import { ChatPhotoChat, ChatPhotoUser } from "./0_chat_photo.js";
23
- import { ChatPChannel, ChatPGroup, ChatPPrivate, ChatPSupergroup } from "./1_chat_p.js";
24
- import { StickerSetNameGetter } from "./1_sticker.js";
25
- import { Message, MessageGetter } from "./4_message.js";
26
- /** @unlisted */
27
- export interface _ChatBase {
28
- order: string;
29
- lastMessage?: Omit<Message, "replyToMessage">;
30
- pinned: number;
31
- }
32
- /** @unlisted */
33
- export interface ChatChannel extends _ChatBase, ChatPChannel {
34
- also?: string[];
35
- photo?: ChatPhotoChat;
36
- }
37
- /** @unlisted */
38
- export interface ChatSupergroup extends _ChatBase, ChatPSupergroup {
39
- also?: string[];
40
- photo?: ChatPhotoChat;
41
- }
42
- /** @unlisted */
43
- export interface ChatGroup extends _ChatBase, ChatPGroup {
44
- photo?: ChatPhotoChat;
45
- }
46
- /** @unlisted */
47
- export interface ChatPrivate extends _ChatBase, ChatPPrivate {
48
- also?: string[];
49
- photo?: ChatPhotoUser;
50
- }
51
- /**
52
- * A chat with more fields.
53
- */
54
- export type Chat = ChatChannel | ChatSupergroup | ChatGroup | ChatPrivate;
55
- export declare function getChatOrder(lastMessage: Omit<Message, "replyToMessage"> | undefined, pinned: number): string;
56
- export declare function constructChat(dialog: enums.Dialog, dialogs: types.messages.Dialogs | types.messages.DialogsSlice, pinnedChats: number[], getEntity: EntityGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Chat>;
57
- export declare function constructChat2(entity: types.User | types.Chat | types.ChatForbidden | types.Channel | types.ChannelForbidden, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined): Chat;
58
- export declare function constructChat3(chatId: number, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined, getEntity: EntityGetter): Promise<Chat | null>;
59
- export declare function constructChat4(chatId: number, pinned: number, lastMessageId: number, getEntity: EntityGetter, getMessage: MessageGetter): Promise<Chat | null>;
@@ -1,126 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2024 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
- import { cleanObject } from "../1_utilities.js";
22
- import { chatIdToPeer, peerToChatId, types } from "../2_tl.js";
23
- import { constructChatPhoto } from "./0_chat_photo.js";
24
- import { constructChatP } from "./1_chat_p.js";
25
- import { constructMessage } from "./4_message.js";
26
- function getChatPAlsoPhoto(entity) {
27
- let chatP;
28
- let also = undefined;
29
- if (entity instanceof types.User) {
30
- chatP = constructChatP(entity);
31
- also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
32
- }
33
- else if (entity instanceof types.Chat) {
34
- chatP = constructChatP(entity);
35
- }
36
- else if (entity instanceof types.Channel) {
37
- chatP = constructChatP(entity);
38
- also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
39
- }
40
- else {
41
- unreachable();
42
- }
43
- let photo = undefined;
44
- if (entity.photo instanceof types.UserProfilePhoto) {
45
- photo = constructChatPhoto(entity.photo, chatP.id, "access_hash" in entity ? entity.access_hash ?? 0n : 0n);
46
- }
47
- else if (entity.photo instanceof types.ChatPhoto) {
48
- photo = constructChatPhoto(entity.photo, chatP.id, "access_hash" in entity ? entity.access_hash ?? 0n : 0n);
49
- }
50
- return { chatP, also, photo };
51
- }
52
- export function getChatOrder(lastMessage, pinned) {
53
- const p = pinned == -1 ? "" : `P${100 - pinned}`;
54
- if (!lastMessage) {
55
- return p + "0";
56
- }
57
- return p + String((BigInt(Math.floor(lastMessage.date.getTime())) << 32n) + BigInt(lastMessage.id));
58
- }
59
- export async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
60
- const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
61
- if (!topMessage_) {
62
- unreachable();
63
- }
64
- const pinned = pinnedChats.indexOf(peerToChatId(dialog.peer));
65
- const lastMessage = await constructMessage(topMessage_, getEntity, getMessage, getStickerSetName, false);
66
- const order = getChatOrder(lastMessage, pinned);
67
- const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
68
- const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
69
- const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
70
- 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();
71
- if (!chat__) {
72
- unreachable();
73
- }
74
- const chat_ = chat__;
75
- const { chatP, also, photo } = getChatPAlsoPhoto(chat_);
76
- if (chatP.type == "group") {
77
- return cleanObject({ ...chatP, order, lastMessage, photo, pinned });
78
- }
79
- else if (chatP.type == "supergroup") {
80
- return cleanObject({ ...chatP, order, lastMessage, also, photo, pinned });
81
- }
82
- else if (chatP.type == "channel") {
83
- return cleanObject({ ...chatP, order, lastMessage, also, photo, pinned });
84
- }
85
- else if (chatP.type == "private") {
86
- return cleanObject({ ...chatP, order, lastMessage, also, photo: photo, pinned });
87
- }
88
- else {
89
- unreachable();
90
- }
91
- }
92
- export function constructChat2(entity, pinned, lastMessage) {
93
- const chatPAlsoPhoto = getChatPAlsoPhoto(entity);
94
- const order = getChatOrder(lastMessage, pinned);
95
- const { also, photo, chatP } = chatPAlsoPhoto;
96
- if (chatP.type == "group") {
97
- return cleanObject({ ...chatP, order, lastMessage, photo, pinned });
98
- }
99
- else if (chatP.type == "supergroup") {
100
- return cleanObject({ ...chatP, order, lastMessage, also, photo, pinned });
101
- }
102
- else if (chatP.type == "channel") {
103
- return cleanObject({ ...chatP, order, lastMessage, also, photo, pinned });
104
- }
105
- else if (chatP.type == "private") {
106
- return cleanObject({ ...chatP, order, lastMessage, also, photo: photo, pinned });
107
- }
108
- else {
109
- unreachable();
110
- }
111
- }
112
- export async function constructChat3(chatId, pinned, lastMessage, getEntity) {
113
- const peer = chatIdToPeer(chatId);
114
- const entity = await getEntity(peer);
115
- if (entity == null) {
116
- return null;
117
- }
118
- else {
119
- return constructChat2(entity, pinned, lastMessage);
120
- }
121
- }
122
- export async function constructChat4(chatId, pinned, lastMessageId, getEntity, getMessage) {
123
- const lastMessage_ = lastMessageId > 0 ? await getMessage(chatId, lastMessageId) : null;
124
- const lastMessage = lastMessage_ == null ? undefined : lastMessage_;
125
- return await constructChat3(chatId, pinned, lastMessage, getEntity);
126
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2024 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 { enums, types } from "../2_tl.js";
21
- import { EntityGetter } from "./_getters.js";
22
- import { ChatPhotoChat, ChatPhotoUser } from "./0_chat_photo.js";
23
- import { ChatPChannel, ChatPGroup, ChatPPrivate, ChatPSupergroup } from "./1_chat_p.js";
24
- import { StickerSetNameGetter } from "./1_sticker.js";
25
- import { Message, MessageGetter } from "./4_message.js";
26
- /** @unlisted */
27
- export interface _ChatBase {
28
- order: string;
29
- lastMessage?: Omit<Message, "replyToMessage">;
30
- pinned: number;
31
- }
32
- /** @unlisted */
33
- export interface ChatChannel extends _ChatBase, ChatPChannel {
34
- also?: string[];
35
- photo?: ChatPhotoChat;
36
- }
37
- /** @unlisted */
38
- export interface ChatSupergroup extends _ChatBase, ChatPSupergroup {
39
- also?: string[];
40
- photo?: ChatPhotoChat;
41
- }
42
- /** @unlisted */
43
- export interface ChatGroup extends _ChatBase, ChatPGroup {
44
- photo?: ChatPhotoChat;
45
- }
46
- /** @unlisted */
47
- export interface ChatPrivate extends _ChatBase, ChatPPrivate {
48
- also?: string[];
49
- photo?: ChatPhotoUser;
50
- }
51
- /**
52
- * A chat with more fields.
53
- */
54
- export type Chat = ChatChannel | ChatSupergroup | ChatGroup | ChatPrivate;
55
- export declare function getChatOrder(lastMessage: Omit<Message, "replyToMessage"> | undefined, pinned: number): string;
56
- export declare function constructChat(dialog: enums.Dialog, dialogs: types.messages.Dialogs | types.messages.DialogsSlice, pinnedChats: number[], getEntity: EntityGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Chat>;
57
- export declare function constructChat2(entity: types.User | types.Chat | types.ChatForbidden | types.Channel | types.ChannelForbidden, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined): Chat;
58
- export declare function constructChat3(chatId: number, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined, getEntity: EntityGetter): Promise<Chat | null>;
59
- export declare function constructChat4(chatId: number, pinned: number, lastMessageId: number, getEntity: EntityGetter, getMessage: MessageGetter): Promise<Chat | null>;
@@ -1,134 +0,0 @@
1
- "use strict";
2
- /**
3
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
- * Copyright (C) 2023-2024 Roj <https://roj.im/>
5
- *
6
- * This file is part of MTKruto.
7
- *
8
- * This program is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU Lesser General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public License
19
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
- */
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.constructChat4 = exports.constructChat3 = exports.constructChat2 = exports.constructChat = exports.getChatOrder = void 0;
23
- const _0_deps_js_1 = require("../0_deps.js");
24
- const _1_utilities_js_1 = require("../1_utilities.js");
25
- const _2_tl_js_1 = require("../2_tl.js");
26
- const _0_chat_photo_js_1 = require("./0_chat_photo.js");
27
- const _1_chat_p_js_1 = require("./1_chat_p.js");
28
- const _4_message_js_1 = require("./4_message.js");
29
- function getChatPAlsoPhoto(entity) {
30
- let chatP;
31
- let also = undefined;
32
- if (entity instanceof _2_tl_js_1.types.User) {
33
- chatP = (0, _1_chat_p_js_1.constructChatP)(entity);
34
- also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
35
- }
36
- else if (entity instanceof _2_tl_js_1.types.Chat) {
37
- chatP = (0, _1_chat_p_js_1.constructChatP)(entity);
38
- }
39
- else if (entity instanceof _2_tl_js_1.types.Channel) {
40
- chatP = (0, _1_chat_p_js_1.constructChatP)(entity);
41
- also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
42
- }
43
- else {
44
- (0, _0_deps_js_1.unreachable)();
45
- }
46
- let photo = undefined;
47
- if (entity.photo instanceof _2_tl_js_1.types.UserProfilePhoto) {
48
- photo = (0, _0_chat_photo_js_1.constructChatPhoto)(entity.photo, chatP.id, "access_hash" in entity ? entity.access_hash ?? 0n : 0n);
49
- }
50
- else if (entity.photo instanceof _2_tl_js_1.types.ChatPhoto) {
51
- photo = (0, _0_chat_photo_js_1.constructChatPhoto)(entity.photo, chatP.id, "access_hash" in entity ? entity.access_hash ?? 0n : 0n);
52
- }
53
- return { chatP, also, photo };
54
- }
55
- function getChatOrder(lastMessage, pinned) {
56
- const p = pinned == -1 ? "" : `P${100 - pinned}`;
57
- if (!lastMessage) {
58
- return p + "0";
59
- }
60
- return p + String((BigInt(Math.floor(lastMessage.date.getTime())) << 32n) + BigInt(lastMessage.id));
61
- }
62
- exports.getChatOrder = getChatOrder;
63
- async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
64
- const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
65
- if (!topMessage_) {
66
- (0, _0_deps_js_1.unreachable)();
67
- }
68
- const pinned = pinnedChats.indexOf((0, _2_tl_js_1.peerToChatId)(dialog.peer));
69
- const lastMessage = await (0, _4_message_js_1.constructMessage)(topMessage_, getEntity, getMessage, getStickerSetName, false);
70
- const order = getChatOrder(lastMessage, pinned);
71
- const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
72
- const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
73
- const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
74
- const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0, _0_deps_js_1.unreachable)();
75
- if (!chat__) {
76
- (0, _0_deps_js_1.unreachable)();
77
- }
78
- const chat_ = chat__;
79
- const { chatP, also, photo } = getChatPAlsoPhoto(chat_);
80
- if (chatP.type == "group") {
81
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, photo, pinned });
82
- }
83
- else if (chatP.type == "supergroup") {
84
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo, pinned });
85
- }
86
- else if (chatP.type == "channel") {
87
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo, pinned });
88
- }
89
- else if (chatP.type == "private") {
90
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
91
- }
92
- else {
93
- (0, _0_deps_js_1.unreachable)();
94
- }
95
- }
96
- exports.constructChat = constructChat;
97
- function constructChat2(entity, pinned, lastMessage) {
98
- const chatPAlsoPhoto = getChatPAlsoPhoto(entity);
99
- const order = getChatOrder(lastMessage, pinned);
100
- const { also, photo, chatP } = chatPAlsoPhoto;
101
- if (chatP.type == "group") {
102
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, photo, pinned });
103
- }
104
- else if (chatP.type == "supergroup") {
105
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo, pinned });
106
- }
107
- else if (chatP.type == "channel") {
108
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo, pinned });
109
- }
110
- else if (chatP.type == "private") {
111
- return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
112
- }
113
- else {
114
- (0, _0_deps_js_1.unreachable)();
115
- }
116
- }
117
- exports.constructChat2 = constructChat2;
118
- async function constructChat3(chatId, pinned, lastMessage, getEntity) {
119
- const peer = (0, _2_tl_js_1.chatIdToPeer)(chatId);
120
- const entity = await getEntity(peer);
121
- if (entity == null) {
122
- return null;
123
- }
124
- else {
125
- return constructChat2(entity, pinned, lastMessage);
126
- }
127
- }
128
- exports.constructChat3 = constructChat3;
129
- async function constructChat4(chatId, pinned, lastMessageId, getEntity, getMessage) {
130
- const lastMessage_ = lastMessageId > 0 ? await getMessage(chatId, lastMessageId) : null;
131
- const lastMessage = lastMessage_ == null ? undefined : lastMessage_;
132
- return await constructChat3(chatId, pinned, lastMessage, getEntity);
133
- }
134
- exports.constructChat4 = constructChat4;
File without changes
File without changes