@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
@@ -29,7 +29,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
29
29
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
30
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
31
  };
32
- var _ChatListManager_instances, _ChatListManager_c, _ChatListManager_LgetChats, _ChatListManager_sendChatUpdate, _ChatListManager_chats, _ChatListManager_archivedChats, _ChatListManager_chatsLoadedFromStorage, _ChatListManager_tryGetChatId, _ChatListManager_getChatAnywhere, _ChatListManager_getChatList, _ChatListManager_loadChatsFromStorage, _ChatListManager_getLoadedChats, _ChatListManager_pinnedChats, _ChatListManager_pinnedArchiveChats, _ChatListManager_storageHadPinnedChats, _ChatListManager_pinnedChatsLoaded, _ChatListManager_loadPinnedChats, _ChatListManager_fetchPinnedChats, _ChatListManager_getPinnedChats, _ChatListManager_updateOrAddChat, _ChatListManager_removeChat, _ChatListManager_handleUpdateFolderPeers, _ChatListManager_handleUpdatePinnedDialogs, _ChatListManager_handleUpdateChannel, _ChatListManager_handleUpdateChat, _ChatListManager_handleUpdateUser, _ChatListManager_fetchChats;
32
+ var _ChatListManager_instances, _ChatListManager_c, _ChatListManager_LgetChats, _ChatListManager_sendChatUpdate, _ChatListManager_chats, _ChatListManager_archivedChats, _ChatListManager_chatsLoadedFromStorage, _ChatListManager_tryGetChatId, _ChatListManager_getChatAnywhere, _ChatListManager_getChatList, _ChatListManager_loadChatsFromStorage, _ChatListManager_getLoadedChats, _ChatListManager_pinnedChats, _ChatListManager_pinnedArchiveChats, _ChatListManager_storageHadPinnedChats, _ChatListManager_pinnedChatsLoaded, _ChatListManager_loadPinnedChats, _ChatListManager_fetchPinnedChats, _ChatListManager_getPinnedChats, _ChatListManager_updateOrAddChat, _ChatListManager_removeChat, _ChatListManager_handleUpdateFolderPeers, _ChatListManager_handleUpdatePinnedDialogs, _ChatListManager_handleUpdateChannel, _ChatListManager_handleUpdateChat, _ChatListManager_handleUpdateUser, _ChatListManager_fetchChats, _ChatListManager_getFullChat;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.ChatListManager = void 0;
35
35
  const _0_deps_js_1 = require("../0_deps.js");
@@ -69,13 +69,13 @@ class ChatListManager {
69
69
  if (message_ != null) {
70
70
  const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.constructMessage(message_);
71
71
  if (chat) {
72
- chat.order = (0, _3_types_js_1.getChatOrder)(message, chat.pinned);
72
+ chat.order = (0, _3_types_js_1.getChatListItemOrder)(message, chat.pinned);
73
73
  chat.lastMessage = message;
74
74
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
75
75
  }
76
76
  else {
77
77
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
78
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
78
+ const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
79
79
  if (chat == null) {
80
80
  (0, _0_deps_js_1.unreachable)();
81
81
  }
@@ -90,13 +90,13 @@ class ChatListManager {
90
90
  const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getHistory(chatId, { limit: 1 }).then((v) => v[0]);
91
91
  if (message) {
92
92
  if (chat) {
93
- chat.order = (0, _3_types_js_1.getChatOrder)(message, chat.pinned);
93
+ chat.order = (0, _3_types_js_1.getChatListItemOrder)(message, chat.pinned);
94
94
  chat.lastMessage = message;
95
95
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
96
96
  }
97
97
  else {
98
98
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
99
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
99
+ const chat = await (0, _3_types_js_1.constructChatListItem3)(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
100
100
  if (chat == null) {
101
101
  (0, _0_deps_js_1.unreachable)();
102
102
  }
@@ -108,7 +108,7 @@ class ChatListManager {
108
108
  return () => Promise.resolve();
109
109
  }
110
110
  if (chat) {
111
- chat.order = (0, _3_types_js_1.getChatOrder)(undefined, chat.pinned);
111
+ chat.order = (0, _3_types_js_1.getChatListItemOrder)(undefined, chat.pinned);
112
112
  chat.lastMessage = undefined;
113
113
  if (sendUpdate) {
114
114
  return () => __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
@@ -121,7 +121,7 @@ class ChatListManager {
121
121
  if (!__classPrivateFieldGet(this, _ChatListManager_chatsLoadedFromStorage, "f")) {
122
122
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadChatsFromStorage).call(this);
123
123
  }
124
- if (after && !__classPrivateFieldGet(this, _ChatListManager_chats, "f").get(after.id)) {
124
+ if (after && !__classPrivateFieldGet(this, _ChatListManager_chats, "f").get(after.chat.id)) {
125
125
  throw new _0_errors_js_1.InputError("Invalid after");
126
126
  }
127
127
  if (limit <= 0 || limit > 100) {
@@ -173,69 +173,11 @@ class ChatListManager {
173
173
  }
174
174
  }
175
175
  async getChat(chatId) {
176
- if (await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getAccountType() == "user") {
177
- let maybeChatId = null;
178
- if (typeof chatId === "number") {
179
- maybeChatId = chatId;
180
- }
181
- else if (typeof chatId === "string") {
182
- maybeChatId = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_tryGetChatId).call(this, (0, _0_utilities_js_1.getUsername)(chatId));
183
- }
184
- else {
185
- (0, _0_deps_js_1.unreachable)();
186
- }
187
- if (maybeChatId != null) {
188
- const [chat] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, maybeChatId);
189
- if (chat !== undefined) {
190
- return chat;
191
- }
192
- }
193
- }
194
- let inputPeer = null;
195
- if (typeof chatId === "number") {
196
- const chat = await (0, _3_types_js_1.constructChat3)(chatId, -1, undefined, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
197
- if (chat != null) {
198
- return chat;
199
- }
200
- }
201
- else {
202
- inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
203
- const chatId_ = (0, _2_tl_js_1.peerToChatId)(inputPeer);
204
- const chat = await (0, _3_types_js_1.constructChat3)(chatId_, -1, undefined, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
205
- if (chat != null) {
206
- return chat;
207
- }
208
- }
209
- if (inputPeer == null) {
210
- inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
211
- }
212
- if (inputPeer instanceof _2_tl_js_1.types.InputPeerChat) {
213
- const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.messages.Chats));
214
- const chat = chats.chats[0];
215
- if (chat instanceof _2_tl_js_1.types.ChatEmpty) {
216
- (0, _0_deps_js_1.unreachable)();
217
- }
218
- return (0, _3_types_js_1.constructChat2)(chat, -1, undefined);
219
- }
220
- else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) {
221
- const channels = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel(inputPeer)] });
222
- const channel = channels.chats[0];
223
- if (channel instanceof _2_tl_js_1.types.ChatEmpty) {
224
- (0, _0_deps_js_1.unreachable)();
225
- }
226
- return (0, _3_types_js_1.constructChat2)(channel, -1, undefined);
227
- }
228
- else if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser) {
229
- const users = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser(inputPeer)] });
230
- const user = users[0];
231
- if (user instanceof _2_tl_js_1.types.UserEmpty) {
232
- (0, _0_deps_js_1.unreachable)();
233
- }
234
- return (0, _3_types_js_1.constructChat2)(user, -1, undefined);
235
- }
236
- else {
237
- (0, _0_deps_js_1.unreachable)();
176
+ const fullChat = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getFullChat).call(this, chatId);
177
+ if (fullChat == null) {
178
+ throw new _0_errors_js_1.InputError("Chat not found.");
238
179
  }
180
+ return await (0, _3_types_js_1.constructChat)(fullChat, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
239
181
  }
240
182
  }
241
183
  exports.ChatListManager = ChatListManager;
@@ -253,15 +195,23 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
253
195
  username = username.toLowerCase();
254
196
  for (const chat of __classPrivateFieldGet(this, _ChatListManager_chats, "f").values()) {
255
197
  if ("username" in chat) {
256
- if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
257
- return chat.id;
198
+ if (chat.username === username
199
+ // TODO
200
+ // ||
201
+ // chat.chat.also?.some((v) => v.toLowerCase() === username)
202
+ ) {
203
+ return chat.chat.id;
258
204
  }
259
205
  }
260
206
  }
261
207
  for (const chat of __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").values()) {
262
208
  if ("username" in chat) {
263
- if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
264
- return chat.id;
209
+ if (chat.username === username
210
+ // TODO
211
+ // ||
212
+ // chat.also?.some((v) => v.toLowerCase() === username)
213
+ ) {
214
+ return chat.chat.id;
265
215
  }
266
216
  }
267
217
  }
@@ -289,18 +239,18 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
289
239
  const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(0);
290
240
  const archivedChats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(1);
291
241
  for (const { chatId, pinned, topMessageId } of chats) {
292
- const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
242
+ const chat = await (0, _3_types_js_1.constructChatListItem)(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
293
243
  if (chat == null) {
294
244
  continue;
295
245
  }
296
- __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chat.id, chat);
246
+ __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chat.chat.id, chat);
297
247
  }
298
248
  for (const { chatId, pinned, topMessageId } of archivedChats) {
299
- const chat = await (0, _3_types_js_1.constructChat4)(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
249
+ const chat = await (0, _3_types_js_1.constructChatListItem)(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
300
250
  if (chat == null) {
301
251
  continue;
302
252
  }
303
- __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").set(chat.id, chat);
253
+ __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").set(chat.chat.id, chat);
304
254
  }
305
255
  __classPrivateFieldSet(this, _ChatListManager_chatsLoadedFromStorage, true, "f");
306
256
  }, _ChatListManager_getLoadedChats = function _ChatListManager_getLoadedChats(listId) {
@@ -310,7 +260,7 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
310
260
  chats.push(chat);
311
261
  }
312
262
  return chats
313
- .sort((a, b) => b.id - a.id)
263
+ .sort((a, b) => b.chat.id - a.chat.id)
314
264
  .sort((a, b) => b.order.localeCompare(a.order));
315
265
  }, _ChatListManager_loadPinnedChats = async function _ChatListManager_loadPinnedChats() {
316
266
  const [pinnedChats, pinnedArchiveChats] = await Promise.all([__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(0), __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(1)]);
@@ -360,14 +310,14 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
360
310
  }, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
361
311
  const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
362
312
  if (chat !== undefined) {
363
- const newChat = await (0, _3_types_js_1.constructChat3)(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
313
+ const newChat = await (0, _3_types_js_1.constructChatListItem3)(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
364
314
  if (newChat != null) {
365
315
  __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, newChat);
366
316
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
367
317
  }
368
318
  }
369
319
  else {
370
- const chat = await (0, _3_types_js_1.constructChat4)(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
320
+ const chat = await (0, _3_types_js_1.constructChatListItem)(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
371
321
  if (chat != null) {
372
322
  __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, 0).set(chatId, chat);
373
323
  await this.reassignChatLastMessage(chatId, false, false);
@@ -398,55 +348,61 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
398
348
  for (const [i, chatId] of pinnedChats.entries()) {
399
349
  const chat = chats.get(chatId);
400
350
  if (chat !== undefined) {
401
- chat.order = (0, _3_types_js_1.getChatOrder)(chat.lastMessage, i);
351
+ chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, i);
402
352
  chat.pinned = i;
403
353
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
404
354
  }
405
355
  }
406
356
  for (const chat of chats.values()) {
407
- if (chat.pinned != -1 && pinnedChats.indexOf(chat.id) == -1) {
408
- chat.order = (0, _3_types_js_1.getChatOrder)(chat.lastMessage, -1);
357
+ if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
358
+ chat.order = (0, _3_types_js_1.getChatListItemOrder)(chat.lastMessage, -1);
409
359
  chat.pinned = -1;
410
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.id, false);
360
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.chat.id, false);
411
361
  }
412
362
  }
413
363
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId));
414
364
  }, _ChatListManager_handleUpdateChannel = async function _ChatListManager_handleUpdateChannel(update) {
415
365
  const peer = new _2_tl_js_1.types.PeerChannel(update);
416
366
  const channel = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
367
+ const chatId = (0, _2_tl_js_1.peerToChatId)(peer);
368
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
417
369
  if (channel != null && "left" in channel && channel.left) {
418
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
370
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
419
371
  }
420
372
  else if (channel instanceof _2_tl_js_1.types.ChannelForbidden) {
421
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
373
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
422
374
  }
423
375
  else if (channel instanceof _2_tl_js_1.types.Channel) {
424
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
376
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
425
377
  }
426
378
  }, _ChatListManager_handleUpdateChat = async function _ChatListManager_handleUpdateChat(update) {
427
379
  const peer = new _2_tl_js_1.types.PeerChat(update);
428
380
  const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
381
+ const chatId = (0, _2_tl_js_1.peerToChatId)(peer);
382
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
429
383
  if (chat != null && "left" in chat && chat.left) {
430
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
384
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
431
385
  }
432
386
  else if (chat instanceof _2_tl_js_1.types.ChatForbidden) {
433
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
387
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
434
388
  }
435
389
  else if (chat instanceof _2_tl_js_1.types.Chat) {
436
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
390
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
437
391
  }
438
392
  }, _ChatListManager_handleUpdateUser = async function _ChatListManager_handleUpdateUser(update) {
439
393
  const peer = new _2_tl_js_1.types.PeerUser(update);
440
394
  const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
395
+ const chatId = (0, _2_tl_js_1.peerToChatId)(peer);
396
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
441
397
  if (chat != null) {
442
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, (0, _2_tl_js_1.peerToChatId)(peer));
398
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
443
399
  }
444
400
  }, _ChatListManager_fetchChats = async function _ChatListManager_fetchChats(listId, limit, after) {
445
401
  const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getDialogs({
446
402
  limit,
447
403
  offset_id: after?.lastMessage?.id ?? 0,
448
404
  offset_date: after?.lastMessage?.date ? (0, _1_utilities_js_1.toUnixTimestamp)(after.lastMessage.date) : 0,
449
- offset_peer: after ? await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(after.id) : new _2_tl_js_1.types.InputPeerEmpty(),
405
+ offset_peer: after ? await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(after.chat.id) : new _2_tl_js_1.types.InputPeerEmpty(),
450
406
  hash: 0n,
451
407
  folder_id: listId,
452
408
  });
@@ -459,8 +415,29 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
459
415
  }
460
416
  const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
461
417
  for (const dialog of dialogs.dialogs) {
462
- const chat = await (0, _3_types_js_1.constructChat)(dialog, dialogs, pinnedChats, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager), __classPrivateFieldGet(this, _ChatListManager_c, "f").fileManager.getStickerSetName.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
463
- chats.set(chat.id, chat);
464
- await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chat.id, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
418
+ const chat = await (0, _3_types_js_1.constructChatListItem4)(dialog, dialogs, pinnedChats, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager), __classPrivateFieldGet(this, _ChatListManager_c, "f").fileManager.getStickerSetName.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
419
+ chats.set(chat.chat.id, chat);
420
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chat.chat.id, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
421
+ }
422
+ }, _ChatListManager_getFullChat = async function _ChatListManager_getFullChat(chatId) {
423
+ const inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
424
+ const chatId_ = (0, _2_tl_js_1.peerToChatId)(inputPeer);
425
+ let fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getFullChat(chatId_);
426
+ if (fullChat != null) {
427
+ return fullChat;
428
+ }
429
+ if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser) {
430
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.users.getFullUser({ id: new _2_tl_js_1.types.InputUser(inputPeer) }).then((v) => v.full_user);
431
+ }
432
+ else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChat) {
433
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getFullChat(inputPeer).then((v) => v.full_chat);
434
+ }
435
+ else if (inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) {
436
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.channels.getFullChannel({ channel: new _2_tl_js_1.types.InputChannel(inputPeer) }).then((v) => v.full_chat);
437
+ }
438
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId_, fullChat);
439
+ if (fullChat != null && "call" in fullChat && fullChat.call) {
440
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
465
441
  }
442
+ return fullChat;
466
443
  };
@@ -20,8 +20,8 @@
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { ID, InlineQueryResult, Update } from "../3_types.js";
22
22
  import { AnswerInlineQueryParams, SendInlineQueryParams } from "./0_params.js";
23
- import { C as C_ } from "./0_types.js";
24
- import { MessageManager } from "./2_message_manager.js";
23
+ import { C as C_ } from "./1_types.js";
24
+ import { MessageManager } from "./3_message_manager.js";
25
25
  type C = C_ & {
26
26
  messageManager: MessageManager;
27
27
  };
@@ -70,6 +70,7 @@ class InlineQueryManager {
70
70
  }
71
71
  }
72
72
  async sendInlineQuery(userId, chatId, params) {
73
+ await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertUser("sendInlineQuery");
73
74
  const bot = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").getInputUser(userId), peer = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").getInputPeer(chatId), query = params?.query ?? "", offset = params?.offset ?? "";
74
75
  const botId = (0, _2_tl_js_1.peerToChatId)(bot), peerId = (0, _2_tl_js_1.peerToChatId)(peer);
75
76
  const maybeResults = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageStorage.getInlineQueryAnswer(botId, peerId, query, offset);
@@ -21,9 +21,9 @@ import { enums, types } from "../2_tl.js";
21
21
  import { ID, Story, Update } from "../3_types.js";
22
22
  import { InputStoryContent } from "../types/1_input_story_content.js";
23
23
  import { CreateStoryParams } from "./0_params.js";
24
- import { C as C_ } from "./0_types.js";
25
- import { FileManager } from "./1_file_manager.js";
26
- import { MessageManager } from "./2_message_manager.js";
24
+ import { C as C_ } from "./1_types.js";
25
+ import { FileManager } from "./2_file_manager.js";
26
+ import { MessageManager } from "./3_message_manager.js";
27
27
  type C = C_ & {
28
28
  fileManager: FileManager;
29
29
  messageManager: MessageManager;
@@ -19,18 +19,19 @@
19
19
  */
20
20
  import { MaybePromise } from "../1_utilities.js";
21
21
  import { enums, functions, types } from "../2_tl.js";
22
- import { Storage } from "../3_storage.js";
22
+ import { Storage } from "../2_storage.js";
23
23
  import { DC } from "../3_transport.js";
24
- import { BotCommand, BusinessConnection, CallbackQueryAnswer, CallbackQueryQuestion, Chat, ChatAction, ChatMember, ChatP, FileSource, ID, InactiveChat, InlineQueryAnswer, InlineQueryResult, InputMedia, InputStoryContent, InviteLink, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageSticker, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Poll, Reaction, Sticker, Story, Update, User } from "../3_types.js";
24
+ import { BotCommand, BusinessConnection, CallbackQueryAnswer, CallbackQueryQuestion, Chat, ChatAction, ChatListItem, ChatMember, ChatP, FileSource, ID, InactiveChat, InlineQueryAnswer, InlineQueryResult, InputMedia, InputStoryContent, InviteLink, LiveStreamChannel, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageSticker, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Poll, Reaction, Sticker, Story, Update, User, VideoChat, VideoChatActive, VideoChatScheduled } from "../3_types.js";
25
25
  import { Migrate } from "../4_errors.js";
26
- import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendInlineQueryParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, StopPollParams } from "./0_params.js";
27
- import { Api } from "./0_types.js";
26
+ import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadLiveStreamChunkParams, DownloadParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, JoinVideoChatParams, PinMessageParams, ReplyParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendInlineQueryParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, SignInParams, StartVideoChatParams, StopPollParams } from "./0_params.js";
27
+ import { Api } from "./1_types.js";
28
28
  import { ClientPlainParams } from "./1_client_plain.js";
29
29
  import { Composer as Composer_, NextFunction } from "./1_composer.js";
30
+ import { StorageOperations } from "./0_storage_operations.js";
30
31
  export interface Context {
31
32
  /** The client that received the update. */
32
33
  client: Client;
33
- /** The currently authorized user. */
34
+ /** The currently signed in user. */
34
35
  me?: User;
35
36
  /** Resolves to `message`, `editedMessage`, or the `message` field of `callbackQuery`. */
36
37
  msg?: Message;
@@ -184,19 +185,25 @@ export declare const restartAuth: unique symbol;
184
185
  export declare const handleMigrationError: unique symbol;
185
186
  declare const getEntity: unique symbol;
186
187
  export interface ClientParams extends ClientPlainParams {
188
+ /** The storage provider to use. Defaults to memory storage. Passing a string constructs a memory storage with the string being the auth string. */
189
+ storage?: Storage;
190
+ /** App's API ID from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
191
+ apiId?: number;
192
+ /** App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
193
+ apiHash?: string;
187
194
  /** A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defaults to `ParseMode.None`. */
188
195
  parseMode?: ParseMode;
189
- /** The app_version parameter to be passed to initConnection when calling `authorize`. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
196
+ /** The app_version parameter to be passed to initConnection. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
190
197
  appVersion?: string;
191
- /** The device_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime. */
198
+ /** The device_version parameter to be passed to initConnection. The default varies by the current runtime. */
192
199
  deviceModel?: string;
193
- /** The lang_code parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`. */
200
+ /** The lang_code parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
194
201
  langCode?: string;
195
- /** The lang_pack parameter to be passed to initConnection when calling `authorize`. Defaults to an empty string. */
202
+ /** The lang_pack parameter to be passed to initConnection. Defaults to an empty string. */
196
203
  langPack?: string;
197
- /** The system_lang_cde parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`. */
204
+ /** The system_lang_cde parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
198
205
  systemLangCode?: string;
199
- /** The system_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime. */
206
+ /** The system_version parameter to be passed to initConnection. The default varies by the current runtime. */
200
207
  systemVersion?: string;
201
208
  /** Whether to use default handlers. Defaults to `true`. */
202
209
  defaultHandlers?: boolean;
@@ -208,18 +215,26 @@ export interface ClientParams extends ClientPlainParams {
208
215
  guaranteeUpdateDelivery?: boolean;
209
216
  /** Whether to not handle updates received when the client was not running. Defaults to `true` for bots, and `false` for users. */
210
217
  dropPendingUpdates?: boolean;
211
- /** Whether to store messages. Defaults to `false`. */
212
- storeMessages?: boolean;
218
+ /**
219
+ * Whether to persist cache to the provided storage, and not memory. Defaults to `false`.
220
+ *
221
+ * Explicitly setting this option to `true` is highly recommended if:
222
+ *
223
+ * - User accounts are authorized.
224
+ * - Less memory usage is demanded.
225
+ * - The client does not usually have a large uptime.
226
+ *
227
+ * When the provided storage takes advantage of memory, nothing changes, even if set to `true`.
228
+ */
229
+ persistCache?: boolean;
213
230
  }
214
231
  /**
215
232
  * An MTKruto client.
216
233
  */
217
234
  export declare class Client<C extends Context = Context> extends Composer<C> {
218
235
  #private;
219
- readonly apiId: number | null;
220
- readonly apiHash: string | null;
221
- readonly storage: Storage;
222
- readonly messageStorage: Storage;
236
+ readonly storage: StorageOperations;
237
+ readonly messageStorage: StorageOperations;
223
238
  readonly appVersion: string;
224
239
  readonly deviceModel: string;
225
240
  readonly langCode: string;
@@ -233,7 +248,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
233
248
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
234
249
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
235
250
  */
236
- constructor(storage?: Storage | string | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
251
+ constructor(params?: ClientParams);
237
252
  get connected(): boolean;
238
253
  get disconnected(): boolean;
239
254
  api: Api;
@@ -254,24 +269,19 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
254
269
  [handleMigrationError](err: Migrate): Promise<void>;
255
270
  disconnect(): Promise<void>;
256
271
  /**
257
- * Authorizes the client with one of the following:
258
- *
259
- * - Bot token (`string`)
260
- * - User authorization handlers (`AuthorizeUserParams`)
261
- *
262
- * if the current auth key doesn't throw AUTH_KEY_UNREGISTERED when calling [updates.getState](1).
272
+ * Signs in using the provided parameters if not already signed in.
273
+ * If no parameters are provided, the credentials will be prompted in runtime.
263
274
  *
264
275
  * Notes:
265
276
  * 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
266
- * 2. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
267
- *
268
- * [1]: https://core.telegram.org/method/updates.getState
277
+ * 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
269
278
  */
270
- authorize(params?: string | AuthorizeUserParams): Promise<void>;
279
+ signIn(params?: SignInParams): Promise<void>;
280
+ signOut(): Promise<void>;
271
281
  /**
272
- * Same as calling `.connect()` followed by `.authorize(params)`.
282
+ * Same as calling `.connect()` followed by `.signIn(params)`.
273
283
  */
274
- start(params?: string | AuthorizeUserParams): Promise<void>;
284
+ start(params?: SignInParams): Promise<void>;
275
285
  /**
276
286
  * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
277
287
  * to be connected.
@@ -706,7 +716,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
706
716
  *
707
717
  * @method ch
708
718
  */
709
- getChats(params?: GetChatsParams): Promise<Chat[]>;
719
+ getChats(params?: GetChatsParams): Promise<ChatListItem[]>;
710
720
  /**
711
721
  * Get a chat.
712
722
  *
@@ -1087,5 +1097,69 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
1087
1097
  * @param userId The identifier of the user to unblock.
1088
1098
  */
1089
1099
  unblockUser(userId: ID): Promise<void>;
1100
+ /**
1101
+ * Start a video chat. User-only.
1102
+ *
1103
+ * @method vc
1104
+ * @param chatId The chat to start the video chat in.
1105
+ * @returns The started video chat.
1106
+ */
1107
+ startVideoChat(chatId: ID, params?: StartVideoChatParams): Promise<VideoChatActive>;
1108
+ /**
1109
+ * Schedule a video chat. User-only.
1110
+ *
1111
+ * @method vc
1112
+ * @param chatId The chat to schedule the video chat in.
1113
+ * @param startAt A point in time within the future in which the video chat will be started.
1114
+ * @returns The scheduled video chat.
1115
+ */
1116
+ scheduleVideoChat(chatId: ID, startAt: Date, params?: ScheduleVideoChatParams): Promise<VideoChatScheduled>;
1117
+ /**
1118
+ * Join a video chat. User-only.
1119
+ *
1120
+ * @method vc
1121
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1122
+ * @param params_ WebRTC connection parameters.
1123
+ * @returns Parameters to be passed to the used WebRTC library.
1124
+ */
1125
+ joinVideoChat(id: string, params_: string, params?: JoinVideoChatParams): Promise<string>;
1126
+ /**
1127
+ * Leave a video chat. User-only.
1128
+ *
1129
+ * @method vc
1130
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1131
+ */
1132
+ leaveVideoChat(id: string): Promise<void>;
1133
+ /**
1134
+ * Join a live stream. User-only.
1135
+ *
1136
+ * @method vc
1137
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1138
+ */
1139
+ joinLiveStream(id: string): Promise<void>;
1140
+ /**
1141
+ * Get a video chat. User-only.
1142
+ *
1143
+ * @method vc
1144
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1145
+ */
1146
+ getVideoChat(id: string): Promise<VideoChat>;
1147
+ /**
1148
+ * Get live stream channels. User-only.
1149
+ *
1150
+ * @method vc
1151
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1152
+ */
1153
+ getLiveStreamChannels(id: string): Promise<LiveStreamChannel[]>;
1154
+ /**
1155
+ * Download a live stream chunk. User-only.
1156
+ *
1157
+ * @method vc
1158
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1159
+ * @param channelId Stream channel ID.
1160
+ * @param scale Stream channel scale.
1161
+ * @param timestamp Millisecond timestamp of the chunk to download.
1162
+ */
1163
+ downloadLiveStreamChunk(id: string, channelId: number, scale: number, timestamp: number, params?: DownloadLiveStreamChunkParams): AsyncGenerator<Uint8Array, void, unknown>;
1090
1164
  }
1091
1165
  export {};