@mtkruto/node 0.1.152 → 0.1.153

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 CHANGED
@@ -18,6 +18,7 @@ export * from "./types/0_login_url.js";
18
18
  export * from "./types/0_mask_position.js";
19
19
  export * from "./types/0_message_entity.js";
20
20
  export * from "./types/0_message_reference.js";
21
+ export * from "./types/0_message_search_filter.js";
21
22
  export * from "./types/0_mini_app_info.js";
22
23
  export * from "./types/0_network_statistics_entry.js";
23
24
  export * from "./types/0_parse_mode.js";
@@ -56,6 +57,7 @@ export * from "./types/1_video.js";
56
57
  export * from "./types/2_chat_member.js";
57
58
  export * from "./types/2_chosen_inline_result.js";
58
59
  export * from "./types/2_game.js";
60
+ export * from "./types/2_inactive_chat.js";
59
61
  export * from "./types/2_inline_keyboard_button.js";
60
62
  export * from "./types/2_inline_query.js";
61
63
  export * from "./types/2_invite_link.js";
package/esm/3_types.js CHANGED
@@ -18,6 +18,7 @@ export * from "./types/0_login_url.js";
18
18
  export * from "./types/0_mask_position.js";
19
19
  export * from "./types/0_message_entity.js";
20
20
  export * from "./types/0_message_reference.js";
21
+ export * from "./types/0_message_search_filter.js";
21
22
  export * from "./types/0_mini_app_info.js";
22
23
  export * from "./types/0_network_statistics_entry.js";
23
24
  export * from "./types/0_parse_mode.js";
@@ -56,6 +57,7 @@ export * from "./types/1_video.js";
56
57
  export * from "./types/2_chat_member.js";
57
58
  export * from "./types/2_chosen_inline_result.js";
58
59
  export * from "./types/2_game.js";
60
+ export * from "./types/2_inactive_chat.js";
59
61
  export * from "./types/2_inline_keyboard_button.js";
60
62
  export * from "./types/2_inline_query.js";
61
63
  export * from "./types/2_invite_link.js";
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
6
  export declare const LAYER = 173;
7
- export declare const APP_VERSION = "MTKruto 0.1.152";
7
+ export declare const APP_VERSION = "MTKruto 0.1.153";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -53,7 +53,7 @@ export const PUBLIC_KEYS = Object.freeze([
53
53
  ]);
54
54
  export const INITIAL_DC = "2";
55
55
  export const LAYER = 173;
56
- export const APP_VERSION = "MTKruto 0.1.152";
56
+ export const APP_VERSION = "MTKruto 0.1.153";
57
57
  // @ts-ignore: lib
58
58
  export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
59
59
  export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -1,6 +1,5 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
- import { BotCommandScope, Chat, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, ParseMode, ReplyMarkup, ReplyQuote, StoryInteractiveArea } from "../3_types.js";
3
- import { StoryPrivacy } from "../types/1_story_privacy.js";
2
+ import { BotCommandScope, Chat, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, MessageSearchFilter, ParseMode, ReplyMarkup, ReplyQuote, StoryInteractiveArea, StoryPrivacy } from "../3_types.js";
4
3
  export interface AnswerCallbackQueryParams {
5
4
  /** A text to be shown to the user. */
6
5
  text?: string;
@@ -269,3 +268,10 @@ export interface CreateStoryParams extends _CaptionCommon, _UploadCommon {
269
268
  highlight?: boolean;
270
269
  protectContent?: boolean;
271
270
  }
271
+ export interface SearchMessagesParams {
272
+ from?: ID;
273
+ filter?: MessageSearchFilter;
274
+ after?: number;
275
+ messageThreadId?: number;
276
+ limit?: number;
277
+ }
@@ -0,0 +1,11 @@
1
+ import { ID } from "../3_types.js";
2
+ import { C } from "./0_types.js";
3
+ export declare class AccountManager {
4
+ #private;
5
+ constructor(c: C);
6
+ showUsername(id: ID, username: string): Promise<void>;
7
+ hideUsername(id: ID, username: string): Promise<void>;
8
+ reorderUsernames(id: ID, order: string[]): Promise<boolean>;
9
+ hideUsernames(id: ID): Promise<boolean>;
10
+ getInactiveChats(): Promise<import("../3_types.js").InactiveChat[]>;
11
+ }
@@ -0,0 +1,76 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _AccountManager_instances, _AccountManager_c, _AccountManager_toggleUsername;
13
+ import { UNREACHABLE } from "../1_utilities.js";
14
+ import { types } from "../2_tl.js";
15
+ import { constructInactiveChat } from "../3_types.js";
16
+ export class AccountManager {
17
+ constructor(c) {
18
+ _AccountManager_instances.add(this);
19
+ _AccountManager_c.set(this, void 0);
20
+ __classPrivateFieldSet(this, _AccountManager_c, c, "f");
21
+ }
22
+ async showUsername(id, username) {
23
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("showUsername");
24
+ await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, true);
25
+ }
26
+ async hideUsername(id, username) {
27
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsername");
28
+ await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, false);
29
+ }
30
+ async reorderUsernames(id, order) {
31
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("reorderUsernames");
32
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
33
+ if (peer instanceof types.InputPeerSelf) {
34
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.account.reorderUsernames({ order });
35
+ }
36
+ else if (peer instanceof types.InputPeerUser) {
37
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.bots.reorderUsernames({ bot: new types.InputUser(peer), order });
38
+ }
39
+ else if (peer instanceof types.InputPeerChannel) {
40
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.reorderUsernames({ channel: new types.InputChannel(peer), order });
41
+ }
42
+ else {
43
+ UNREACHABLE();
44
+ }
45
+ }
46
+ async hideUsernames(id) {
47
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsernames");
48
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
49
+ if (peer instanceof types.InputPeerChannel) {
50
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.deactivateAllUsernames({ channel: new types.InputChannel(peer) });
51
+ }
52
+ else {
53
+ UNREACHABLE();
54
+ }
55
+ }
56
+ async getInactiveChats() {
57
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("getInactiveChats");
58
+ const { chats, dates } = await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.getInactiveChannels();
59
+ return chats.map((v, i) => constructInactiveChat(v, dates[i]));
60
+ }
61
+ }
62
+ _AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _AccountManager_toggleUsername = async function _AccountManager_toggleUsername(id, username, active) {
63
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
64
+ if (peer instanceof types.InputPeerSelf) {
65
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.account.toggleUsername({ username, active });
66
+ }
67
+ else if (peer instanceof types.InputPeerUser) {
68
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.bots.toggleUsername({ bot: new types.InputUser(peer), username, active });
69
+ }
70
+ else if (peer instanceof types.InputPeerChannel) {
71
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.toggleUsername({ channel: new types.InputChannel(peer), username, active });
72
+ }
73
+ else {
74
+ UNREACHABLE();
75
+ }
76
+ };
@@ -1,6 +1,7 @@
1
1
  import { enums, types } from "../2_tl.js";
2
2
  import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
3
3
  import { BanChatMemberParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetHistoryParams, PinMessageParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams } from "./0_params.js";
4
+ import { SearchMessagesParams } from "./0_params.js";
4
5
  import { AddReactionParams, SetReactionsParams } from "./0_params.js";
5
6
  import { C as C_ } from "./0_types.js";
6
7
  import { FileManager } from "./1_file_manager.js";
@@ -98,5 +99,6 @@ export declare class MessageManager {
98
99
  getChatAdministrators(chatId: ID): Promise<ChatMember[]>;
99
100
  enableJoinRequests(chatId: ID): Promise<void>;
100
101
  disableJoinRequests(chatId: ID): Promise<void>;
102
+ searchMessages(chatId: ID, query: string, params?: SearchMessagesParams): Promise<Message[]>;
101
103
  }
102
104
  export {};
@@ -16,6 +16,7 @@ import { as, getChannelChatId, peerToChatId, types } from "../2_tl.js";
16
16
  import { constructChatMemberUpdated } from "../3_types.js";
17
17
  import { assertMessageType, chatMemberRightsToTlObject, constructChatMember, constructMessage as constructMessage_, deserializeInlineMessageId, FileID, FileType, messageEntityToTlObject, reactionEqual, reactionToTlObject, replyMarkupToTlObject } from "../3_types.js";
18
18
  import { STICKER_SET_NAME_TTL } from "../4_constants.js";
19
+ import { messageSearchFilterToTlObject } from "../types/0_message_search_filter.js";
19
20
  import { parseHtml } from "./0_html.js";
20
21
  import { getFileContents, isHttpUrl } from "./0_utilities.js";
21
22
  const d = debug("MessageManager");
@@ -135,6 +136,7 @@ export class MessageManager {
135
136
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, to, result);
136
137
  }
137
138
  async getHistory(chatId, params) {
139
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
138
140
  let limit = params?.limit ?? 100;
139
141
  if (limit <= 0) {
140
142
  limit = 1;
@@ -859,11 +861,38 @@ export class MessageManager {
859
861
  }
860
862
  }
861
863
  async enableJoinRequests(chatId) {
864
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("enableJoinRequests");
862
865
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, true);
863
866
  }
864
867
  async disableJoinRequests(chatId) {
868
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("disableJoinRequests");
865
869
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, false);
866
870
  }
871
+ async searchMessages(chatId, query, params) {
872
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.search({
873
+ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
874
+ q: query,
875
+ add_offset: 0,
876
+ filter: messageSearchFilterToTlObject(params?.filter ?? "empty"),
877
+ hash: 0n,
878
+ limit: params?.limit ?? 100,
879
+ max_date: 0,
880
+ max_id: 0,
881
+ min_date: 0,
882
+ min_id: 0,
883
+ offset_id: params?.after ? params.after : 0,
884
+ from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined,
885
+ });
886
+ if (!("messages" in result)) {
887
+ UNREACHABLE();
888
+ }
889
+ const messages = new Array();
890
+ for (const message_ of result.messages) {
891
+ const message = await this.constructMessage(message_, false);
892
+ messages.push(message);
893
+ }
894
+ return messages;
895
+ }
867
896
  }
868
897
  _MessageManager_c = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {
869
898
  const messages = new Array();
@@ -22,6 +22,7 @@ export class StoryManager {
22
22
  __classPrivateFieldSet(this, _StoryManager_c, c, "f");
23
23
  }
24
24
  async createStory(chatId, content, params) {
25
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("createStory");
25
26
  let media = null;
26
27
  const source = "video" in content ? content.video : "photo" in content ? content.photo : UNREACHABLE();
27
28
  if (typeof source === "string") {
@@ -81,6 +82,7 @@ export class StoryManager {
81
82
  return await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_updatesToStory).call(this, updates);
82
83
  }
83
84
  async getStories(chatId, storyIds) {
85
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("getStories");
84
86
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
85
87
  const stories_ = await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.getStoriesByID({ peer, id: storyIds });
86
88
  const stories = new Array();
@@ -90,25 +92,32 @@ export class StoryManager {
90
92
  return stories;
91
93
  }
92
94
  async getStory(chatId, storyId) {
95
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("getStory");
93
96
  return await this.getStories(chatId, [storyId]).then((v) => v[0] ?? null);
94
97
  }
95
98
  async deleteStories(chatId, storyIds) {
99
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("deleteStories");
96
100
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
97
101
  await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.deleteStories({ peer, id: storyIds });
98
102
  }
99
103
  async deleteStory(chatId, storyId) {
104
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("deleteStory");
100
105
  await this.deleteStories(chatId, [storyId]);
101
106
  }
102
107
  async addStoriesToHighlights(chatId, storyIds) {
108
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("addStoriesToHighlights");
103
109
  await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_togglePinned).call(this, chatId, storyIds, true);
104
110
  }
105
111
  async addStoryToHighlights(chatId, storyId) {
112
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("addStoryToHighlights");
106
113
  await this.addStoriesToHighlights(chatId, [storyId]);
107
114
  }
108
115
  async removeStoriesFromHighlights(chatId, storyIds) {
116
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("removeStoriesFromHighlights");
109
117
  await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_togglePinned).call(this, chatId, storyIds, false);
110
118
  }
111
119
  async removeStoryFromHighlights(chatId, storyId) {
120
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("removeStoryFromHighlights");
112
121
  await this.removeStoriesFromHighlights(chatId, [storyId]);
113
122
  }
114
123
  static canHandleUpdate(update) {
@@ -2,11 +2,12 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { functions, types } from "../2_tl.js";
3
3
  import { Storage } from "../3_storage.js";
4
4
  import { DC } from "../3_transport.js";
5
+ import { InactiveChat } from "../3_types.js";
5
6
  import { BotCommand, Chat, ChatAction, ChatMember, ChatP, Document, FileSource, ID, InlineQueryResult, InputStoryContent, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Reaction, Story, Update, UpdateIntersection, User } from "../3_types.js";
6
7
  import { Migrate } from "../4_errors.js";
7
8
  import { ClientAbstract } from "./0_client_abstract.js";
8
9
  import { FilterQuery, WithFilter } from "./0_filters.js";
9
- import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, UploadParams } from "./0_params.js";
10
+ import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, UploadParams } from "./0_params.js";
10
11
  import { Api } from "./0_types.js";
11
12
  import { Composer, Middleware } from "./1_composer.js";
12
13
  import { ClientPlainParams } from "./2_client_plain.js";
@@ -816,5 +817,50 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
816
817
  * @param chatId The identifier of the chat. Must be a channel or a supergroup.
817
818
  */
818
819
  disableJoinRequests(chatId: ID): Promise<void>;
820
+ /**
821
+ * Show a username in the current account, a bot account, sa upergroup, or a channel's profile. User-only.
822
+ *
823
+ * @method ac
824
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
825
+ * @param username The username to show.
826
+ */
827
+ showUsername(id: ID, username: string): Promise<void>;
828
+ /**
829
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
830
+ *
831
+ * @method ac
832
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
833
+ * @param username The username to hide.
834
+ */
835
+ hideUsername(id: ID, username: string): Promise<void>;
836
+ /**
837
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
838
+ *
839
+ * @method ac
840
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
841
+ * @param order The new order to use.
842
+ */
843
+ reorderUsernames(id: ID, order: string[]): Promise<boolean>;
844
+ /**
845
+ * Hide all usernames from the a supergroup or a channel's profile. User-only.
846
+ *
847
+ * @method ac
848
+ * @param id A supergroup ID or a channel ID.
849
+ */
850
+ hideUsernames(id: ID): Promise<boolean>;
851
+ /**
852
+ * Get inactive chats. User-only.
853
+ *
854
+ * @method ch
855
+ */
856
+ getInactiveChats(): Promise<InactiveChat[]>;
857
+ /**
858
+ * Search the messages of a chat.
859
+ *
860
+ * @method ms
861
+ * @param chatId The identifier of the chat to search the messages in.
862
+ * @param query The message search query.
863
+ */
864
+ searchMessages(chatId: ID, query: string, params?: SearchMessagesParams): Promise<Message[]>;
819
865
  }
820
866
  export {};
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  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");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_storeMessages, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_handle;
12
+ var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_storeMessages, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_handle;
13
13
  import { debug, gunzip, Mutex } from "../0_deps.js";
14
14
  import { bigIntFromBuffer, cleanObject, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
15
15
  import { as, chatIdToPeerId, functions, getChatIdPeerType, Message_, MessageContainer, name, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
@@ -23,6 +23,7 @@ import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
23
23
  import { checkPassword } from "./0_password.js";
24
24
  import { ConnectionError } from "./0_types.js";
25
25
  import { getUsername, resolve } from "./0_utilities.js";
26
+ import { AccountManager } from "./1_account_manager.js";
26
27
  import { BotInfoManager } from "./1_bot_info_manager.js";
27
28
  import { Composer, concat, flatten, skip } from "./1_composer.js";
28
29
  import { FileManager } from "./1_file_manager.js";
@@ -84,6 +85,7 @@ export class Client extends ClientAbstract {
84
85
  _Client_callbackQueryManager.set(this, void 0);
85
86
  _Client_inlineQueryManager.set(this, void 0);
86
87
  _Client_chatListManager.set(this, void 0);
88
+ _Client_accountManager.set(this, void 0);
87
89
  Object.defineProperty(this, "storage", {
88
90
  enumerable: true,
89
91
  configurable: true,
@@ -616,6 +618,7 @@ export class Client extends ClientAbstract {
616
618
  __classPrivateFieldSet(this, _Client_storyManager, new StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
617
619
  __classPrivateFieldSet(this, _Client_inlineQueryManager, new InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
618
620
  __classPrivateFieldSet(this, _Client_chatListManager, new ChatListManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
621
+ __classPrivateFieldSet(this, _Client_accountManager, new AccountManager(c), "f");
619
622
  __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
620
623
  const transportProvider = this.transportProvider;
621
624
  this.transportProvider = (params) => {
@@ -730,7 +733,7 @@ export class Client extends ClientAbstract {
730
733
  release();
731
734
  }
732
735
  }
733
- async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = 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_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
736
+ async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = 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_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_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
734
737
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
735
738
  __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
736
739
  }, _Client_setAuth = async function _Client_setAuth(key) {
@@ -2058,6 +2061,63 @@ export class Client extends ClientAbstract {
2058
2061
  async disableJoinRequests(chatId) {
2059
2062
  await __classPrivateFieldGet(this, _Client_messageManager, "f").disableJoinRequests(chatId);
2060
2063
  }
2064
+ /**
2065
+ * Show a username in the current account, a bot account, sa upergroup, or a channel's profile. User-only.
2066
+ *
2067
+ * @method ac
2068
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2069
+ * @param username The username to show.
2070
+ */
2071
+ async showUsername(id, username) {
2072
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
2073
+ }
2074
+ /**
2075
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
2076
+ *
2077
+ * @method ac
2078
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2079
+ * @param username The username to hide.
2080
+ */
2081
+ async hideUsername(id, username) {
2082
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
2083
+ }
2084
+ /**
2085
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
2086
+ *
2087
+ * @method ac
2088
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2089
+ * @param order The new order to use.
2090
+ */
2091
+ async reorderUsernames(id, order) {
2092
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
2093
+ }
2094
+ /**
2095
+ * Hide all usernames from the a supergroup or a channel's profile. User-only.
2096
+ *
2097
+ * @method ac
2098
+ * @param id A supergroup ID or a channel ID.
2099
+ */
2100
+ async hideUsernames(id) {
2101
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
2102
+ }
2103
+ /**
2104
+ * Get inactive chats. User-only.
2105
+ *
2106
+ * @method ch
2107
+ */
2108
+ async getInactiveChats() {
2109
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
2110
+ }
2111
+ /**
2112
+ * Search the messages of a chat.
2113
+ *
2114
+ * @method ms
2115
+ * @param chatId The identifier of the chat to search the messages in.
2116
+ * @param query The message search query.
2117
+ */
2118
+ async searchMessages(chatId, query, params) {
2119
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(chatId, query, params);
2120
+ }
2061
2121
  }
2062
2122
  _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
2063
2123
  await __classPrivateFieldGet(this, _Client_handle, "f").call(this, await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
@@ -0,0 +1,2 @@
1
+ export type MessageSearchFilter = "empty" | "animations" | "audios" | "documents" | "photos" | "videos" | "voiceMessages" | "photosAndVideos" | "links" | "chatPhotos" | "videoNotes" | "voiceMessagesAndVideoNotes" | "mentions" | "pinned";
2
+ export declare function messageSearchFilterToTlObject(filter: MessageSearchFilter): import("../tl/2_types.js").InputMessagesFilterEmpty_ | import("../tl/2_types.js").InputMessagesFilterPhotos_ | import("../tl/2_types.js").InputMessagesFilterVideo_ | import("../tl/2_types.js").InputMessagesFilterPhotoVideo_ | import("../tl/2_types.js").InputMessagesFilterDocument_ | import("../tl/2_types.js").InputMessagesFilterUrl_ | import("../tl/2_types.js").InputMessagesFilterGif_ | import("../tl/2_types.js").InputMessagesFilterVoice_ | import("../tl/2_types.js").InputMessagesFilterMusic_ | import("../tl/2_types.js").InputMessagesFilterChatPhotos_ | import("../tl/2_types.js").InputMessagesFilterRoundVoice_ | import("../tl/2_types.js").InputMessagesFilterRoundVideo_ | import("../tl/2_types.js").InputMessagesFilterMyMentions_ | import("../tl/2_types.js").InputMessagesFilterPinned_;
@@ -0,0 +1,36 @@
1
+ import { UNREACHABLE } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
+ export function messageSearchFilterToTlObject(filter) {
4
+ switch (filter) {
5
+ case "empty":
6
+ return new types.InputMessagesFilterEmpty();
7
+ case "animations":
8
+ return new types.InputMessagesFilterGif();
9
+ case "audios":
10
+ return new types.InputMessagesFilterMusic();
11
+ case "documents":
12
+ return new types.InputMessagesFilterDocument();
13
+ case "photos":
14
+ return new types.InputMessagesFilterPhotos();
15
+ case "videos":
16
+ return new types.InputMessagesFilterVideo();
17
+ case "voiceMessages":
18
+ return new types.InputMessagesFilterVoice();
19
+ case "photosAndVideos":
20
+ return new types.InputMessagesFilterPhotoVideo();
21
+ case "links":
22
+ return new types.InputMessagesFilterUrl();
23
+ case "chatPhotos":
24
+ return new types.InputMessagesFilterChatPhotos();
25
+ case "videoNotes":
26
+ return new types.InputMessagesFilterRoundVideo();
27
+ case "voiceMessagesAndVideoNotes":
28
+ return new types.InputMessagesFilterRoundVoice();
29
+ case "mentions":
30
+ return new types.InputMessagesFilterMyMentions();
31
+ case "pinned":
32
+ return new types.InputMessagesFilterPinned();
33
+ default:
34
+ UNREACHABLE();
35
+ }
36
+ }
@@ -0,0 +1,7 @@
1
+ import { enums } from "../2_tl.js";
2
+ import { ChatP } from "./1_chat_p.js";
3
+ export interface InactiveChat {
4
+ lastActivity: Date;
5
+ chat: ChatP;
6
+ }
7
+ export declare function constructInactiveChat(chat_: enums.Chat, lastActivity: number): InactiveChat;
@@ -0,0 +1,13 @@
1
+ import { fromUnixTimestamp, UNREACHABLE } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
+ import { constructChatP } from "./1_chat_p.js";
4
+ export function constructInactiveChat(chat_, lastActivity) {
5
+ if (chat_ instanceof types.ChatEmpty) {
6
+ UNREACHABLE();
7
+ }
8
+ const chat = constructChatP(chat_);
9
+ return {
10
+ lastActivity: fromUnixTimestamp(lastActivity),
11
+ chat,
12
+ };
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.152",
3
+ "version": "0.1.153",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -18,6 +18,7 @@ export * from "./types/0_login_url.js";
18
18
  export * from "./types/0_mask_position.js";
19
19
  export * from "./types/0_message_entity.js";
20
20
  export * from "./types/0_message_reference.js";
21
+ export * from "./types/0_message_search_filter.js";
21
22
  export * from "./types/0_mini_app_info.js";
22
23
  export * from "./types/0_network_statistics_entry.js";
23
24
  export * from "./types/0_parse_mode.js";
@@ -56,6 +57,7 @@ export * from "./types/1_video.js";
56
57
  export * from "./types/2_chat_member.js";
57
58
  export * from "./types/2_chosen_inline_result.js";
58
59
  export * from "./types/2_game.js";
60
+ export * from "./types/2_inactive_chat.js";
59
61
  export * from "./types/2_inline_keyboard_button.js";
60
62
  export * from "./types/2_inline_query.js";
61
63
  export * from "./types/2_invite_link.js";
package/script/3_types.js CHANGED
@@ -34,6 +34,7 @@ __exportStar(require("./types/0_login_url.js"), exports);
34
34
  __exportStar(require("./types/0_mask_position.js"), exports);
35
35
  __exportStar(require("./types/0_message_entity.js"), exports);
36
36
  __exportStar(require("./types/0_message_reference.js"), exports);
37
+ __exportStar(require("./types/0_message_search_filter.js"), exports);
37
38
  __exportStar(require("./types/0_mini_app_info.js"), exports);
38
39
  __exportStar(require("./types/0_network_statistics_entry.js"), exports);
39
40
  __exportStar(require("./types/0_parse_mode.js"), exports);
@@ -72,6 +73,7 @@ __exportStar(require("./types/1_video.js"), exports);
72
73
  __exportStar(require("./types/2_chat_member.js"), exports);
73
74
  __exportStar(require("./types/2_chosen_inline_result.js"), exports);
74
75
  __exportStar(require("./types/2_game.js"), exports);
76
+ __exportStar(require("./types/2_inactive_chat.js"), exports);
75
77
  __exportStar(require("./types/2_inline_keyboard_button.js"), exports);
76
78
  __exportStar(require("./types/2_inline_query.js"), exports);
77
79
  __exportStar(require("./types/2_invite_link.js"), exports);
@@ -4,7 +4,7 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
6
  export declare const LAYER = 173;
7
- export declare const APP_VERSION = "MTKruto 0.1.152";
7
+ export declare const APP_VERSION = "MTKruto 0.1.153";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -79,7 +79,7 @@ exports.PUBLIC_KEYS = Object.freeze([
79
79
  ]);
80
80
  exports.INITIAL_DC = "2";
81
81
  exports.LAYER = 173;
82
- exports.APP_VERSION = "MTKruto 0.1.152";
82
+ exports.APP_VERSION = "MTKruto 0.1.153";
83
83
  // @ts-ignore: lib
84
84
  exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
85
85
  exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -1,6 +1,5 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
- import { BotCommandScope, Chat, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, ParseMode, ReplyMarkup, ReplyQuote, StoryInteractiveArea } from "../3_types.js";
3
- import { StoryPrivacy } from "../types/1_story_privacy.js";
2
+ import { BotCommandScope, Chat, ChatMemberRights, FileSource, ID, InlineQueryResultButton, LinkPreview, Message, MessageEntity, MessageSearchFilter, ParseMode, ReplyMarkup, ReplyQuote, StoryInteractiveArea, StoryPrivacy } from "../3_types.js";
4
3
  export interface AnswerCallbackQueryParams {
5
4
  /** A text to be shown to the user. */
6
5
  text?: string;
@@ -269,3 +268,10 @@ export interface CreateStoryParams extends _CaptionCommon, _UploadCommon {
269
268
  highlight?: boolean;
270
269
  protectContent?: boolean;
271
270
  }
271
+ export interface SearchMessagesParams {
272
+ from?: ID;
273
+ filter?: MessageSearchFilter;
274
+ after?: number;
275
+ messageThreadId?: number;
276
+ limit?: number;
277
+ }
@@ -0,0 +1,11 @@
1
+ import { ID } from "../3_types.js";
2
+ import { C } from "./0_types.js";
3
+ export declare class AccountManager {
4
+ #private;
5
+ constructor(c: C);
6
+ showUsername(id: ID, username: string): Promise<void>;
7
+ hideUsername(id: ID, username: string): Promise<void>;
8
+ reorderUsernames(id: ID, order: string[]): Promise<boolean>;
9
+ hideUsernames(id: ID): Promise<boolean>;
10
+ getInactiveChats(): Promise<import("../3_types.js").InactiveChat[]>;
11
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _AccountManager_instances, _AccountManager_c, _AccountManager_toggleUsername;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AccountManager = void 0;
16
+ const _1_utilities_js_1 = require("../1_utilities.js");
17
+ const _2_tl_js_1 = require("../2_tl.js");
18
+ const _3_types_js_1 = require("../3_types.js");
19
+ class AccountManager {
20
+ constructor(c) {
21
+ _AccountManager_instances.add(this);
22
+ _AccountManager_c.set(this, void 0);
23
+ __classPrivateFieldSet(this, _AccountManager_c, c, "f");
24
+ }
25
+ async showUsername(id, username) {
26
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("showUsername");
27
+ await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, true);
28
+ }
29
+ async hideUsername(id, username) {
30
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsername");
31
+ await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, false);
32
+ }
33
+ async reorderUsernames(id, order) {
34
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("reorderUsernames");
35
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
36
+ if (peer instanceof _2_tl_js_1.types.InputPeerSelf) {
37
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.account.reorderUsernames({ order });
38
+ }
39
+ else if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
40
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.bots.reorderUsernames({ bot: new _2_tl_js_1.types.InputUser(peer), order });
41
+ }
42
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
43
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.reorderUsernames({ channel: new _2_tl_js_1.types.InputChannel(peer), order });
44
+ }
45
+ else {
46
+ (0, _1_utilities_js_1.UNREACHABLE)();
47
+ }
48
+ }
49
+ async hideUsernames(id) {
50
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsernames");
51
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
52
+ if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
53
+ return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.deactivateAllUsernames({ channel: new _2_tl_js_1.types.InputChannel(peer) });
54
+ }
55
+ else {
56
+ (0, _1_utilities_js_1.UNREACHABLE)();
57
+ }
58
+ }
59
+ async getInactiveChats() {
60
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("getInactiveChats");
61
+ const { chats, dates } = await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.getInactiveChannels();
62
+ return chats.map((v, i) => (0, _3_types_js_1.constructInactiveChat)(v, dates[i]));
63
+ }
64
+ }
65
+ exports.AccountManager = AccountManager;
66
+ _AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _AccountManager_toggleUsername = async function _AccountManager_toggleUsername(id, username, active) {
67
+ const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
68
+ if (peer instanceof _2_tl_js_1.types.InputPeerSelf) {
69
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.account.toggleUsername({ username, active });
70
+ }
71
+ else if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
72
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.bots.toggleUsername({ bot: new _2_tl_js_1.types.InputUser(peer), username, active });
73
+ }
74
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
75
+ await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.toggleUsername({ channel: new _2_tl_js_1.types.InputChannel(peer), username, active });
76
+ }
77
+ else {
78
+ (0, _1_utilities_js_1.UNREACHABLE)();
79
+ }
80
+ };
@@ -1,6 +1,7 @@
1
1
  import { enums, types } from "../2_tl.js";
2
2
  import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
3
3
  import { BanChatMemberParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetHistoryParams, PinMessageParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams } from "./0_params.js";
4
+ import { SearchMessagesParams } from "./0_params.js";
4
5
  import { AddReactionParams, SetReactionsParams } from "./0_params.js";
5
6
  import { C as C_ } from "./0_types.js";
6
7
  import { FileManager } from "./1_file_manager.js";
@@ -98,5 +99,6 @@ export declare class MessageManager {
98
99
  getChatAdministrators(chatId: ID): Promise<ChatMember[]>;
99
100
  enableJoinRequests(chatId: ID): Promise<void>;
100
101
  disableJoinRequests(chatId: ID): Promise<void>;
102
+ searchMessages(chatId: ID, query: string, params?: SearchMessagesParams): Promise<Message[]>;
101
103
  }
102
104
  export {};
@@ -19,6 +19,7 @@ const _2_tl_js_1 = require("../2_tl.js");
19
19
  const _3_types_js_1 = require("../3_types.js");
20
20
  const _3_types_js_2 = require("../3_types.js");
21
21
  const _4_constants_js_1 = require("../4_constants.js");
22
+ const _0_message_search_filter_js_1 = require("../types/0_message_search_filter.js");
22
23
  const _0_html_js_1 = require("./0_html.js");
23
24
  const _0_utilities_js_1 = require("./0_utilities.js");
24
25
  const d = (0, _0_deps_js_1.debug)("MessageManager");
@@ -138,6 +139,7 @@ class MessageManager {
138
139
  return await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_updatesToMessages).call(this, to, result);
139
140
  }
140
141
  async getHistory(chatId, params) {
142
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getHistory");
141
143
  let limit = params?.limit ?? 100;
142
144
  if (limit <= 0) {
143
145
  limit = 1;
@@ -862,11 +864,38 @@ class MessageManager {
862
864
  }
863
865
  }
864
866
  async enableJoinRequests(chatId) {
867
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("enableJoinRequests");
865
868
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, true);
866
869
  }
867
870
  async disableJoinRequests(chatId) {
871
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("disableJoinRequests");
868
872
  await __classPrivateFieldGet(this, _MessageManager_instances, "m", _MessageManager_toggleJoinRequests).call(this, chatId, false);
869
873
  }
874
+ async searchMessages(chatId, query, params) {
875
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.search({
876
+ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
877
+ q: query,
878
+ add_offset: 0,
879
+ filter: (0, _0_message_search_filter_js_1.messageSearchFilterToTlObject)(params?.filter ?? "empty"),
880
+ hash: 0n,
881
+ limit: params?.limit ?? 100,
882
+ max_date: 0,
883
+ max_id: 0,
884
+ min_date: 0,
885
+ min_id: 0,
886
+ offset_id: params?.after ? params.after : 0,
887
+ from_id: params?.from ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(params.from) : undefined,
888
+ });
889
+ if (!("messages" in result)) {
890
+ (0, _1_utilities_js_1.UNREACHABLE)();
891
+ }
892
+ const messages = new Array();
893
+ for (const message_ of result.messages) {
894
+ const message = await this.constructMessage(message_, false);
895
+ messages.push(message);
896
+ }
897
+ return messages;
898
+ }
870
899
  }
871
900
  exports.MessageManager = MessageManager;
872
901
  _MessageManager_c = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {
@@ -25,6 +25,7 @@ class StoryManager {
25
25
  __classPrivateFieldSet(this, _StoryManager_c, c, "f");
26
26
  }
27
27
  async createStory(chatId, content, params) {
28
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("createStory");
28
29
  let media = null;
29
30
  const source = "video" in content ? content.video : "photo" in content ? content.photo : (0, _1_utilities_js_1.UNREACHABLE)();
30
31
  if (typeof source === "string") {
@@ -84,6 +85,7 @@ class StoryManager {
84
85
  return await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_updatesToStory).call(this, updates);
85
86
  }
86
87
  async getStories(chatId, storyIds) {
88
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("getStories");
87
89
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
88
90
  const stories_ = await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.getStoriesByID({ peer, id: storyIds });
89
91
  const stories = new Array();
@@ -93,25 +95,32 @@ class StoryManager {
93
95
  return stories;
94
96
  }
95
97
  async getStory(chatId, storyId) {
98
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("getStory");
96
99
  return await this.getStories(chatId, [storyId]).then((v) => v[0] ?? null);
97
100
  }
98
101
  async deleteStories(chatId, storyIds) {
102
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("deleteStories");
99
103
  const peer = await __classPrivateFieldGet(this, _StoryManager_c, "f").getInputPeer(chatId);
100
104
  await __classPrivateFieldGet(this, _StoryManager_c, "f").api.stories.deleteStories({ peer, id: storyIds });
101
105
  }
102
106
  async deleteStory(chatId, storyId) {
107
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("deleteStory");
103
108
  await this.deleteStories(chatId, [storyId]);
104
109
  }
105
110
  async addStoriesToHighlights(chatId, storyIds) {
111
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("addStoriesToHighlights");
106
112
  await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_togglePinned).call(this, chatId, storyIds, true);
107
113
  }
108
114
  async addStoryToHighlights(chatId, storyId) {
115
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("addStoryToHighlights");
109
116
  await this.addStoriesToHighlights(chatId, [storyId]);
110
117
  }
111
118
  async removeStoriesFromHighlights(chatId, storyIds) {
119
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("removeStoriesFromHighlights");
112
120
  await __classPrivateFieldGet(this, _StoryManager_instances, "m", _StoryManager_togglePinned).call(this, chatId, storyIds, false);
113
121
  }
114
122
  async removeStoryFromHighlights(chatId, storyId) {
123
+ await __classPrivateFieldGet(this, _StoryManager_c, "f").storage.assertUser("removeStoryFromHighlights");
115
124
  await this.removeStoriesFromHighlights(chatId, [storyId]);
116
125
  }
117
126
  static canHandleUpdate(update) {
@@ -2,11 +2,12 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { functions, types } from "../2_tl.js";
3
3
  import { Storage } from "../3_storage.js";
4
4
  import { DC } from "../3_transport.js";
5
+ import { InactiveChat } from "../3_types.js";
5
6
  import { BotCommand, Chat, ChatAction, ChatMember, ChatP, Document, FileSource, ID, InlineQueryResult, InputStoryContent, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Reaction, Story, Update, UpdateIntersection, User } from "../3_types.js";
6
7
  import { Migrate } from "../4_errors.js";
7
8
  import { ClientAbstract } from "./0_client_abstract.js";
8
9
  import { FilterQuery, WithFilter } from "./0_filters.js";
9
- import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, UploadParams } from "./0_params.js";
10
+ import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetHistoryParams, GetMyCommandsParams, PinMessageParams, ReplyParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, UploadParams } from "./0_params.js";
10
11
  import { Api } from "./0_types.js";
11
12
  import { Composer, Middleware } from "./1_composer.js";
12
13
  import { ClientPlainParams } from "./2_client_plain.js";
@@ -816,5 +817,50 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
816
817
  * @param chatId The identifier of the chat. Must be a channel or a supergroup.
817
818
  */
818
819
  disableJoinRequests(chatId: ID): Promise<void>;
820
+ /**
821
+ * Show a username in the current account, a bot account, sa upergroup, or a channel's profile. User-only.
822
+ *
823
+ * @method ac
824
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
825
+ * @param username The username to show.
826
+ */
827
+ showUsername(id: ID, username: string): Promise<void>;
828
+ /**
829
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
830
+ *
831
+ * @method ac
832
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
833
+ * @param username The username to hide.
834
+ */
835
+ hideUsername(id: ID, username: string): Promise<void>;
836
+ /**
837
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
838
+ *
839
+ * @method ac
840
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
841
+ * @param order The new order to use.
842
+ */
843
+ reorderUsernames(id: ID, order: string[]): Promise<boolean>;
844
+ /**
845
+ * Hide all usernames from the a supergroup or a channel's profile. User-only.
846
+ *
847
+ * @method ac
848
+ * @param id A supergroup ID or a channel ID.
849
+ */
850
+ hideUsernames(id: ID): Promise<boolean>;
851
+ /**
852
+ * Get inactive chats. User-only.
853
+ *
854
+ * @method ch
855
+ */
856
+ getInactiveChats(): Promise<InactiveChat[]>;
857
+ /**
858
+ * Search the messages of a chat.
859
+ *
860
+ * @method ms
861
+ * @param chatId The identifier of the chat to search the messages in.
862
+ * @param query The message search query.
863
+ */
864
+ searchMessages(chatId: ID, query: string, params?: SearchMessagesParams): Promise<Message[]>;
819
865
  }
820
866
  export {};
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  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");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_storeMessages, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_handle;
13
+ var _Client_instances, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_prefixes, _Client_storeMessages, _Client_namespaceProxies, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_setAuth, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_handle;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Client = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
16
16
  const _0_deps_js_1 = require("../0_deps.js");
@@ -26,6 +26,7 @@ const _0_message_js_1 = require("./0_message.js");
26
26
  const _0_password_js_1 = require("./0_password.js");
27
27
  const _0_types_js_1 = require("./0_types.js");
28
28
  const _0_utilities_js_1 = require("./0_utilities.js");
29
+ const _1_account_manager_js_1 = require("./1_account_manager.js");
29
30
  const _1_bot_info_manager_js_1 = require("./1_bot_info_manager.js");
30
31
  const _1_composer_js_1 = require("./1_composer.js");
31
32
  const _1_file_manager_js_1 = require("./1_file_manager.js");
@@ -88,6 +89,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
88
89
  _Client_callbackQueryManager.set(this, void 0);
89
90
  _Client_inlineQueryManager.set(this, void 0);
90
91
  _Client_chatListManager.set(this, void 0);
92
+ _Client_accountManager.set(this, void 0);
91
93
  Object.defineProperty(this, "storage", {
92
94
  enumerable: true,
93
95
  configurable: true,
@@ -620,6 +622,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
620
622
  __classPrivateFieldSet(this, _Client_storyManager, new _3_story_manager_js_1.StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
621
623
  __classPrivateFieldSet(this, _Client_inlineQueryManager, new _3_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
622
624
  __classPrivateFieldSet(this, _Client_chatListManager, new _3_chat_list_manager_js_1.ChatListManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
625
+ __classPrivateFieldSet(this, _Client_accountManager, new _1_account_manager_js_1.AccountManager(c), "f");
623
626
  __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
624
627
  const transportProvider = this.transportProvider;
625
628
  this.transportProvider = (params) => {
@@ -734,7 +737,7 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
734
737
  release();
735
738
  }
736
739
  }
737
- async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = 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_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
740
+ async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = 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_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_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_prefixes = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
738
741
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
739
742
  __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
740
743
  }, _Client_setAuth = async function _Client_setAuth(key) {
@@ -2062,6 +2065,63 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
2062
2065
  async disableJoinRequests(chatId) {
2063
2066
  await __classPrivateFieldGet(this, _Client_messageManager, "f").disableJoinRequests(chatId);
2064
2067
  }
2068
+ /**
2069
+ * Show a username in the current account, a bot account, sa upergroup, or a channel's profile. User-only.
2070
+ *
2071
+ * @method ac
2072
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2073
+ * @param username The username to show.
2074
+ */
2075
+ async showUsername(id, username) {
2076
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").showUsername(id, username);
2077
+ }
2078
+ /**
2079
+ * Hide a username from the current account, a bot account, a supergroup, or a channel's profile. User-only.
2080
+ *
2081
+ * @method ac
2082
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2083
+ * @param username The username to hide.
2084
+ */
2085
+ async hideUsername(id, username) {
2086
+ await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsername(id, username);
2087
+ }
2088
+ /**
2089
+ * Reorder the usernames of the current account, a bot account, a supergroup, or a channel's profile. User-only.
2090
+ *
2091
+ * @method ac
2092
+ * @param id `"me"`, a bot ID, a supergroup ID, or a channel ID.
2093
+ * @param order The new order to use.
2094
+ */
2095
+ async reorderUsernames(id, order) {
2096
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").reorderUsernames(id, order);
2097
+ }
2098
+ /**
2099
+ * Hide all usernames from the a supergroup or a channel's profile. User-only.
2100
+ *
2101
+ * @method ac
2102
+ * @param id A supergroup ID or a channel ID.
2103
+ */
2104
+ async hideUsernames(id) {
2105
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").hideUsernames(id);
2106
+ }
2107
+ /**
2108
+ * Get inactive chats. User-only.
2109
+ *
2110
+ * @method ch
2111
+ */
2112
+ async getInactiveChats() {
2113
+ return await __classPrivateFieldGet(this, _Client_accountManager, "f").getInactiveChats();
2114
+ }
2115
+ /**
2116
+ * Search the messages of a chat.
2117
+ *
2118
+ * @method ms
2119
+ * @param chatId The identifier of the chat to search the messages in.
2120
+ * @param query The message search query.
2121
+ */
2122
+ async searchMessages(chatId, query, params) {
2123
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").searchMessages(chatId, query, params);
2124
+ }
2065
2125
  }
2066
2126
  exports.Client = Client;
2067
2127
  _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
@@ -0,0 +1,2 @@
1
+ export type MessageSearchFilter = "empty" | "animations" | "audios" | "documents" | "photos" | "videos" | "voiceMessages" | "photosAndVideos" | "links" | "chatPhotos" | "videoNotes" | "voiceMessagesAndVideoNotes" | "mentions" | "pinned";
2
+ export declare function messageSearchFilterToTlObject(filter: MessageSearchFilter): import("../tl/2_types.js").InputMessagesFilterEmpty_ | import("../tl/2_types.js").InputMessagesFilterPhotos_ | import("../tl/2_types.js").InputMessagesFilterVideo_ | import("../tl/2_types.js").InputMessagesFilterPhotoVideo_ | import("../tl/2_types.js").InputMessagesFilterDocument_ | import("../tl/2_types.js").InputMessagesFilterUrl_ | import("../tl/2_types.js").InputMessagesFilterGif_ | import("../tl/2_types.js").InputMessagesFilterVoice_ | import("../tl/2_types.js").InputMessagesFilterMusic_ | import("../tl/2_types.js").InputMessagesFilterChatPhotos_ | import("../tl/2_types.js").InputMessagesFilterRoundVoice_ | import("../tl/2_types.js").InputMessagesFilterRoundVideo_ | import("../tl/2_types.js").InputMessagesFilterMyMentions_ | import("../tl/2_types.js").InputMessagesFilterPinned_;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.messageSearchFilterToTlObject = void 0;
4
+ const _1_utilities_js_1 = require("../1_utilities.js");
5
+ const _2_tl_js_1 = require("../2_tl.js");
6
+ function messageSearchFilterToTlObject(filter) {
7
+ switch (filter) {
8
+ case "empty":
9
+ return new _2_tl_js_1.types.InputMessagesFilterEmpty();
10
+ case "animations":
11
+ return new _2_tl_js_1.types.InputMessagesFilterGif();
12
+ case "audios":
13
+ return new _2_tl_js_1.types.InputMessagesFilterMusic();
14
+ case "documents":
15
+ return new _2_tl_js_1.types.InputMessagesFilterDocument();
16
+ case "photos":
17
+ return new _2_tl_js_1.types.InputMessagesFilterPhotos();
18
+ case "videos":
19
+ return new _2_tl_js_1.types.InputMessagesFilterVideo();
20
+ case "voiceMessages":
21
+ return new _2_tl_js_1.types.InputMessagesFilterVoice();
22
+ case "photosAndVideos":
23
+ return new _2_tl_js_1.types.InputMessagesFilterPhotoVideo();
24
+ case "links":
25
+ return new _2_tl_js_1.types.InputMessagesFilterUrl();
26
+ case "chatPhotos":
27
+ return new _2_tl_js_1.types.InputMessagesFilterChatPhotos();
28
+ case "videoNotes":
29
+ return new _2_tl_js_1.types.InputMessagesFilterRoundVideo();
30
+ case "voiceMessagesAndVideoNotes":
31
+ return new _2_tl_js_1.types.InputMessagesFilterRoundVoice();
32
+ case "mentions":
33
+ return new _2_tl_js_1.types.InputMessagesFilterMyMentions();
34
+ case "pinned":
35
+ return new _2_tl_js_1.types.InputMessagesFilterPinned();
36
+ default:
37
+ (0, _1_utilities_js_1.UNREACHABLE)();
38
+ }
39
+ }
40
+ exports.messageSearchFilterToTlObject = messageSearchFilterToTlObject;
@@ -0,0 +1,7 @@
1
+ import { enums } from "../2_tl.js";
2
+ import { ChatP } from "./1_chat_p.js";
3
+ export interface InactiveChat {
4
+ lastActivity: Date;
5
+ chat: ChatP;
6
+ }
7
+ export declare function constructInactiveChat(chat_: enums.Chat, lastActivity: number): InactiveChat;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructInactiveChat = void 0;
4
+ const _1_utilities_js_1 = require("../1_utilities.js");
5
+ const _2_tl_js_1 = require("../2_tl.js");
6
+ const _1_chat_p_js_1 = require("./1_chat_p.js");
7
+ function constructInactiveChat(chat_, lastActivity) {
8
+ if (chat_ instanceof _2_tl_js_1.types.ChatEmpty) {
9
+ (0, _1_utilities_js_1.UNREACHABLE)();
10
+ }
11
+ const chat = (0, _1_chat_p_js_1.constructChatP)(chat_);
12
+ return {
13
+ lastActivity: (0, _1_utilities_js_1.fromUnixTimestamp)(lastActivity),
14
+ chat,
15
+ };
16
+ }
17
+ exports.constructInactiveChat = constructInactiveChat;