@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.
- package/esm/3_types.d.ts +6 -1
- package/esm/3_types.js +6 -1
- package/esm/4_errors.js +2 -4
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_params.d.ts +33 -7
- package/esm/client/0_storage_operations.d.ts +182 -0
- package/esm/client/0_storage_operations.js +611 -0
- package/esm/client/1_composer.d.ts +2 -0
- package/esm/client/1_composer.js +28 -0
- package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
- package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
- package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
- package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
- package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
- package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
- package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
- package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/esm/client/3_video_chat_manager.d.ts +43 -0
- package/esm/client/3_video_chat_manager.js +194 -0
- package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
- package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
- package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
- package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
- package/esm/client/{4_client.js → 5_client.js} +172 -73
- package/esm/connection/0_connection.d.ts +6 -15
- package/esm/connection/0_connection.js +1 -38
- package/esm/connection/1_connection_web_socket.d.ts +3 -2
- package/esm/connection/1_connection_web_socket.js +7 -3
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.d.ts +9 -145
- package/esm/storage/0_storage.js +1 -526
- package/esm/storage/2_storage_indexed_db.d.ts +3 -2
- package/esm/storage/2_storage_indexed_db.js +9 -8
- package/esm/storage/2_storage_local_storage.d.ts +3 -2
- package/esm/storage/2_storage_local_storage.js +5 -4
- package/esm/storage/2_storage_memory.d.ts +4 -4
- package/esm/storage/2_storage_memory.js +12 -19
- package/esm/storage/2_storage_session_storage.d.ts +2 -1
- package/esm/storage/2_storage_session_storage.js +5 -4
- package/esm/tl/3_utilities.d.ts +1 -1
- package/esm/tl/3_utilities.js +3 -3
- package/esm/types/0_birthday.d.ts +27 -0
- package/esm/types/0_birthday.js +26 -0
- package/esm/types/0_giveaway_parameters.d.ts +1 -1
- package/esm/types/0_id.d.ts +1 -1
- package/esm/types/0_live_stream_channel.d.ts +30 -0
- package/esm/types/0_live_stream_channel.js +26 -0
- package/esm/types/0_opening_hours.d.ts +25 -0
- package/esm/types/0_opening_hours.js +25 -0
- package/esm/types/0_video_chat.d.ts +60 -0
- package/esm/types/0_video_chat.js +53 -0
- package/esm/types/1_chat_p.d.ts +4 -0
- package/esm/types/1_chat_p.js +1 -0
- package/esm/types/2_business_connection.d.ts +6 -0
- package/esm/types/2_chat.d.ts +62 -0
- package/esm/types/2_chat.js +66 -0
- package/esm/types/2_inactive_chat.d.ts +1 -1
- package/esm/types/2_invite_link.d.ts +1 -1
- package/esm/types/2_message_reaction_count.d.ts +1 -1
- package/esm/types/2_message_reactions.d.ts +1 -1
- package/esm/types/3_chat_member_updated.d.ts +1 -1
- package/esm/types/4_message.d.ts +3 -3
- package/esm/types/5_chat_list_item.d.ts +35 -0
- package/esm/types/5_chat_list_item.js +86 -0
- package/esm/types/6_update.d.ts +14 -5
- package/esm/types/_file_id.d.ts +1 -0
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +7 -3
- package/package.json +1 -1
- package/script/3_types.d.ts +6 -1
- package/script/3_types.js +6 -1
- package/script/4_errors.js +2 -4
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_params.d.ts +33 -7
- package/script/client/0_storage_operations.d.ts +182 -0
- package/script/client/0_storage_operations.js +615 -0
- package/script/client/1_composer.d.ts +2 -0
- package/script/client/1_composer.js +28 -0
- package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
- package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
- package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
- package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
- package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
- package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
- package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
- package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/script/client/3_video_chat_manager.d.ts +43 -0
- package/script/client/3_video_chat_manager.js +198 -0
- package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
- package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
- package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
- package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
- package/script/client/{4_client.js → 5_client.js} +192 -93
- package/script/connection/0_connection.d.ts +6 -15
- package/script/connection/0_connection.js +0 -41
- package/script/connection/1_connection_web_socket.d.ts +3 -2
- package/script/connection/1_connection_web_socket.js +7 -3
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/storage/0_storage.d.ts +9 -145
- package/script/storage/0_storage.js +0 -528
- package/script/storage/2_storage_indexed_db.d.ts +3 -2
- package/script/storage/2_storage_indexed_db.js +9 -8
- package/script/storage/2_storage_local_storage.d.ts +3 -2
- package/script/storage/2_storage_local_storage.js +5 -4
- package/script/storage/2_storage_memory.d.ts +4 -4
- package/script/storage/2_storage_memory.js +12 -19
- package/script/storage/2_storage_session_storage.d.ts +2 -1
- package/script/storage/2_storage_session_storage.js +5 -4
- package/script/tl/3_utilities.d.ts +1 -1
- package/script/tl/3_utilities.js +3 -3
- package/script/types/0_birthday.d.ts +27 -0
- package/script/types/0_birthday.js +30 -0
- package/script/types/0_giveaway_parameters.d.ts +1 -1
- package/script/types/0_id.d.ts +1 -1
- package/script/types/0_live_stream_channel.d.ts +30 -0
- package/script/types/0_live_stream_channel.js +30 -0
- package/script/types/0_opening_hours.d.ts +25 -0
- package/script/types/0_opening_hours.js +29 -0
- package/script/types/0_video_chat.d.ts +60 -0
- package/script/types/0_video_chat.js +57 -0
- package/script/types/1_chat_p.d.ts +4 -0
- package/script/types/1_chat_p.js +1 -0
- package/script/types/2_business_connection.d.ts +6 -0
- package/script/types/2_chat.d.ts +62 -0
- package/script/types/2_chat.js +70 -0
- package/script/types/2_inactive_chat.d.ts +1 -1
- package/script/types/2_invite_link.d.ts +1 -1
- package/script/types/2_message_reaction_count.d.ts +1 -1
- package/script/types/2_message_reactions.d.ts +1 -1
- package/script/types/3_chat_member_updated.d.ts +1 -1
- package/script/types/4_message.d.ts +3 -3
- package/script/types/5_chat_list_item.d.ts +35 -0
- package/script/types/5_chat_list_item.js +94 -0
- package/script/types/6_update.d.ts +14 -5
- package/script/types/_file_id.d.ts +1 -0
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +7 -3
- package/esm/types/5_chat.d.ts +0 -59
- package/esm/types/5_chat.js +0 -126
- package/script/types/5_chat.d.ts +0 -59
- package/script/types/5_chat.js +0 -134
- /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/esm/{3_storage.js → 2_storage.js} +0 -0
- /package/esm/client/{0_types.js → 1_types.js} +0 -0
- /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
- /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/script/{3_storage.js → 2_storage.js} +0 -0
- /package/script/client/{0_types.js → 1_types.js} +0 -0
- /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
|
@@ -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 {
|
|
36
|
-
import { constructChat,
|
|
37
|
-
import { getChatListId
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
253
|
-
|
|
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
|
|
260
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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
|
};
|
|
@@ -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 "./
|
|
24
|
-
import { MessageManager } from "./
|
|
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
|
};
|
|
@@ -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 { 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 "./
|
|
25
|
-
import { FileManager } from "./
|
|
26
|
-
import { MessageManager } from "./
|
|
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 "../
|
|
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,
|
|
27
|
-
import { Api } from "./
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
212
|
-
|
|
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
|
|
220
|
-
readonly
|
|
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(
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
279
|
+
signIn(params?: SignInParams): Promise<void>;
|
|
280
|
+
signOut(): Promise<void>;
|
|
271
281
|
/**
|
|
272
|
-
* Same as calling `.connect()` followed by `.
|
|
282
|
+
* Same as calling `.connect()` followed by `.signIn(params)`.
|
|
273
283
|
*/
|
|
274
|
-
start(params?:
|
|
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<
|
|
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 {};
|