@mtkruto/node 0.1.155 → 0.1.156

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/esm/4_constants.d.ts +1 -1
  2. package/esm/4_constants.js +1 -1
  3. package/esm/4_errors.d.ts +1 -1
  4. package/esm/client/0_params.d.ts +20 -0
  5. package/esm/client/0_password.d.ts +2 -2
  6. package/esm/client/0_types.d.ts +1 -0
  7. package/esm/client/1_composer.d.ts +3 -3
  8. package/esm/client/2_client_plain.d.ts +1 -4
  9. package/esm/client/2_client_plain.js +1 -4
  10. package/esm/client/2_message_manager.d.ts +9 -36
  11. package/esm/client/2_message_manager.js +73 -1
  12. package/esm/client/4_client.d.ts +90 -15
  13. package/esm/client/4_client.js +123 -12
  14. package/esm/storage/0_storage.d.ts +38 -38
  15. package/esm/storage/0_storage.js +2 -2
  16. package/esm/storage/0_utilities.d.ts +2 -2
  17. package/esm/storage/1_storage_indexed_db.d.ts +1 -1
  18. package/esm/storage/1_storage_local_storage.d.ts +1 -1
  19. package/esm/storage/1_storage_memory.d.ts +3 -3
  20. package/esm/storage/1_storage_session_storage.d.ts +1 -1
  21. package/esm/tl/0_tl_raw_writer.d.ts +9 -9
  22. package/esm/tl/1_tl_object.d.ts +1 -1
  23. package/esm/tl/1_tl_object.js +3 -3
  24. package/esm/tl/3_functions.d.ts +28 -28
  25. package/esm/tl/3_functions.js +586 -586
  26. package/esm/tl/3_utilities.d.ts +3 -3
  27. package/esm/tl/4_tl_writer.d.ts +1 -1
  28. package/esm/types/0_chat_administrator_rights.d.ts +2 -2
  29. package/esm/types/0_chat_member_rights.d.ts +1 -1
  30. package/esm/types/0_message_entity.d.ts +1 -1
  31. package/esm/types/0_message_search_filter.d.ts +2 -1
  32. package/esm/types/1_bot_command_scope.d.ts +2 -1
  33. package/esm/types/1_keyboard_button.d.ts +1 -1
  34. package/esm/types/1_story_interactive_area.d.ts +1 -1
  35. package/esm/types/2_inline_keyboard_button.d.ts +1 -1
  36. package/esm/types/2_invite_link.d.ts +6 -6
  37. package/esm/types/2_invite_link.js +4 -4
  38. package/esm/types/3_reply_markup.d.ts +2 -2
  39. package/esm/types/4_inline_query_result.d.ts +2 -1
  40. package/esm/types/4_message.d.ts +1 -60
  41. package/esm/types/5_callback_query.d.ts +2 -2
  42. package/esm/utilities/0_cache_map.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/script/4_constants.d.ts +1 -1
  45. package/script/4_constants.js +1 -1
  46. package/script/4_errors.d.ts +1 -1
  47. package/script/client/0_params.d.ts +20 -0
  48. package/script/client/0_password.d.ts +2 -2
  49. package/script/client/0_types.d.ts +1 -0
  50. package/script/client/1_composer.d.ts +3 -3
  51. package/script/client/2_client_plain.d.ts +1 -4
  52. package/script/client/2_client_plain.js +1 -4
  53. package/script/client/2_message_manager.d.ts +9 -36
  54. package/script/client/2_message_manager.js +72 -0
  55. package/script/client/4_client.d.ts +90 -15
  56. package/script/client/4_client.js +123 -12
  57. package/script/storage/0_storage.d.ts +38 -38
  58. package/script/storage/0_storage.js +2 -2
  59. package/script/storage/0_utilities.d.ts +2 -2
  60. package/script/storage/1_storage_indexed_db.d.ts +1 -1
  61. package/script/storage/1_storage_local_storage.d.ts +1 -1
  62. package/script/storage/1_storage_memory.d.ts +3 -3
  63. package/script/storage/1_storage_session_storage.d.ts +1 -1
  64. package/script/tl/0_tl_raw_writer.d.ts +9 -9
  65. package/script/tl/1_tl_object.d.ts +1 -1
  66. package/script/tl/1_tl_object.js +3 -3
  67. package/script/tl/3_functions.d.ts +28 -28
  68. package/script/tl/3_functions.js +586 -586
  69. package/script/tl/3_utilities.d.ts +3 -3
  70. package/script/tl/4_tl_writer.d.ts +1 -1
  71. package/script/types/0_chat_administrator_rights.d.ts +2 -2
  72. package/script/types/0_chat_member_rights.d.ts +1 -1
  73. package/script/types/0_message_entity.d.ts +1 -1
  74. package/script/types/0_message_search_filter.d.ts +2 -1
  75. package/script/types/1_bot_command_scope.d.ts +2 -1
  76. package/script/types/1_keyboard_button.d.ts +1 -1
  77. package/script/types/1_story_interactive_area.d.ts +1 -1
  78. package/script/types/2_inline_keyboard_button.d.ts +1 -1
  79. package/script/types/2_invite_link.d.ts +6 -6
  80. package/script/types/2_invite_link.js +4 -4
  81. package/script/types/3_reply_markup.d.ts +2 -2
  82. package/script/types/4_inline_query_result.d.ts +2 -1
  83. package/script/types/4_message.d.ts +1 -60
  84. package/script/types/5_callback_query.d.ts +2 -2
  85. package/script/utilities/0_cache_map.d.ts +1 -1
@@ -8,7 +8,7 @@ export declare function peerToChatId(peer: enums.Peer | enums.InputPeer | AnyEnt
8
8
  } | {
9
9
  chat_id: bigint;
10
10
  }): number;
11
- export declare function chatIdToPeer(chatId: number): import("./2_types.js").PeerUser_ | import("./2_types.js").PeerChat_ | import("./2_types.js").PeerChannel_;
11
+ export declare function chatIdToPeer(chatId: number): enums.Peer;
12
12
  export declare function chatIdToPeerId(chatId: number): bigint;
13
- export declare function getChatIdPeerType(chatId: number): "chat" | "channel" | "user";
14
- export declare function inputPeerToPeer(inputPeer: enums.InputPeer): import("./2_types.js").PeerUser_ | import("./2_types.js").PeerChat_ | import("./2_types.js").PeerChannel_;
13
+ export declare function getChatIdPeerType(chatId: number): "user" | "chat" | "channel";
14
+ export declare function inputPeerToPeer(inputPeer: enums.InputPeer): enums.Peer;
@@ -1,5 +1,5 @@
1
1
  import { TLRawWriter } from "./0_tl_raw_writer.js";
2
2
  import { ReadObject } from "./3_tl_reader.js";
3
3
  export declare class TLWriter extends TLRawWriter {
4
- writeObject(object: ReadObject): this;
4
+ writeObject(object: ReadObject): typeof this;
5
5
  }
@@ -1,4 +1,4 @@
1
- import { enums } from "../2_tl.js";
1
+ import { enums, types } from "../2_tl.js";
2
2
  /** The rights of a chat administrator. */
3
3
  export interface ChatAdministratorRights {
4
4
  /** Whether the admininistrator's presence in the chat is hidden. */
@@ -27,4 +27,4 @@ export interface ChatAdministratorRights {
27
27
  canManageTopics?: boolean;
28
28
  }
29
29
  export declare function constructChatAdministratorRights(rights_: enums.ChatAdminRights): ChatAdministratorRights;
30
- export declare function chatAdministratorRightsToTlObject(rights: ChatAdministratorRights): import("../tl/2_types.js").ChatAdminRights_;
30
+ export declare function chatAdministratorRightsToTlObject(rights: ChatAdministratorRights): types.ChatAdminRights;
@@ -37,4 +37,4 @@ export interface ChatMemberRights {
37
37
  canManageTopics?: boolean;
38
38
  }
39
39
  export declare function constructChatMemberRights(rights: types.ChatBannedRights): ChatMemberRights;
40
- export declare function chatMemberRightsToTlObject(rights?: ChatMemberRights, untilDate?: Date): import("../tl/2_types.js").ChatBannedRights_;
40
+ export declare function chatMemberRightsToTlObject(rights?: ChatMemberRights, untilDate?: Date): types.ChatBannedRights;
@@ -95,4 +95,4 @@ export interface MessageEntityCustomEmoji extends _MessageEntityBase {
95
95
  /** A single entity of a message's text or caption. */
96
96
  export type MessageEntity = MessageEntityMention | MessageEntityHashtag | MessageEntityBotCommand | MessageEntityURL | MessageEntityEmailAddress | MessageEntityBold | MessageEntityItalic | MessageEntityCode | MessageEntityPre | MessageEntityTextLink | MessageEntityTextMention | MessageEntityCashtag | MessageEntityPhoneNumber | MessageEntityUnderline | MessageEntityStrikethrough | MessageEntityBlockquote | MessageEntityBankCard | MessageEntitySpoiler | MessageEntityCustomEmoji;
97
97
  export declare function constructMessageEntity(obj: enums.MessageEntity): MessageEntity | null;
98
- export declare function messageEntityToTlObject(entity: MessageEntity, getEntity: EntityGetter): Promise<import("../tl/2_types.js").MessageEntityMention_ | import("../tl/2_types.js").MessageEntityHashtag_ | import("../tl/2_types.js").MessageEntityBotCommand_ | import("../tl/2_types.js").MessageEntityUrl_ | import("../tl/2_types.js").MessageEntityEmail_ | import("../tl/2_types.js").MessageEntityBold_ | import("../tl/2_types.js").MessageEntityItalic_ | import("../tl/2_types.js").MessageEntityCode_ | import("../tl/2_types.js").MessageEntityPre_ | import("../tl/2_types.js").MessageEntityTextUrl_ | import("../tl/2_types.js").InputMessageEntityMentionName_ | import("../tl/2_types.js").MessageEntityPhone_ | import("../tl/2_types.js").MessageEntityCashtag_ | import("../tl/2_types.js").MessageEntityUnderline_ | import("../tl/2_types.js").MessageEntityStrike_ | import("../tl/2_types.js").MessageEntityBankCard_ | import("../tl/2_types.js").MessageEntitySpoiler_ | import("../tl/2_types.js").MessageEntityCustomEmoji_ | import("../tl/2_types.js").MessageEntityBlockquote_>;
98
+ export declare function messageEntityToTlObject(entity: MessageEntity, getEntity: EntityGetter): Promise<enums.MessageEntity>;
@@ -1,2 +1,3 @@
1
+ import { enums } from "../2_tl.js";
1
2
  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_;
3
+ export declare function messageSearchFilterToTlObject(filter: MessageSearchFilter): enums.MessagesFilter;
@@ -1,3 +1,4 @@
1
+ import { enums } from "../2_tl.js";
1
2
  import { ID } from "./0_id.js";
2
3
  import { InputPeerGetter } from "./1__getters.js";
3
4
  /** @unlisted */
@@ -34,4 +35,4 @@ export interface BotCommandScopeChatMember {
34
35
  }
35
36
  /** A type specifying where bot commads are available. */
36
37
  export type BotCommandScope = BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember;
37
- export declare function botCommandScopeToTlObject(scope: BotCommandScope, getInputPeer: InputPeerGetter): Promise<import("../tl/2_types.js").BotCommandScopeDefault_ | import("../tl/2_types.js").BotCommandScopeUsers_ | import("../tl/2_types.js").BotCommandScopeChats_ | import("../tl/2_types.js").BotCommandScopeChatAdmins_ | import("../tl/2_types.js").BotCommandScopePeer_ | import("../tl/2_types.js").BotCommandScopePeerAdmins_ | import("../tl/2_types.js").BotCommandScopePeerUser_>;
38
+ export declare function botCommandScopeToTlObject(scope: BotCommandScope, getInputPeer: InputPeerGetter): Promise<enums.BotCommandScope>;
@@ -46,4 +46,4 @@ export interface KeyboardButtonMiniApp extends KeyboardButtonText {
46
46
  /** A button of a custom keyboard. */
47
47
  export type KeyboardButton = KeyboardButtonText | KeyboardButtonRequestUser | KeyboardButtonRequestChat | KeyboardButtonRequestContact | KeyboardButtonRequestLocation | KeyboardButtonRequestPoll | KeyboardButtonMiniApp;
48
48
  export declare function constructKeyboardButton(button_: enums.KeyboardButton): KeyboardButton;
49
- export declare function keyboardButtonToTlObject(button: KeyboardButton): import("../tl/2_types.js").KeyboardButton_ | import("../tl/2_types.js").KeyboardButtonRequestPhone_ | import("../tl/2_types.js").KeyboardButtonRequestGeoLocation_ | import("../tl/2_types.js").KeyboardButtonRequestPoll_ | import("../tl/2_types.js").KeyboardButtonWebView_ | import("../tl/2_types.js").KeyboardButtonRequestPeer_;
49
+ export declare function keyboardButtonToTlObject(button: KeyboardButton): enums.KeyboardButton;
@@ -38,4 +38,4 @@ export interface StoryInteractiveAreaMessage extends _StoryInteractiveAreaPositi
38
38
  /** A story's interactive area. */
39
39
  export type StoryInteractiveArea = StoryInteractiveAreaLocation | StoryInteractiveAreaVenue | StoryInteractiveAreaReaction | StoryInteractiveAreaMessage;
40
40
  export declare function constructStoryInteractiveArea(area: enums.MediaArea): StoryInteractiveArea;
41
- export declare function storyInteractiveAreaToTlObject(area: StoryInteractiveArea, getEntity: EntityGetter): Promise<import("../tl/2_types.js").MediaAreaVenue_ | import("../tl/2_types.js").MediaAreaGeoPoint_ | import("../tl/2_types.js").MediaAreaSuggestedReaction_ | import("../tl/2_types.js").InputMediaAreaChannelPost_>;
41
+ export declare function storyInteractiveAreaToTlObject(area: StoryInteractiveArea, getEntity: EntityGetter): Promise<enums.MediaArea>;
@@ -41,4 +41,4 @@ export interface InlineKeyboardButtonPay extends _InlineKeyboardButtonBase {
41
41
  /** A button of an inline keyboard. */
42
42
  export type InlineKeyboardButton = InlineKeyboardButtonURL | InlineKeyboardButtonCallback | InlineKeyboardButtonMiniApp | InlineKeyboardButtonLogin | InlineKeyboardButtonSwitchInline | InlineKeyboardButtonSwitchInlineCurrent | InlineKeyboardButtonGame | InlineKeyboardButtonPay;
43
43
  export declare function constructInlineKeyboardButton(button_: enums.KeyboardButton): InlineKeyboardButton;
44
- export declare function inlineKeyboardButtonToTlObject(button: InlineKeyboardButton, usernameResolver: UsernameResolver): Promise<import("../tl/2_types.js").KeyboardButtonUrl_ | import("../tl/2_types.js").KeyboardButtonCallback_ | import("../tl/2_types.js").KeyboardButtonSwitchInline_ | import("../tl/2_types.js").KeyboardButtonBuy_ | import("../tl/2_types.js").InputKeyboardButtonUrlAuth_ | import("../tl/2_types.js").KeyboardButtonWebView_>;
44
+ export declare function inlineKeyboardButtonToTlObject(button: InlineKeyboardButton, usernameResolver: UsernameResolver): Promise<enums.KeyboardButton>;
@@ -7,17 +7,17 @@ export interface InviteLink {
7
7
  inviteLink: string;
8
8
  /** The user who created the invite link. */
9
9
  creator: User;
10
- /** Whether the invite link requires explicit approval from administrators. */
11
- createsJoinRequest: boolean;
10
+ /** Whether an admin must explicitly approve join requests originating from this invite link. */
11
+ requiresApproval: boolean;
12
12
  /** Whether the invite link is revoked. */
13
13
  revoked: boolean;
14
- /** An optional name. */
15
- name?: string;
14
+ /** An optional title. */
15
+ title?: string;
16
16
  /** The point of time in which the invite link is expired at. */
17
17
  expiresAt?: Date;
18
- /** The number of times the invite link can be used. */
18
+ /** The times the invite link can be used. */
19
19
  limit?: number;
20
- /** The number of pending join requests from this invite link. */
20
+ /** The number of pending join requests originating from this invite link. */
21
21
  pendingJoinRequestCount?: number;
22
22
  }
23
23
  export declare function constructInviteLink(inviteLink_: types.ChatInviteExported, getEntity: EntityGetter): Promise<InviteLink>;
@@ -8,18 +8,18 @@ export async function constructInviteLink(inviteLink_, getEntity) {
8
8
  }
9
9
  const inviteLink = inviteLink_.link;
10
10
  const creator = constructUser(entity);
11
- const createsJoinRequest = inviteLink_.request_needed ? true : false;
11
+ const requiresApproval = inviteLink_.request_needed ? true : false;
12
12
  const revoked = inviteLink_.revoked ? true : false;
13
- const name = inviteLink_.title;
13
+ const title = inviteLink_.title;
14
14
  const expiresAt = inviteLink_.expire_date ? fromUnixTimestamp(inviteLink_.expire_date) : undefined;
15
15
  const limit = inviteLink_.usage_limit ? inviteLink_.usage_limit : undefined;
16
16
  const pendingJoinRequestCount = inviteLink_.requested;
17
17
  return cleanObject({
18
18
  inviteLink,
19
19
  creator,
20
- createsJoinRequest,
20
+ requiresApproval,
21
21
  revoked,
22
- name,
22
+ title,
23
23
  expiresAt,
24
24
  limit,
25
25
  pendingJoinRequestCount,
@@ -39,5 +39,5 @@ export interface ReplyMarkupForceReply {
39
39
  }
40
40
  /** A message's reply markup. */
41
41
  export type ReplyMarkup = ReplyMarkupInlineKeyboard | ReplyMarkupKeyboard | ReplyMarkupRemoveKeyboard | ReplyMarkupForceReply;
42
- export declare function constructReplyMarkup(replyMarkup: enums.ReplyMarkup): ReplyMarkupInlineKeyboard | ReplyMarkupKeyboard | ReplyMarkupRemoveKeyboard | ReplyMarkupForceReply;
43
- export declare function replyMarkupToTlObject(replyMarkup: ReplyMarkup, usernameResolver: UsernameResolver): Promise<import("../tl/2_types.js").ReplyKeyboardHide_ | import("../tl/2_types.js").ReplyKeyboardForceReply_ | import("../tl/2_types.js").ReplyKeyboardMarkup_ | import("../tl/2_types.js").ReplyInlineMarkup_>;
42
+ export declare function constructReplyMarkup(replyMarkup: enums.ReplyMarkup): ReplyMarkup;
43
+ export declare function replyMarkupToTlObject(replyMarkup: ReplyMarkup, usernameResolver: UsernameResolver): Promise<enums.ReplyMarkup>;
@@ -1,3 +1,4 @@
1
+ import { enums } from "../2_tl.js";
1
2
  import { MessageEntity } from "./0_message_entity.js";
2
3
  import { ParseMode } from "./0_parse_mode.js";
3
4
  import { UsernameResolver } from "./1__getters.js";
@@ -190,5 +191,5 @@ export type InlineQueryResult = InlineQueryResultCachedAudio | InlineQueryResult
190
191
  export declare function inlineQueryResultToTlObject(result_: InlineQueryResult, parseText: (text: string, params?: {
191
192
  parseMode?: ParseMode;
192
193
  entities?: MessageEntity[];
193
- }) => Promise<readonly [string, any[] | undefined]>, usernameResolver: UsernameResolver): Promise<import("../tl/2_types.js").InputBotInlineResult_ | import("../tl/2_types.js").InputBotInlineResultDocument_>;
194
+ }) => Promise<readonly [string, any[] | undefined]>, usernameResolver: UsernameResolver): Promise<enums.InputBotInlineResult>;
194
195
  export {};
@@ -464,64 +464,5 @@ export interface MessageGetter {
464
464
  (chatId: number, messageId: number): MaybePromise<Message | null>;
465
465
  }
466
466
  type Message_MessageGetter = MessageGetter | null;
467
- export declare function constructMessage(message_: enums.Message, getEntity: EntityGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter, getReply_?: boolean): Promise<MessageLink | MessagePhoto | MessageDocument | MessageVideo | MessageSticker | MessageAnimation | MessageVoice | MessageAudio | MessageDice | MessageVideoNote | MessageContact | MessageGame | MessagePoll | MessageVenue | MessageLocation | MessageNewChatMembers | MessageLeftChatMember | MessageNewChatTitle | MessageNewChatPhoto | MessageDeletedChatPhoto | MessageSupergroupCreated | MessageChannelCreated | MessageAutoDeleteTimerChanged | MessageChatMigratedTo | MessageChatMigratedFrom | MessagePinnedMessage | MessageUserShared | MessageWriteAccessAllowed | MessageForumTopicCreated | MessageForumTopicEdited | MessageForumTopicClosed | MessageForumTopicReopened | MessageVideoChatScheduled | MessageVideoChatStarted | MessageVideoChatEnded | MessageGiveaway | MessageUnsupported | {
468
- text: string;
469
- entities: NonNullable<MessageEntity | null>[];
470
- /** Whether the message is outgoing (sent by the current user). */
471
- out: boolean;
472
- /** The identifier of the message. */
473
- id: number;
474
- /** The identifier of the message's thread. */
475
- threadId?: number | undefined;
476
- /** The user who sent the message. */
477
- from?: User | undefined;
478
- /** The chat which the message was sent on behalf of. */
479
- senderChat?: ChatP | undefined;
480
- /** The point of time in which the message was sent. */
481
- date: Date;
482
- /** The chat where the message was sent to. */
483
- chat: ChatP;
484
- /** A link to the message. */
485
- link?: string | undefined;
486
- /** The original sender of the message. */
487
- forwardFrom?: User | undefined;
488
- /** The original chat of the message. */
489
- forwardFromChat?: ChatP | undefined;
490
- /** The original identifier of the message. */
491
- forwardId?: number | undefined;
492
- /** The original signature of the message. */
493
- forwardSignature?: string | undefined;
494
- /** The name of the original sender of the message. */
495
- forwardSenderName?: string | undefined;
496
- /** The point of time in which the original message was sent. */
497
- forwardDate?: Date | undefined;
498
- /** Whether the message was sent in a topic thread. */
499
- isTopicMessage: boolean;
500
- /** Whether the message is an automatic forward. */
501
- isAutomaticForward?: boolean | undefined;
502
- /** The message that is being replied to. Not always available even if a message is being replied to. */
503
- replyToMessage?: Message | undefined;
504
- /** The identifier of the message that is being replied to. */
505
- replyToMessageId?: number | undefined;
506
- /** The reactions of the message. */
507
- reactions?: MessageReaction[] | undefined;
508
- /** The part of the message that is being replied to. */
509
- replyQuote?: ReplyQuote | undefined;
510
- /** The inline bot that was used to send this message. */
511
- viaBot?: User | undefined;
512
- /** The point of time in which the message's last edit was made. */
513
- editDate?: Date | undefined;
514
- /** Whether the contents of the message is protected. */
515
- hasProtectedContent?: boolean | undefined;
516
- /** The identifier of the message's media group. */
517
- mediaGroupId?: string | undefined;
518
- /** The signature of the message. */
519
- authorSignature?: string | undefined;
520
- /** The number of times the message was viewed. */
521
- views?: number | undefined;
522
- /** The number of times the message was forwarded. */
523
- forwards?: number | undefined;
524
- /** The message's reply markup. */
525
- replyMarkup?: ReplyMarkup | undefined;
526
- }>;
467
+ export declare function constructMessage(message_: enums.Message, getEntity: EntityGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter, getReply_?: boolean): Promise<Message>;
527
468
  export {};
@@ -1,4 +1,4 @@
1
- import { types } from "../2_tl.js";
1
+ import { enums, types } from "../2_tl.js";
2
2
  import { EntityGetter } from "./1__getters.js";
3
3
  import { User } from "./1_user.js";
4
4
  import { Message, MessageGetter } from "./4_message.js";
@@ -12,5 +12,5 @@ export interface CallbackQuery {
12
12
  data?: string;
13
13
  gameShortName?: string;
14
14
  }
15
- export declare function deserializeInlineMessageId(inlineMessageId: string): import("../tl/2_types.js").InputBotInlineMessageID_ | import("../tl/2_types.js").InputBotInlineMessageID64_;
15
+ export declare function deserializeInlineMessageId(inlineMessageId: string): enums.InputBotInlineMessageID;
16
16
  export declare function constructCallbackQuery(callbackQuery: types.UpdateBotCallbackQuery | types.UpdateInlineBotCallbackQuery, getEntity: EntityGetter, getMessage: MessageGetter): Promise<CallbackQuery>;
@@ -2,5 +2,5 @@ export declare class CacheMap<K, V> extends Map<K, V> {
2
2
  #private;
3
3
  constructor(limit: number, entries?: readonly (readonly [K, V])[] | null);
4
4
  constructor(limit: number);
5
- set(key: K, value: V): this;
5
+ set(key: K, value: V): typeof this;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.155",
3
+ "version": "0.1.156",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -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 = 174;
7
- export declare const APP_VERSION = "MTKruto 0.1.155";
7
+ export declare const APP_VERSION = "MTKruto 0.1.156";
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 = 174;
82
- exports.APP_VERSION = "MTKruto 0.1.155";
82
+ exports.APP_VERSION = "MTKruto 0.1.156";
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" || typeof navigator.language !== "string" ? "en" : navigator.language.split("-")[0];
@@ -17,4 +17,4 @@ export declare class FileMigrate extends Migrate {
17
17
  }
18
18
  export declare class StatsMigrate extends Migrate {
19
19
  }
20
- export declare function upgradeInstance(error: types.Rpc_error, call: TLObject): import("./tl/2_types.js").Rpc_error_;
20
+ export declare function upgradeInstance(error: types.Rpc_error, call: TLObject): types.Rpc_error;
@@ -287,3 +287,23 @@ export interface SearchMessagesParams {
287
287
  /** The maximum number of results to return. Must be in the range of 1-100. Defaults to 100. */
288
288
  limit?: number;
289
289
  }
290
+ export interface CreateInviteLinkParams {
291
+ /** An optional title to be attached to the link that can only be seen by admins. */
292
+ title?: string;
293
+ /** The point of time in which the invite link must no longer work. */
294
+ expireAt?: Date;
295
+ /** The times the invite link can be used. Cannot be specified while `requireApproval` is `true`. */
296
+ limit?: number;
297
+ /** Whether an admin must explicitly approve join requests originating from this invite link. Cannot be `true` while `limit` is specified. */
298
+ requireApproval?: boolean;
299
+ }
300
+ export interface GetCreatedInviteLinksParams {
301
+ /** The identifier of an admin. If specified, only invite links created by this admin will be returned. */
302
+ by?: ID;
303
+ /** The maximum number of results to return. Must be in the range 1-100. Defaults to 100. */
304
+ limit?: number;
305
+ /** Whether only revoked invite links must be returned. */
306
+ revoked?: boolean;
307
+ afterDate?: Date;
308
+ afterInviteLink?: string;
309
+ }
@@ -1,5 +1,5 @@
1
1
  import { sha256 } from "../1_utilities.js";
2
- import { enums } from "../2_tl.js";
2
+ import { enums, types } from "../2_tl.js";
3
3
  export declare function isSafePrime(primeBytes: Uint8Array, g: number): boolean;
4
4
  export declare const h: typeof sha256;
5
5
  export declare const sh: (data: Uint8Array, salt: Uint8Array) => Promise<Uint8Array>;
@@ -8,4 +8,4 @@ export declare function pbkdf2(password: Uint8Array, salt: Uint8Array, iteration
8
8
  export declare const ph2: (password: Uint8Array, salt1: Uint8Array, salt2: Uint8Array) => Promise<Uint8Array>;
9
9
  export declare function isGoodModExpFirst(modexp: bigint, prime: bigint): boolean;
10
10
  export declare function pad(bigint: number | bigint | Uint8Array): Uint8Array;
11
- export declare function checkPassword(password_: string, ap: enums.account.Password): Promise<import("../tl/2_types.js").InputCheckPasswordSRP_>;
11
+ export declare function checkPassword(password_: string, ap: enums.account.Password): Promise<types.InputCheckPasswordSRP>;
@@ -32,6 +32,7 @@ export interface C {
32
32
  getSelfId: () => Promise<number>;
33
33
  getInputPeer: (id: ID) => Promise<enums.InputPeer>;
34
34
  getInputChannel: (id: ID) => Promise<types.InputChannel>;
35
+ getInputUser: (id: ID) => Promise<types.InputUser>;
35
36
  getEntity: EntityGetter;
36
37
  handleUpdate: (update: Update) => void;
37
38
  parseMode: ParseMode;
@@ -17,14 +17,14 @@ export declare class Composer<C extends {
17
17
  set prefixes(value: string | string[]);
18
18
  constructor(...middleware: Middleware<C>[]);
19
19
  middleware(): MiddlewareFn<C>;
20
- use(...middleware: Middleware<UpdateIntersection<C>>[]): Composer<UpdateIntersection<C>>;
21
- branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<UpdateIntersection<C>>;
20
+ use(...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
21
+ branch(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, trueHandler_: Middleware<UpdateIntersection<C>>, falseHandler_: Middleware<UpdateIntersection<C>>): Composer<C>;
22
22
  filter<D extends C>(predicate: (ctx: UpdateIntersection<C>) => ctx is D, ...middleware: Middleware<D>[]): Composer<D>;
23
23
  filter(predicate: (ctx: UpdateIntersection<C>) => MaybePromise<boolean>, ...middleware: Middleware<UpdateIntersection<C>>[]): Composer<C>;
24
24
  on<Q extends FilterQuery>(filter: Q, ...middleawre: Middleware<WithFilter<C, Q>>[]): Composer<UpdateIntersection<WithFilter<C, Q>>>;
25
25
  command(commands: string | RegExp | (string | RegExp)[] | {
26
26
  names: string | RegExp | (string | RegExp)[];
27
27
  prefixes: string | string[];
28
- }, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<UpdateIntersection<WithFilter<C, "message:text">>>;
28
+ }, ...middleawre: Middleware<WithFilter<C, "message:text">>[]): Composer<WithFilter<C, "message:text">>;
29
29
  }
30
30
  export {};
@@ -11,8 +11,5 @@ export declare class ClientPlain extends ClientAbstract {
11
11
  #private;
12
12
  constructor(params?: ClientPlainParams);
13
13
  invoke<T extends functions.Function<unknown>>(function_: T): Promise<T["__R"]>;
14
- createAuthKey(): Promise<{
15
- authKey: Uint8Array;
16
- salt: bigint;
17
- }>;
14
+ createAuthKey(): Promise<[Uint8Array, bigint]>;
18
15
  }
@@ -145,10 +145,7 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
145
145
  const authKey_ = (0, _1_utilities_js_1.modExp)(gA, b, dhPrime);
146
146
  const authKey = (0, _1_utilities_js_1.bufferFromBigInt)(authKey_, 256, false, false);
147
147
  LcreateAuthKey.debug("auth key created");
148
- return {
149
- authKey,
150
- salt: (0, _1_utilities_js_1.bigIntFromBuffer)(salt, true, false),
151
- };
148
+ return [authKey, (0, _1_utilities_js_1.bigIntFromBuffer)(salt, true, false)];
152
149
  }
153
150
  }
154
151
  exports.ClientPlain = ClientPlain;
@@ -1,8 +1,6 @@
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
- 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";
5
- import { AddReactionParams, SetReactionsParams } from "./0_params.js";
3
+ import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams } from "./0_params.js";
6
4
  import { C as C_ } from "./0_types.js";
7
5
  import { FileManager } from "./1_file_manager.js";
8
6
  interface C extends C_ {
@@ -18,40 +16,9 @@ export declare class MessageManager {
18
16
  parseText(text: string, params?: {
19
17
  parseMode?: ParseMode;
20
18
  entities?: MessageEntity[];
21
- }): Promise<readonly [string, (import("../tl/2_types.js").MessageEntityMention_ | import("../tl/2_types.js").MessageEntityHashtag_ | import("../tl/2_types.js").MessageEntityBotCommand_ | import("../tl/2_types.js").MessageEntityUrl_ | import("../tl/2_types.js").MessageEntityEmail_ | import("../tl/2_types.js").MessageEntityBold_ | import("../tl/2_types.js").MessageEntityItalic_ | import("../tl/2_types.js").MessageEntityCode_ | import("../tl/2_types.js").MessageEntityPre_ | import("../tl/2_types.js").MessageEntityTextUrl_ | import("../tl/2_types.js").InputMessageEntityMentionName_ | import("../tl/2_types.js").MessageEntityPhone_ | import("../tl/2_types.js").MessageEntityCashtag_ | import("../tl/2_types.js").MessageEntityUnderline_ | import("../tl/2_types.js").MessageEntityStrike_ | import("../tl/2_types.js").MessageEntityBankCard_ | import("../tl/2_types.js").MessageEntitySpoiler_ | import("../tl/2_types.js").MessageEntityCustomEmoji_ | import("../tl/2_types.js").MessageEntityBlockquote_)[] | undefined]>;
19
+ }): Promise<readonly [string, enums.MessageEntity[] | undefined]>;
22
20
  getStickerSetName(inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
23
- constructMessage(message_: enums.Message, r?: boolean): Promise<import("../3_types.js").MessageLink | import("../3_types.js").MessagePhoto | import("../3_types.js").MessageDocument | import("../3_types.js").MessageVideo | import("../3_types.js").MessageSticker | import("../3_types.js").MessageAnimation | import("../3_types.js").MessageVoice | import("../3_types.js").MessageAudio | import("../3_types.js").MessageDice | import("../3_types.js").MessageVideoNote | import("../3_types.js").MessageContact | import("../3_types.js").MessageGame | import("../3_types.js").MessagePoll | import("../3_types.js").MessageVenue | import("../3_types.js").MessageLocation | import("../3_types.js").MessageNewChatMembers | import("../3_types.js").MessageLeftChatMember | import("../3_types.js").MessageNewChatTitle | import("../3_types.js").MessageNewChatPhoto | import("../3_types.js").MessageDeletedChatPhoto | import("../3_types.js").MessageSupergroupCreated | import("../3_types.js").MessageChannelCreated | import("../3_types.js").MessageAutoDeleteTimerChanged | import("../3_types.js").MessageChatMigratedTo | import("../3_types.js").MessageChatMigratedFrom | import("../3_types.js").MessagePinnedMessage | import("../3_types.js").MessageUserShared | import("../3_types.js").MessageWriteAccessAllowed | import("../3_types.js").MessageForumTopicCreated | import("../3_types.js").MessageForumTopicEdited | import("../3_types.js").MessageForumTopicClosed | import("../3_types.js").MessageForumTopicReopened | import("../3_types.js").MessageVideoChatScheduled | import("../3_types.js").MessageVideoChatStarted | import("../3_types.js").MessageVideoChatEnded | import("../3_types.js").MessageGiveaway | import("../3_types.js").MessageUnsupported | {
24
- text: string;
25
- entities: NonNullable<MessageEntity | null>[];
26
- out: boolean;
27
- id: number;
28
- threadId?: number | undefined;
29
- from?: import("../3_types.js").User | undefined;
30
- senderChat?: import("../3_types.js").ChatP | undefined;
31
- date: Date;
32
- chat: import("../3_types.js").ChatP;
33
- link?: string | undefined;
34
- forwardFrom?: import("../3_types.js").User | undefined;
35
- forwardFromChat?: import("../3_types.js").ChatP | undefined;
36
- forwardId?: number | undefined;
37
- forwardSignature?: string | undefined;
38
- forwardSenderName?: string | undefined;
39
- forwardDate?: Date | undefined;
40
- isTopicMessage: boolean;
41
- isAutomaticForward?: boolean | undefined;
42
- replyToMessage?: Message | undefined;
43
- replyToMessageId?: number | undefined;
44
- reactions?: import("../3_types.js").MessageReaction[] | undefined;
45
- replyQuote?: import("../3_types.js").ReplyQuote | undefined;
46
- viaBot?: import("../3_types.js").User | undefined;
47
- editDate?: Date | undefined;
48
- hasProtectedContent?: boolean | undefined;
49
- mediaGroupId?: string | undefined;
50
- authorSignature?: string | undefined;
51
- views?: number | undefined;
52
- forwards?: number | undefined;
53
- replyMarkup?: import("../3_types.js").ReplyMarkup | undefined;
54
- }>;
21
+ constructMessage(message_: enums.Message, r?: boolean): Promise<Message>;
55
22
  forwardMessages(from: ID, to: ID, messageIds: number[], params?: ForwardMessagesParams): Promise<Message[]>;
56
23
  getHistory(chatId: ID, params?: GetHistoryParams): Promise<Message[]>;
57
24
  usernameResolver: UsernameResolver;
@@ -101,5 +68,11 @@ export declare class MessageManager {
101
68
  disableJoinRequests(chatId: ID): Promise<void>;
102
69
  searchMessages(chatId: ID, query: string, params?: SearchMessagesParams): Promise<Message[]>;
103
70
  setBoostsRequiredToCircumventRestrictions(chatId: ID, boosts: number): Promise<void>;
71
+ createInviteLink(chatId: ID, params?: CreateInviteLinkParams): Promise<import("../3_types.js").InviteLink>;
72
+ getCreatedInviteLinks(chatId: ID, params?: GetCreatedInviteLinksParams): Promise<import("../3_types.js").InviteLink[]>;
73
+ joinChat(chatId: ID): Promise<void>;
74
+ leaveChat(chatId: ID): Promise<void>;
75
+ blockUser(userId: ID): Promise<void>;
76
+ unblockUser(userId: ID): Promise<void>;
104
77
  }
105
78
  export {};
@@ -902,6 +902,78 @@ class MessageManager {
902
902
  const channel = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputChannel(chatId);
903
903
  await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.setBoostsToUnblockRestrictions({ channel, boosts });
904
904
  }
905
+ async createInviteLink(chatId, params) {
906
+ if (params?.requireApproval && params?.limit) {
907
+ throw new Error("createInviteLink: requireApproval cannot be true while limit is specified");
908
+ }
909
+ const result = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.exportChatInvite({
910
+ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
911
+ title: params?.title,
912
+ expire_date: params?.expireAt ? (0, _1_utilities_js_1.toUnixTimestamp)(params.expireAt) : undefined,
913
+ request_needed: params?.requireApproval ? true : undefined,
914
+ usage_limit: params?.limit,
915
+ });
916
+ return await (0, _3_types_js_1.constructInviteLink)(result[_2_tl_js_1.as](_2_tl_js_1.types.ChatInviteExported), __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity);
917
+ }
918
+ async getCreatedInviteLinks(chatId, params) {
919
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("getCreatedInviteLinks");
920
+ const { invites } = await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.getExportedChatInvites({
921
+ peer: await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId),
922
+ revoked: params?.revoked ? true : undefined,
923
+ admin_id: params?.by ? await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputUser(params.by) : new _2_tl_js_1.types.InputUserEmpty(),
924
+ limit: params?.limit ?? 100,
925
+ offset_date: params?.afterDate ? (0, _1_utilities_js_1.toUnixTimestamp)(params.afterDate) : undefined,
926
+ offset_link: params?.afterInviteLink,
927
+ });
928
+ return await Promise.all(invites.map((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.ChatInviteExported)).map((v) => (0, _3_types_js_1.constructInviteLink)(v, __classPrivateFieldGet(this, _MessageManager_c, "f").getEntity)));
929
+ }
930
+ async joinChat(chatId) {
931
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("joinChat");
932
+ const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
933
+ if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
934
+ throw new Error("joinChat: cannot join private chats");
935
+ }
936
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
937
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.joinChannel({ channel: new _2_tl_js_1.types.InputChannel(peer) });
938
+ }
939
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChat) {
940
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.addChatUser({ chat_id: peer.chat_id, user_id: new _2_tl_js_1.types.InputUserSelf(), fwd_limit: 0 }); // TODO: use potential high-level method for adding participants to chats
941
+ }
942
+ else {
943
+ (0, _1_utilities_js_1.UNREACHABLE)();
944
+ }
945
+ }
946
+ async leaveChat(chatId) {
947
+ const peer = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(chatId);
948
+ if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
949
+ throw new Error("leaveChat: cannot leave private chats");
950
+ }
951
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChannel) {
952
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.channels.leaveChannel({ channel: new _2_tl_js_1.types.InputChannel(peer) });
953
+ }
954
+ else if (peer instanceof _2_tl_js_1.types.InputPeerChat) {
955
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.messages.deleteChatUser({ chat_id: peer.chat_id, user_id: new _2_tl_js_1.types.InputUserSelf() }); // TODO: use potential high-level method for adding participants to chats
956
+ }
957
+ else {
958
+ (0, _1_utilities_js_1.UNREACHABLE)();
959
+ }
960
+ }
961
+ async blockUser(userId) {
962
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("blockUser");
963
+ const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
964
+ if (!(id instanceof _2_tl_js_1.types.User)) {
965
+ throw new Error("blockUser: only users can be blocked or unblocked");
966
+ }
967
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.contacts.block({ id });
968
+ }
969
+ async unblockUser(userId) {
970
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").storage.assertUser("unblockUser");
971
+ const id = await __classPrivateFieldGet(this, _MessageManager_c, "f").getInputPeer(userId);
972
+ if (!(id instanceof _2_tl_js_1.types.User)) {
973
+ throw new Error("unblockUser: only users can be blocked or unblocked");
974
+ }
975
+ await __classPrivateFieldGet(this, _MessageManager_c, "f").api.contacts.unblock({ id });
976
+ }
905
977
  }
906
978
  exports.MessageManager = MessageManager;
907
979
  _MessageManager_c = new WeakMap(), _MessageManager_LresolveFileId = new WeakMap(), _MessageManager_instances = new WeakSet(), _MessageManager_updatesToMessages = async function _MessageManager_updatesToMessages(chatId, updates) {