@mtkruto/node 0.1.500 → 0.1.600

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 (91) hide show
  1. package/esm/3_types.d.ts +6 -1
  2. package/esm/3_types.js +6 -1
  3. package/esm/client/0_params.d.ts +28 -6
  4. package/esm/client/1_file_manager.d.ts +5 -1
  5. package/esm/client/1_file_manager.js +50 -49
  6. package/esm/client/2_video_chat_manager.d.ts +43 -0
  7. package/esm/client/2_video_chat_manager.js +194 -0
  8. package/esm/client/3_callback_query_manager.js +1 -0
  9. package/esm/client/3_chat_list_manager.d.ts +3 -3
  10. package/esm/client/3_chat_list_manager.js +75 -98
  11. package/esm/client/3_inline_query_manager.js +1 -0
  12. package/esm/client/4_client.d.ts +67 -3
  13. package/esm/client/4_client.js +92 -3
  14. package/esm/storage/0_storage.d.ts +14 -0
  15. package/esm/storage/0_storage.js +39 -2
  16. package/esm/tl/3_utilities.d.ts +1 -1
  17. package/esm/tl/3_utilities.js +3 -3
  18. package/esm/types/0_birthday.d.ts +27 -0
  19. package/esm/types/0_birthday.js +26 -0
  20. package/esm/types/0_giveaway_parameters.d.ts +1 -1
  21. package/esm/types/0_live_stream_channel.d.ts +30 -0
  22. package/esm/types/0_live_stream_channel.js +26 -0
  23. package/esm/types/0_opening_hours.d.ts +25 -0
  24. package/esm/types/0_opening_hours.js +25 -0
  25. package/esm/types/0_video_chat.d.ts +60 -0
  26. package/esm/types/0_video_chat.js +53 -0
  27. package/esm/types/1_chat_p.d.ts +4 -0
  28. package/esm/types/1_chat_p.js +1 -0
  29. package/esm/types/2_business_connection.d.ts +6 -0
  30. package/esm/types/2_chat.d.ts +62 -0
  31. package/esm/types/2_chat.js +66 -0
  32. package/esm/types/2_inactive_chat.d.ts +1 -1
  33. package/esm/types/2_invite_link.d.ts +1 -1
  34. package/esm/types/2_message_reaction_count.d.ts +1 -1
  35. package/esm/types/2_message_reactions.d.ts +1 -1
  36. package/esm/types/3_chat_member_updated.d.ts +1 -1
  37. package/esm/types/4_message.d.ts +3 -3
  38. package/esm/types/5_chat_list_item.d.ts +35 -0
  39. package/esm/types/5_chat_list_item.js +86 -0
  40. package/esm/types/6_update.d.ts +14 -5
  41. package/esm/types/_file_id.d.ts +1 -0
  42. package/esm/utilities/0_bigint.d.ts +1 -0
  43. package/esm/utilities/0_bigint.js +7 -3
  44. package/package.json +1 -1
  45. package/script/3_types.d.ts +6 -1
  46. package/script/3_types.js +6 -1
  47. package/script/client/0_params.d.ts +28 -6
  48. package/script/client/1_file_manager.d.ts +5 -1
  49. package/script/client/1_file_manager.js +50 -49
  50. package/script/client/2_video_chat_manager.d.ts +43 -0
  51. package/script/client/2_video_chat_manager.js +198 -0
  52. package/script/client/3_callback_query_manager.js +1 -0
  53. package/script/client/3_chat_list_manager.d.ts +3 -3
  54. package/script/client/3_chat_list_manager.js +72 -95
  55. package/script/client/3_inline_query_manager.js +1 -0
  56. package/script/client/4_client.d.ts +67 -3
  57. package/script/client/4_client.js +92 -3
  58. package/script/storage/0_storage.d.ts +14 -0
  59. package/script/storage/0_storage.js +39 -2
  60. package/script/tl/3_utilities.d.ts +1 -1
  61. package/script/tl/3_utilities.js +3 -3
  62. package/script/types/0_birthday.d.ts +27 -0
  63. package/script/types/0_birthday.js +30 -0
  64. package/script/types/0_giveaway_parameters.d.ts +1 -1
  65. package/script/types/0_live_stream_channel.d.ts +30 -0
  66. package/script/types/0_live_stream_channel.js +30 -0
  67. package/script/types/0_opening_hours.d.ts +25 -0
  68. package/script/types/0_opening_hours.js +29 -0
  69. package/script/types/0_video_chat.d.ts +60 -0
  70. package/script/types/0_video_chat.js +57 -0
  71. package/script/types/1_chat_p.d.ts +4 -0
  72. package/script/types/1_chat_p.js +1 -0
  73. package/script/types/2_business_connection.d.ts +6 -0
  74. package/script/types/2_chat.d.ts +62 -0
  75. package/script/types/2_chat.js +70 -0
  76. package/script/types/2_inactive_chat.d.ts +1 -1
  77. package/script/types/2_invite_link.d.ts +1 -1
  78. package/script/types/2_message_reaction_count.d.ts +1 -1
  79. package/script/types/2_message_reactions.d.ts +1 -1
  80. package/script/types/3_chat_member_updated.d.ts +1 -1
  81. package/script/types/4_message.d.ts +3 -3
  82. package/script/types/5_chat_list_item.d.ts +35 -0
  83. package/script/types/5_chat_list_item.js +94 -0
  84. package/script/types/6_update.d.ts +14 -5
  85. package/script/types/_file_id.d.ts +1 -0
  86. package/script/utilities/0_bigint.d.ts +1 -0
  87. package/script/utilities/0_bigint.js +7 -3
  88. package/esm/types/5_chat.d.ts +0 -59
  89. package/esm/types/5_chat.js +0 -126
  90. package/script/types/5_chat.d.ts +0 -59
  91. package/script/types/5_chat.js +0 -134
@@ -28,13 +28,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
28
28
  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");
29
29
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
30
  };
31
- 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;
31
+ 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;
32
32
  import { unreachable } from "../0_deps.js";
33
33
  import { InputError } from "../0_errors.js";
34
34
  import { getLogger, toUnixTimestamp } from "../1_utilities.js";
35
- import { as, peerToChatId, types } from "../2_tl.js";
36
- import { constructChat, constructChat2, constructChat3, constructChat4, getChatOrder } from "../3_types.js";
37
- import { getChatListId, getUsername } from "./0_utilities.js";
35
+ import { peerToChatId, types } from "../2_tl.js";
36
+ import { constructChat, constructChatListItem, constructChatListItem3, constructChatListItem4, getChatListItemOrder } from "../3_types.js";
37
+ import { getChatListId } from "./0_utilities.js";
38
38
  export class ChatListManager {
39
39
  constructor(c) {
40
40
  _ChatListManager_instances.add(this);
@@ -66,13 +66,13 @@ export class ChatListManager {
66
66
  if (message_ != null) {
67
67
  const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.constructMessage(message_);
68
68
  if (chat) {
69
- chat.order = getChatOrder(message, chat.pinned);
69
+ chat.order = getChatListItemOrder(message, chat.pinned);
70
70
  chat.lastMessage = message;
71
71
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
72
72
  }
73
73
  else {
74
74
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
75
- const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
75
+ const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
76
76
  if (chat == null) {
77
77
  unreachable();
78
78
  }
@@ -87,13 +87,13 @@ export class ChatListManager {
87
87
  const message = await __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getHistory(chatId, { limit: 1 }).then((v) => v[0]);
88
88
  if (message) {
89
89
  if (chat) {
90
- chat.order = getChatOrder(message, chat.pinned);
90
+ chat.order = getChatListItemOrder(message, chat.pinned);
91
91
  chat.lastMessage = message;
92
92
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chatId, chat.pinned, message.id, message.date);
93
93
  }
94
94
  else {
95
95
  const pinnedChats = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId);
96
- const chat = await constructChat3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
96
+ const chat = await constructChatListItem3(chatId, pinnedChats.indexOf(chatId), message, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
97
97
  if (chat == null) {
98
98
  unreachable();
99
99
  }
@@ -105,7 +105,7 @@ export class ChatListManager {
105
105
  return () => Promise.resolve();
106
106
  }
107
107
  if (chat) {
108
- chat.order = getChatOrder(undefined, chat.pinned);
108
+ chat.order = getChatListItemOrder(undefined, chat.pinned);
109
109
  chat.lastMessage = undefined;
110
110
  if (sendUpdate) {
111
111
  return () => __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
@@ -118,7 +118,7 @@ export class ChatListManager {
118
118
  if (!__classPrivateFieldGet(this, _ChatListManager_chatsLoadedFromStorage, "f")) {
119
119
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_loadChatsFromStorage).call(this);
120
120
  }
121
- if (after && !__classPrivateFieldGet(this, _ChatListManager_chats, "f").get(after.id)) {
121
+ if (after && !__classPrivateFieldGet(this, _ChatListManager_chats, "f").get(after.chat.id)) {
122
122
  throw new InputError("Invalid after");
123
123
  }
124
124
  if (limit <= 0 || limit > 100) {
@@ -170,69 +170,11 @@ export class ChatListManager {
170
170
  }
171
171
  }
172
172
  async getChat(chatId) {
173
- if (await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getAccountType() == "user") {
174
- let maybeChatId = null;
175
- if (typeof chatId === "number") {
176
- maybeChatId = chatId;
177
- }
178
- else if (typeof chatId === "string") {
179
- maybeChatId = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_tryGetChatId).call(this, getUsername(chatId));
180
- }
181
- else {
182
- unreachable();
183
- }
184
- if (maybeChatId != null) {
185
- const [chat] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, maybeChatId);
186
- if (chat !== undefined) {
187
- return chat;
188
- }
189
- }
190
- }
191
- let inputPeer = null;
192
- if (typeof chatId === "number") {
193
- const chat = await constructChat3(chatId, -1, undefined, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
194
- if (chat != null) {
195
- return chat;
196
- }
197
- }
198
- else {
199
- inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
200
- const chatId_ = peerToChatId(inputPeer);
201
- const chat = await constructChat3(chatId_, -1, undefined, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
202
- if (chat != null) {
203
- return chat;
204
- }
205
- }
206
- if (inputPeer == null) {
207
- inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
208
- }
209
- if (inputPeer instanceof types.InputPeerChat) {
210
- const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getChats({ id: [inputPeer.chat_id] }).then((v) => v[as](types.messages.Chats));
211
- const chat = chats.chats[0];
212
- if (chat instanceof types.ChatEmpty) {
213
- unreachable();
214
- }
215
- return constructChat2(chat, -1, undefined);
216
- }
217
- else if (inputPeer instanceof types.InputPeerChannel) {
218
- const channels = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.channels.getChannels({ id: [new types.InputChannel(inputPeer)] });
219
- const channel = channels.chats[0];
220
- if (channel instanceof types.ChatEmpty) {
221
- unreachable();
222
- }
223
- return constructChat2(channel, -1, undefined);
224
- }
225
- else if (inputPeer instanceof types.InputPeerUser) {
226
- const users = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.users.getUsers({ id: [new types.InputUser(inputPeer)] });
227
- const user = users[0];
228
- if (user instanceof types.UserEmpty) {
229
- unreachable();
230
- }
231
- return constructChat2(user, -1, undefined);
232
- }
233
- else {
234
- unreachable();
173
+ const fullChat = await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getFullChat).call(this, chatId);
174
+ if (fullChat == null) {
175
+ throw new InputError("Chat not found.");
235
176
  }
177
+ return await constructChat(fullChat, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
236
178
  }
237
179
  }
238
180
  _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(), _ChatListManager_chats = new WeakMap(), _ChatListManager_archivedChats = new WeakMap(), _ChatListManager_chatsLoadedFromStorage = new WeakMap(), _ChatListManager_pinnedChats = new WeakMap(), _ChatListManager_pinnedArchiveChats = new WeakMap(), _ChatListManager_storageHadPinnedChats = new WeakMap(), _ChatListManager_pinnedChatsLoaded = new WeakMap(), _ChatListManager_instances = new WeakSet(), _ChatListManager_sendChatUpdate = async function _ChatListManager_sendChatUpdate(chatId, added) {
@@ -249,15 +191,23 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
249
191
  username = username.toLowerCase();
250
192
  for (const chat of __classPrivateFieldGet(this, _ChatListManager_chats, "f").values()) {
251
193
  if ("username" in chat) {
252
- if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
253
- return chat.id;
194
+ if (chat.username === username
195
+ // TODO
196
+ // ||
197
+ // chat.chat.also?.some((v) => v.toLowerCase() === username)
198
+ ) {
199
+ return chat.chat.id;
254
200
  }
255
201
  }
256
202
  }
257
203
  for (const chat of __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").values()) {
258
204
  if ("username" in chat) {
259
- if (chat.username === username || chat.also?.some((v) => v.toLowerCase() === username)) {
260
- return chat.id;
205
+ if (chat.username === username
206
+ // TODO
207
+ // ||
208
+ // chat.also?.some((v) => v.toLowerCase() === username)
209
+ ) {
210
+ return chat.chat.id;
261
211
  }
262
212
  }
263
213
  }
@@ -285,18 +235,18 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
285
235
  const chats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(0);
286
236
  const archivedChats = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getChats(1);
287
237
  for (const { chatId, pinned, topMessageId } of chats) {
288
- const chat = await constructChat4(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
238
+ const chat = await constructChatListItem(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
289
239
  if (chat == null) {
290
240
  continue;
291
241
  }
292
- __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chat.id, chat);
242
+ __classPrivateFieldGet(this, _ChatListManager_chats, "f").set(chat.chat.id, chat);
293
243
  }
294
244
  for (const { chatId, pinned, topMessageId } of archivedChats) {
295
- const chat = await constructChat4(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
245
+ const chat = await constructChatListItem(chatId, pinned, topMessageId, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
296
246
  if (chat == null) {
297
247
  continue;
298
248
  }
299
- __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").set(chat.id, chat);
249
+ __classPrivateFieldGet(this, _ChatListManager_archivedChats, "f").set(chat.chat.id, chat);
300
250
  }
301
251
  __classPrivateFieldSet(this, _ChatListManager_chatsLoadedFromStorage, true, "f");
302
252
  }, _ChatListManager_getLoadedChats = function _ChatListManager_getLoadedChats(listId) {
@@ -306,7 +256,7 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
306
256
  chats.push(chat);
307
257
  }
308
258
  return chats
309
- .sort((a, b) => b.id - a.id)
259
+ .sort((a, b) => b.chat.id - a.chat.id)
310
260
  .sort((a, b) => b.order.localeCompare(a.order));
311
261
  }, _ChatListManager_loadPinnedChats = async function _ChatListManager_loadPinnedChats() {
312
262
  const [pinnedChats, pinnedArchiveChats] = await Promise.all([__classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(0), __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getPinnedChats(1)]);
@@ -356,14 +306,14 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
356
306
  }, _ChatListManager_updateOrAddChat = async function _ChatListManager_updateOrAddChat(chatId) {
357
307
  const [chat, listId] = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatAnywhere).call(this, chatId);
358
308
  if (chat !== undefined) {
359
- const newChat = await constructChat3(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
309
+ const newChat = await constructChatListItem3(chatId, chat.pinned, chat.lastMessage, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity);
360
310
  if (newChat != null) {
361
311
  __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId).set(chatId, newChat);
362
312
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
363
313
  }
364
314
  }
365
315
  else {
366
- const chat = await constructChat4(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
316
+ const chat = await constructChatListItem(chatId, -1, -1, __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity, __classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager.getMessage.bind(__classPrivateFieldGet(this, _ChatListManager_c, "f").messageManager));
367
317
  if (chat != null) {
368
318
  __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, 0).set(chatId, chat);
369
319
  await this.reassignChatLastMessage(chatId, false, false);
@@ -394,55 +344,61 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
394
344
  for (const [i, chatId] of pinnedChats.entries()) {
395
345
  const chat = chats.get(chatId);
396
346
  if (chat !== undefined) {
397
- chat.order = getChatOrder(chat.lastMessage, i);
347
+ chat.order = getChatListItemOrder(chat.lastMessage, i);
398
348
  chat.pinned = i;
399
349
  await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chatId, false);
400
350
  }
401
351
  }
402
352
  for (const chat of chats.values()) {
403
- if (chat.pinned != -1 && pinnedChats.indexOf(chat.id) == -1) {
404
- chat.order = getChatOrder(chat.lastMessage, -1);
353
+ if (chat.pinned != -1 && pinnedChats.indexOf(chat.chat.id) == -1) {
354
+ chat.order = getChatListItemOrder(chat.lastMessage, -1);
405
355
  chat.pinned = -1;
406
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.id, false);
356
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_sendChatUpdate).call(this, chat.chat.id, false);
407
357
  }
408
358
  }
409
359
  await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setPinnedChats(listId, await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getPinnedChats).call(this, listId));
410
360
  }, _ChatListManager_handleUpdateChannel = async function _ChatListManager_handleUpdateChannel(update) {
411
361
  const peer = new types.PeerChannel(update);
412
362
  const channel = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
363
+ const chatId = peerToChatId(peer);
364
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
413
365
  if (channel != null && "left" in channel && channel.left) {
414
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
366
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
415
367
  }
416
368
  else if (channel instanceof types.ChannelForbidden) {
417
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
369
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
418
370
  }
419
371
  else if (channel instanceof types.Channel) {
420
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
372
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
421
373
  }
422
374
  }, _ChatListManager_handleUpdateChat = async function _ChatListManager_handleUpdateChat(update) {
423
375
  const peer = new types.PeerChat(update);
424
376
  const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
377
+ const chatId = peerToChatId(peer);
378
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
425
379
  if (chat != null && "left" in chat && chat.left) {
426
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
380
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
427
381
  }
428
382
  else if (chat instanceof types.ChatForbidden) {
429
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, peerToChatId(peer));
383
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_removeChat).call(this, chatId);
430
384
  }
431
385
  else if (chat instanceof types.Chat) {
432
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
386
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
433
387
  }
434
388
  }, _ChatListManager_handleUpdateUser = async function _ChatListManager_handleUpdateUser(update) {
435
389
  const peer = new types.PeerUser(update);
436
390
  const chat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getEntity(peer);
391
+ const chatId = peerToChatId(peer);
392
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId, null);
437
393
  if (chat != null) {
438
- await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, peerToChatId(peer));
394
+ await __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_updateOrAddChat).call(this, chatId);
439
395
  }
440
396
  }, _ChatListManager_fetchChats = async function _ChatListManager_fetchChats(listId, limit, after) {
441
397
  const dialogs = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getDialogs({
442
398
  limit,
443
399
  offset_id: after?.lastMessage?.id ?? 0,
444
400
  offset_date: after?.lastMessage?.date ? toUnixTimestamp(after.lastMessage.date) : 0,
445
- offset_peer: after ? await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(after.id) : new types.InputPeerEmpty(),
401
+ offset_peer: after ? await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(after.chat.id) : new types.InputPeerEmpty(),
446
402
  hash: 0n,
447
403
  folder_id: listId,
448
404
  });
@@ -455,8 +411,29 @@ _ChatListManager_c = new WeakMap(), _ChatListManager_LgetChats = new WeakMap(),
455
411
  }
456
412
  const chats = __classPrivateFieldGet(this, _ChatListManager_instances, "m", _ChatListManager_getChatList).call(this, listId);
457
413
  for (const dialog of dialogs.dialogs) {
458
- const chat = await 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));
459
- chats.set(chat.id, chat);
460
- await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chat.id, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
414
+ const chat = await 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));
415
+ chats.set(chat.chat.id, chat);
416
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setChat(listId, chat.chat.id, chat.pinned, chat.lastMessage?.id ?? 0, chat.lastMessage?.date ?? new Date(0));
417
+ }
418
+ }, _ChatListManager_getFullChat = async function _ChatListManager_getFullChat(chatId) {
419
+ const inputPeer = await __classPrivateFieldGet(this, _ChatListManager_c, "f").getInputPeer(chatId);
420
+ const chatId_ = peerToChatId(inputPeer);
421
+ let fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.getFullChat(chatId_);
422
+ if (fullChat != null) {
423
+ return fullChat;
424
+ }
425
+ if (inputPeer instanceof types.InputPeerUser) {
426
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.users.getFullUser({ id: new types.InputUser(inputPeer) }).then((v) => v.full_user);
427
+ }
428
+ else if (inputPeer instanceof types.InputPeerChat) {
429
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.messages.getFullChat(inputPeer).then((v) => v.full_chat);
430
+ }
431
+ else if (inputPeer instanceof types.InputPeerChannel) {
432
+ fullChat = await __classPrivateFieldGet(this, _ChatListManager_c, "f").api.channels.getFullChannel({ channel: new types.InputChannel(inputPeer) }).then((v) => v.full_chat);
433
+ }
434
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setFullChat(chatId_, fullChat);
435
+ if (fullChat != null && "call" in fullChat && fullChat.call) {
436
+ await __classPrivateFieldGet(this, _ChatListManager_c, "f").storage.setGroupCallAccessHash(fullChat.call.id, fullChat.call.access_hash);
461
437
  }
438
+ return fullChat;
462
439
  };
@@ -67,6 +67,7 @@ export class InlineQueryManager {
67
67
  }
68
68
  }
69
69
  async sendInlineQuery(userId, chatId, params) {
70
+ await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").storage.assertUser("sendInlineQuery");
70
71
  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 ?? "";
71
72
  const botId = peerToChatId(bot), peerId = peerToChatId(peer);
72
73
  const maybeResults = await __classPrivateFieldGet(this, _InlineQueryManager_c, "f").messageStorage.getInlineQueryAnswer(botId, peerId, query, offset);
@@ -21,9 +21,9 @@ import { MaybePromise } from "../1_utilities.js";
21
21
  import { enums, functions, types } from "../2_tl.js";
22
22
  import { Storage } from "../3_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";
26
+ import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, 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, StartVideoChatParams, StopPollParams } from "./0_params.js";
27
27
  import { Api } from "./0_types.js";
28
28
  import { ClientPlainParams } from "./1_client_plain.js";
29
29
  import { Composer as Composer_, NextFunction } from "./1_composer.js";
@@ -706,7 +706,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
706
706
  *
707
707
  * @method ch
708
708
  */
709
- getChats(params?: GetChatsParams): Promise<Chat[]>;
709
+ getChats(params?: GetChatsParams): Promise<ChatListItem[]>;
710
710
  /**
711
711
  * Get a chat.
712
712
  *
@@ -1087,5 +1087,69 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
1087
1087
  * @param userId The identifier of the user to unblock.
1088
1088
  */
1089
1089
  unblockUser(userId: ID): Promise<void>;
1090
+ /**
1091
+ * Start a video chat. User-only.
1092
+ *
1093
+ * @method vc
1094
+ * @param chatId The chat to start the video chat in.
1095
+ * @returns The started video chat.
1096
+ */
1097
+ startVideoChat(chatId: ID, params?: StartVideoChatParams): Promise<VideoChatActive>;
1098
+ /**
1099
+ * Schedule a video chat. User-only.
1100
+ *
1101
+ * @method vc
1102
+ * @param chatId The chat to schedule the video chat in.
1103
+ * @param startAt A point in time within the future in which the video chat will be started.
1104
+ * @returns The scheduled video chat.
1105
+ */
1106
+ scheduleVideoChat(chatId: ID, startAt: Date, params?: ScheduleVideoChatParams): Promise<VideoChatScheduled>;
1107
+ /**
1108
+ * Join a video chat. User-only.
1109
+ *
1110
+ * @method vc
1111
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1112
+ * @param params_ WebRTC connection parameters.
1113
+ * @returns Parameters to be passed to the used WebRTC library.
1114
+ */
1115
+ joinVideoChat(id: string, params_: string, params?: JoinVideoChatParams): Promise<string>;
1116
+ /**
1117
+ * Leave a video chat. User-only.
1118
+ *
1119
+ * @method vc
1120
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1121
+ */
1122
+ leaveVideoChat(id: string): Promise<void>;
1123
+ /**
1124
+ * Join a live stream. User-only.
1125
+ *
1126
+ * @method vc
1127
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1128
+ */
1129
+ joinLiveStream(id: string): Promise<void>;
1130
+ /**
1131
+ * Get a video chat. User-only.
1132
+ *
1133
+ * @method vc
1134
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1135
+ */
1136
+ getVideoChat(id: string): Promise<VideoChat>;
1137
+ /**
1138
+ * Get live stream channels. User-only.
1139
+ *
1140
+ * @method vc
1141
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1142
+ */
1143
+ getLiveStreamChannels(id: string): Promise<LiveStreamChannel[]>;
1144
+ /**
1145
+ * Download a live stream chunk. User-only.
1146
+ *
1147
+ * @method vc
1148
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
1149
+ * @param channelId Stream channel ID.
1150
+ * @param scale Stream channel scale.
1151
+ * @param timestamp Millisecond timestamp of the chunk to download.
1152
+ */
1153
+ downloadLiveStreamChunk(id: string, channelId: number, scale: number, timestamp: number, params?: DownloadLiveStreamChunkParams): AsyncGenerator<Uint8Array, void, unknown>;
1090
1154
  }
1091
1155
  export {};
@@ -28,7 +28,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
28
28
  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");
29
29
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
30
  };
31
- var _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
31
+ var _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_videoChatManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
32
32
  import { unreachable } from "../0_deps.js";
33
33
  import { AccessError, InputError } from "../0_errors.js";
34
34
  import { cleanObject, drop, getLogger, getRandomId, minute, mustPrompt, mustPromptOneOf, second, ZERO_CHANNEL_ID } from "../1_utilities.js";
@@ -54,6 +54,7 @@ import { CallbackQueryManager } from "./3_callback_query_manager.js";
54
54
  import { ChatListManager } from "./3_chat_list_manager.js";
55
55
  import { InlineQueryManager } from "./3_inline_query_manager.js";
56
56
  import { StoryManager } from "./3_story_manager.js";
57
+ import { VideoChatManager } from "./2_video_chat_manager.js";
57
58
  export class Composer extends Composer_ {
58
59
  }
59
60
  function skipInvoke() {
@@ -98,6 +99,7 @@ export class Client extends Composer {
98
99
  _Client_botInfoManager.set(this, void 0);
99
100
  _Client_fileManager.set(this, void 0);
100
101
  _Client_reactionManager.set(this, void 0);
102
+ _Client_videoChatManager.set(this, void 0);
101
103
  _Client_businessConnectionManager.set(this, void 0);
102
104
  _Client_messageManager.set(this, void 0);
103
105
  _Client_storyManager.set(this, void 0);
@@ -697,6 +699,7 @@ export class Client extends Composer {
697
699
  __classPrivateFieldSet(this, _Client_fileManager, new FileManager(c), "f");
698
700
  __classPrivateFieldSet(this, _Client_reactionManager, new ReactionManager(c), "f");
699
701
  __classPrivateFieldSet(this, _Client_businessConnectionManager, new BusinessConnectionManager(c), "f");
702
+ __classPrivateFieldSet(this, _Client_videoChatManager, new VideoChatManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
700
703
  __classPrivateFieldSet(this, _Client_messageManager, new MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
701
704
  __classPrivateFieldSet(this, _Client_callbackQueryManager, new CallbackQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
702
705
  __classPrivateFieldSet(this, _Client_storyManager, new StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
@@ -811,7 +814,7 @@ export class Client extends Composer {
811
814
  }
812
815
  await this.connect();
813
816
  }
814
- async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
817
+ async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
815
818
  const apiId = this.apiId || await this.storage.getApiId();
816
819
  if (!apiId) {
817
820
  throw new Error("apiId not set");
@@ -1103,7 +1106,7 @@ export class Client extends Composer {
1103
1106
  return new types.InputPeerSelf();
1104
1107
  }
1105
1108
  const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
1106
- if ((inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1109
+ if (((inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1107
1110
  if ("channel_id" in inputPeer) {
1108
1111
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
1109
1112
  }
@@ -2290,6 +2293,89 @@ export class Client extends Composer {
2290
2293
  async unblockUser(userId) {
2291
2294
  await __classPrivateFieldGet(this, _Client_messageManager, "f").unblockUser(userId);
2292
2295
  }
2296
+ //
2297
+ // ========================= VIDEO CHATS ========================= //
2298
+ //
2299
+ /**
2300
+ * Start a video chat. User-only.
2301
+ *
2302
+ * @method vc
2303
+ * @param chatId The chat to start the video chat in.
2304
+ * @returns The started video chat.
2305
+ */
2306
+ async startVideoChat(chatId, params) {
2307
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").startVideoChat(chatId, params);
2308
+ }
2309
+ /**
2310
+ * Schedule a video chat. User-only.
2311
+ *
2312
+ * @method vc
2313
+ * @param chatId The chat to schedule the video chat in.
2314
+ * @param startAt A point in time within the future in which the video chat will be started.
2315
+ * @returns The scheduled video chat.
2316
+ */
2317
+ async scheduleVideoChat(chatId, startAt, params) {
2318
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").scheduleVideoChat(chatId, startAt, params);
2319
+ }
2320
+ /**
2321
+ * Join a video chat. User-only.
2322
+ *
2323
+ * @method vc
2324
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2325
+ * @param params_ WebRTC connection parameters.
2326
+ * @returns Parameters to be passed to the used WebRTC library.
2327
+ */
2328
+ async joinVideoChat(id, params_, params) {
2329
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinVideoChat(id, params_, params);
2330
+ }
2331
+ /**
2332
+ * Leave a video chat. User-only.
2333
+ *
2334
+ * @method vc
2335
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2336
+ */
2337
+ async leaveVideoChat(id) {
2338
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").leaveVideoChat(id);
2339
+ }
2340
+ /**
2341
+ * Join a live stream. User-only.
2342
+ *
2343
+ * @method vc
2344
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2345
+ */
2346
+ async joinLiveStream(id) {
2347
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinLiveStream(id);
2348
+ }
2349
+ /**
2350
+ * Get a video chat. User-only.
2351
+ *
2352
+ * @method vc
2353
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2354
+ */
2355
+ async getVideoChat(id) {
2356
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getVideoChat(id);
2357
+ }
2358
+ /**
2359
+ * Get live stream channels. User-only.
2360
+ *
2361
+ * @method vc
2362
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2363
+ */
2364
+ async getLiveStreamChannels(id) {
2365
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getLiveStreamChannels(id);
2366
+ }
2367
+ /**
2368
+ * Download a live stream chunk. User-only.
2369
+ *
2370
+ * @method vc
2371
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2372
+ * @param channelId Stream channel ID.
2373
+ * @param scale Stream channel scale.
2374
+ * @param timestamp Millisecond timestamp of the chunk to download.
2375
+ */
2376
+ async *downloadLiveStreamChunk(id, channelId, scale, timestamp, params) {
2377
+ yield* __classPrivateFieldGet(this, _Client_videoChatManager, "f").downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
2378
+ }
2293
2379
  }
2294
2380
  _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
2295
2381
  await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
@@ -2328,6 +2414,9 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
2328
2414
  })());
2329
2415
  }
2330
2416
  }
2417
+ if (VideoChatManager.canHandleUpdate(update)) {
2418
+ promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update)));
2419
+ }
2331
2420
  if (CallbackQueryManager.canHandleUpdate(update)) {
2332
2421
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update)));
2333
2422
  }
@@ -64,6 +64,12 @@ export declare const K: {
64
64
  inlineQueryAnswer: (userId: number, chatId: number, query: string, offset: string) => StorageKeyPart[];
65
65
  callbackQueryAnswers: () => StorageKeyPart[];
66
66
  callbackQueryAnswer: (chatId: number, messageId: number, question: string) => StorageKeyPart[];
67
+ fullChats: () => StorageKeyPart[];
68
+ fullChat: (chatId: number) => StorageKeyPart[];
69
+ groupCalls: () => StorageKeyPart[];
70
+ groupCall: (id: bigint) => StorageKeyPart[];
71
+ groupCallAccessHashes: () => StorageKeyPart[];
72
+ groupCallAccessHash: (id: bigint) => StorageKeyPart[];
67
73
  };
68
74
  messages: {
69
75
  P: (string: string) => string;
@@ -157,6 +163,12 @@ export declare abstract class Storage {
157
163
  getInlineQueryAnswer(userId: number, chatId: number, query: string, offset: string): Promise<[types.messages.BotResults, Date] | null>;
158
164
  setCallbackQueryAnswer(chatId: number, messageId: number, question: string, answer: types.messages.BotCallbackAnswer): Promise<void>;
159
165
  getCallbackQueryAnswer(chatId: number, messageId: number, question: string): Promise<[types.messages.BotCallbackAnswer, Date] | null>;
166
+ setFullChat(chatId: number, fullChat: types.UserFull | types.ChannelFull | types.ChatFull | null): Promise<void>;
167
+ getFullChat(chatId: number): Promise<types.UserFull | types.ChannelFull | types.ChatFull | null>;
168
+ setGroupCall(id: bigint, groupCall: types.GroupCall | null): Promise<void>;
169
+ getGroupCall(id: bigint): Promise<types.GroupCall | null>;
170
+ setGroupCallAccessHash(id: bigint, accessHash: bigint | null): Promise<void>;
171
+ getGroupCallAccessHash(id: bigint): Promise<bigint | null>;
160
172
  setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
161
173
  deleteUpdates(): Promise<void>;
162
174
  getFirstUpdate(boxId: bigint): Promise<[readonly StorageKeyPart[], enums.Update] | null>;
@@ -167,6 +179,8 @@ export declare abstract class Storage {
167
179
  deleteBusinessConnections(): Promise<void>;
168
180
  deleteInlineQueryAnswers(): Promise<void>;
169
181
  deleteCallbackQueryAnswers(): Promise<void>;
182
+ deleteFullChats(): Promise<void>;
183
+ deleteGroupCalls(): Promise<void>;
170
184
  deleteStickerSetNames(): Promise<void>;
171
185
  deletePeers(): Promise<void>;
172
186
  deleteUsernames(): Promise<void>;