2023-09-03 02:37:51 +03:00
|
|
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging, @typescript-eslint/unified-signatures */
|
2021-04-08 12:19:38 +03:00
|
|
|
/* THIS FILE WAS AUTO-GENERATED */
|
2022-04-29 17:54:11 +03:00
|
|
|
import { Readable } from 'stream'
|
2023-06-05 03:30:48 +03:00
|
|
|
|
2023-09-24 04:10:18 +03:00
|
|
|
import {
|
|
|
|
BaseTelegramClient,
|
|
|
|
BaseTelegramClientOptions,
|
2023-10-05 04:00:58 +03:00
|
|
|
Long,
|
2023-09-24 04:10:18 +03:00
|
|
|
MaybeArray,
|
|
|
|
MaybeAsync,
|
|
|
|
PartialExcept,
|
|
|
|
PartialOnly,
|
|
|
|
tl,
|
|
|
|
} from '@mtcute/core'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { tdFileId } from '@mtcute/file-id'
|
|
|
|
|
2023-10-09 05:59:48 +03:00
|
|
|
import { _onAuthorization, AuthState, getAuthState } from './methods/auth/_state'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { checkPassword } from './methods/auth/check-password'
|
|
|
|
import { getPasswordHint } from './methods/auth/get-password-hint'
|
|
|
|
import { logOut } from './methods/auth/log-out'
|
|
|
|
import { recoverPassword } from './methods/auth/recover-password'
|
|
|
|
import { resendCode } from './methods/auth/resend-code'
|
2021-04-24 16:33:06 +03:00
|
|
|
import { run } from './methods/auth/run'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { sendCode } from './methods/auth/send-code'
|
|
|
|
import { sendRecoveryCode } from './methods/auth/send-recovery-code'
|
|
|
|
import { signIn } from './methods/auth/sign-in'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { signInBot } from './methods/auth/sign-in-bot'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { start } from './methods/auth/start'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { startTest } from './methods/auth/start-test'
|
2021-05-05 01:50:04 +03:00
|
|
|
import { answerCallbackQuery } from './methods/bots/answer-callback-query'
|
2021-04-28 23:00:51 +03:00
|
|
|
import { answerInlineQuery } from './methods/bots/answer-inline-query'
|
2022-10-30 20:51:50 +03:00
|
|
|
import { answerPreCheckoutQuery } from './methods/bots/answer-pre-checkout-query'
|
2021-06-26 19:45:06 +03:00
|
|
|
import { deleteMyCommands } from './methods/bots/delete-my-commands'
|
2023-10-04 23:34:55 +03:00
|
|
|
import { getBotInfo } from './methods/bots/get-bot-info'
|
2022-05-09 00:00:22 +03:00
|
|
|
import { getBotMenuButton } from './methods/bots/get-bot-menu-button'
|
2021-05-16 12:59:00 +03:00
|
|
|
import { getCallbackAnswer } from './methods/bots/get-callback-answer'
|
2023-09-24 01:32:22 +03:00
|
|
|
import { getGameHighScores, getInlineGameHighScores } from './methods/bots/get-game-high-scores'
|
2021-06-26 19:45:06 +03:00
|
|
|
import { getMyCommands } from './methods/bots/get-my-commands'
|
|
|
|
import { _normalizeCommandScope } from './methods/bots/normalize-command-scope'
|
2023-10-04 23:34:55 +03:00
|
|
|
import { setBotInfo } from './methods/bots/set-bot-info'
|
2022-05-09 00:00:22 +03:00
|
|
|
import { setBotMenuButton } from './methods/bots/set-bot-menu-button'
|
2021-05-16 02:21:59 +03:00
|
|
|
import { setGameScore, setInlineGameScore } from './methods/bots/set-game-score'
|
2021-06-26 19:45:06 +03:00
|
|
|
import { setMyCommands } from './methods/bots/set-my-commands'
|
2022-05-08 23:34:28 +03:00
|
|
|
import { setMyDefaultRights } from './methods/bots/set-my-default-rights'
|
2021-04-10 20:06:33 +03:00
|
|
|
import { addChatMembers } from './methods/chats/add-chat-members'
|
2021-04-10 20:30:28 +03:00
|
|
|
import { archiveChats } from './methods/chats/archive-chats'
|
2021-05-12 22:07:00 +03:00
|
|
|
import { banChatMember } from './methods/chats/ban-chat-member'
|
2021-04-10 20:56:09 +03:00
|
|
|
import { createChannel } from './methods/chats/create-channel'
|
2021-04-11 00:37:12 +03:00
|
|
|
import { createGroup } from './methods/chats/create-group'
|
2021-04-10 21:08:04 +03:00
|
|
|
import { createSupergroup } from './methods/chats/create-supergroup'
|
2021-04-10 20:56:09 +03:00
|
|
|
import { deleteChannel } from './methods/chats/delete-channel'
|
2021-04-11 15:22:48 +03:00
|
|
|
import { deleteChatPhoto } from './methods/chats/delete-chat-photo'
|
2021-04-11 00:37:12 +03:00
|
|
|
import { deleteGroup } from './methods/chats/delete-group'
|
|
|
|
import { deleteHistory } from './methods/chats/delete-history'
|
2021-05-10 14:27:57 +03:00
|
|
|
import { deleteUserHistory } from './methods/chats/delete-user-history'
|
2021-05-16 14:55:17 +03:00
|
|
|
import { editAdminRights } from './methods/chats/edit-admin-rights'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { getChat } from './methods/chats/get-chat'
|
2021-05-10 21:51:25 +03:00
|
|
|
import { getChatEventLog } from './methods/chats/get-chat-event-log'
|
2021-04-11 14:56:34 +03:00
|
|
|
import { getChatMember } from './methods/chats/get-chat-member'
|
2021-04-14 19:43:05 +03:00
|
|
|
import { getChatMembers } from './methods/chats/get-chat-members'
|
2021-04-10 17:11:25 +03:00
|
|
|
import { getChatPreview } from './methods/chats/get-chat-preview'
|
|
|
|
import { getFullChat } from './methods/chats/get-full-chat'
|
2021-05-10 22:51:35 +03:00
|
|
|
import { getNearbyChats } from './methods/chats/get-nearby-chats'
|
2023-09-29 17:02:36 +03:00
|
|
|
import { iterChatEventLog } from './methods/chats/iter-chat-event-log'
|
2021-04-14 19:43:05 +03:00
|
|
|
import { iterChatMembers } from './methods/chats/iter-chat-members'
|
2021-04-10 17:11:25 +03:00
|
|
|
import { joinChat } from './methods/chats/join-chat'
|
2021-05-12 22:07:00 +03:00
|
|
|
import { kickChatMember } from './methods/chats/kick-chat-member'
|
2021-04-11 00:37:12 +03:00
|
|
|
import { leaveChat } from './methods/chats/leave-chat'
|
2021-05-12 22:36:03 +03:00
|
|
|
import { markChatUnread } from './methods/chats/mark-chat-unread'
|
2023-10-03 03:23:23 +03:00
|
|
|
import { reorderUsernames } from './methods/chats/reorder-usernames'
|
2021-05-12 22:07:00 +03:00
|
|
|
import { restrictChatMember } from './methods/chats/restrict-chat-member'
|
2021-04-14 21:31:51 +03:00
|
|
|
import { saveDraft } from './methods/chats/save-draft'
|
2021-04-11 16:11:28 +03:00
|
|
|
import { setChatDefaultPermissions } from './methods/chats/set-chat-default-permissions'
|
2021-04-11 15:32:38 +03:00
|
|
|
import { setChatDescription } from './methods/chats/set-chat-description'
|
2021-04-11 15:22:48 +03:00
|
|
|
import { setChatPhoto } from './methods/chats/set-chat-photo'
|
2021-04-11 15:32:38 +03:00
|
|
|
import { setChatTitle } from './methods/chats/set-chat-title'
|
2023-10-03 04:05:24 +03:00
|
|
|
import { setChatTtl } from './methods/chats/set-chat-ttl'
|
2021-04-11 16:32:10 +03:00
|
|
|
import { setChatUsername } from './methods/chats/set-chat-username'
|
2021-04-11 16:11:28 +03:00
|
|
|
import { setSlowMode } from './methods/chats/set-slow-mode'
|
2023-10-03 03:48:52 +03:00
|
|
|
import { toggleContentProtection } from './methods/chats/toggle-content-protection'
|
2023-10-03 03:23:23 +03:00
|
|
|
import { toggleFragmentUsername } from './methods/chats/toggle-fragment-username'
|
2023-10-02 19:54:11 +03:00
|
|
|
import { toggleJoinRequests } from './methods/chats/toggle-join-requests'
|
|
|
|
import { toggleJoinToSend } from './methods/chats/toggle-join-to-send'
|
2021-04-10 20:30:28 +03:00
|
|
|
import { unarchiveChats } from './methods/chats/unarchive-chats'
|
2021-05-12 22:07:00 +03:00
|
|
|
import { unbanChatMember } from './methods/chats/unban-chat-member'
|
2021-04-25 17:10:37 +03:00
|
|
|
import { addContact } from './methods/contacts/add-contact'
|
|
|
|
import { deleteContacts } from './methods/contacts/delete-contacts'
|
|
|
|
import { getContacts } from './methods/contacts/get-contacts'
|
|
|
|
import { importContacts } from './methods/contacts/import-contacts'
|
2021-04-16 00:12:07 +03:00
|
|
|
import { createFolder } from './methods/dialogs/create-folder'
|
|
|
|
import { deleteFolder } from './methods/dialogs/delete-folder'
|
|
|
|
import { editFolder } from './methods/dialogs/edit-folder'
|
2021-04-24 19:27:14 +03:00
|
|
|
import { findFolder } from './methods/dialogs/find-folder'
|
2023-09-29 17:02:36 +03:00
|
|
|
import { _normalizeInputFolder, getFolders } from './methods/dialogs/get-folders'
|
2021-07-09 22:50:04 +03:00
|
|
|
import { getPeerDialogs } from './methods/dialogs/get-peer-dialogs'
|
2023-09-29 17:02:36 +03:00
|
|
|
import { iterDialogs } from './methods/dialogs/iter-dialogs'
|
2023-10-07 00:22:08 +03:00
|
|
|
import { setFoldersOrder } from './methods/dialogs/set-folders-order'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { downloadAsBuffer } from './methods/files/download-buffer'
|
|
|
|
import { downloadToFile } from './methods/files/download-file'
|
|
|
|
import { downloadAsIterable } from './methods/files/download-iterable'
|
|
|
|
import { downloadAsStream } from './methods/files/download-stream'
|
2021-05-05 23:26:28 +03:00
|
|
|
import { _normalizeFileToDocument } from './methods/files/normalize-file-to-document'
|
2021-04-30 23:57:24 +03:00
|
|
|
import { _normalizeInputFile } from './methods/files/normalize-input-file'
|
|
|
|
import { _normalizeInputMedia } from './methods/files/normalize-input-media'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { uploadFile } from './methods/files/upload-file'
|
2021-07-02 17:04:45 +03:00
|
|
|
import { uploadMedia } from './methods/files/upload-media'
|
2023-10-03 00:58:45 +03:00
|
|
|
import { createForumTopic } from './methods/forums/create-forum-topic'
|
|
|
|
import { deleteForumTopicHistory } from './methods/forums/delete-forum-topic-history'
|
|
|
|
import { editForumTopic } from './methods/forums/edit-forum-topic'
|
|
|
|
import { getForumTopics, GetForumTopicsOffset } from './methods/forums/get-forum-topics'
|
|
|
|
import { getForumTopicsById } from './methods/forums/get-forum-topics-by-id'
|
|
|
|
import { iterForumTopics } from './methods/forums/iter-forum-topics'
|
|
|
|
import { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-topics'
|
|
|
|
import { toggleForum } from './methods/forums/toggle-forum'
|
|
|
|
import { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed'
|
|
|
|
import { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned'
|
|
|
|
import { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden'
|
2021-05-10 00:35:29 +03:00
|
|
|
import { createInviteLink } from './methods/invite-links/create-invite-link'
|
|
|
|
import { editInviteLink } from './methods/invite-links/edit-invite-link'
|
|
|
|
import { exportInviteLink } from './methods/invite-links/export-invite-link'
|
|
|
|
import { getInviteLink } from './methods/invite-links/get-invite-link'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { getInviteLinkMembers } from './methods/invite-links/get-invite-link-members'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { getInviteLinks, GetInviteLinksOffset } from './methods/invite-links/get-invite-links'
|
2021-05-10 00:35:29 +03:00
|
|
|
import { getPrimaryInviteLink } from './methods/invite-links/get-primary-invite-link'
|
2022-05-09 17:25:38 +03:00
|
|
|
import { hideAllJoinRequests } from './methods/invite-links/hide-all-join-requests'
|
|
|
|
import { hideJoinRequest } from './methods/invite-links/hide-join-request'
|
2023-09-29 17:02:36 +03:00
|
|
|
import { iterInviteLinkMembers } from './methods/invite-links/iter-invite-link-members'
|
|
|
|
import { iterInviteLinks } from './methods/invite-links/iter-invite-links'
|
2021-05-10 00:35:29 +03:00
|
|
|
import { revokeInviteLink } from './methods/invite-links/revoke-invite-link'
|
2021-05-08 13:19:37 +03:00
|
|
|
import { closePoll } from './methods/messages/close-poll'
|
2023-10-09 21:44:38 +03:00
|
|
|
import { deleteMessages, deleteMessagesById, DeleteMessagesParams } from './methods/messages/delete-messages'
|
2021-07-10 15:00:40 +03:00
|
|
|
import { deleteScheduledMessages } from './methods/messages/delete-scheduled-messages'
|
2021-05-04 14:07:40 +03:00
|
|
|
import { editInlineMessage } from './methods/messages/edit-inline-message'
|
2021-04-09 23:19:58 +03:00
|
|
|
import { editMessage } from './methods/messages/edit-message'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { _findMessageInUpdate } from './methods/messages/find-in-update'
|
2023-10-09 21:44:38 +03:00
|
|
|
import { ForwardMessageOptions, forwardMessages, forwardMessagesById } from './methods/messages/forward-messages'
|
2023-09-24 01:32:22 +03:00
|
|
|
import { _getDiscussionMessage, getDiscussionMessage } from './methods/messages/get-discussion-message'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { getHistory, GetHistoryOffset } from './methods/messages/get-history'
|
2021-05-09 18:29:33 +03:00
|
|
|
import { getMessageGroup } from './methods/messages/get-message-group'
|
2023-10-09 21:44:38 +03:00
|
|
|
import { getMessageReactions, getMessageReactionsById } from './methods/messages/get-message-reactions'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { getMessages } from './methods/messages/get-messages'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { getMessagesUnsafe } from './methods/messages/get-messages-unsafe'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { getReactionUsers, GetReactionUsersOffset } from './methods/messages/get-reaction-users'
|
2021-07-10 01:19:59 +03:00
|
|
|
import { getScheduledMessages } from './methods/messages/get-scheduled-messages'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { iterHistory } from './methods/messages/iter-history'
|
|
|
|
import { iterReactionUsers } from './methods/messages/iter-reaction-users'
|
|
|
|
import { iterSearchGlobal } from './methods/messages/iter-search-global'
|
|
|
|
import { iterSearchMessages } from './methods/messages/iter-search-messages'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { _parseEntities } from './methods/messages/parse-entities'
|
2021-04-11 16:25:17 +03:00
|
|
|
import { pinMessage } from './methods/messages/pin-message'
|
2021-05-12 22:31:29 +03:00
|
|
|
import { readHistory } from './methods/messages/read-history'
|
2022-05-12 10:09:37 +03:00
|
|
|
import { readReactions } from './methods/messages/read-reactions'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { searchGlobal, SearchGlobalOffset } from './methods/messages/search-global'
|
|
|
|
import { searchMessages, SearchMessagesOffset } from './methods/messages/search-messages'
|
2023-10-09 21:44:38 +03:00
|
|
|
import { sendCopy, SendCopyParams } from './methods/messages/send-copy'
|
2021-04-10 13:28:02 +03:00
|
|
|
import { sendMedia } from './methods/messages/send-media'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { sendMediaGroup } from './methods/messages/send-media-group'
|
2022-05-12 10:09:37 +03:00
|
|
|
import { sendReaction } from './methods/messages/send-reaction'
|
2021-07-10 01:19:59 +03:00
|
|
|
import { sendScheduled } from './methods/messages/send-scheduled'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { sendText } from './methods/messages/send-text'
|
2021-05-08 17:54:18 +03:00
|
|
|
import { sendTyping } from './methods/messages/send-typing'
|
2021-05-08 12:36:15 +03:00
|
|
|
import { sendVote } from './methods/messages/send-vote'
|
2022-04-29 17:54:11 +03:00
|
|
|
import { translateMessage } from './methods/messages/translate-message'
|
|
|
|
import { translateText } from './methods/messages/translate-text'
|
2021-05-12 22:18:08 +03:00
|
|
|
import { unpinAllMessages } from './methods/messages/unpin-all-messages'
|
2021-04-11 16:25:17 +03:00
|
|
|
import { unpinMessage } from './methods/messages/unpin-message'
|
2021-04-24 21:11:34 +03:00
|
|
|
import { initTakeoutSession } from './methods/misc/init-takeout-session'
|
2023-10-04 19:26:21 +03:00
|
|
|
import { _normalizePrivacyRules } from './methods/misc/normalize-privacy-rules'
|
2023-10-09 05:59:48 +03:00
|
|
|
import { getParseModesState, ParseModesState } from './methods/parse-modes/_state'
|
2021-04-08 12:19:38 +03:00
|
|
|
import {
|
|
|
|
getParseMode,
|
|
|
|
registerParseMode,
|
|
|
|
setDefaultParseMode,
|
|
|
|
unregisterParseMode,
|
|
|
|
} from './methods/parse-modes/parse-modes'
|
2023-10-09 05:59:48 +03:00
|
|
|
import { changeCloudPassword } from './methods/password/change-cloud-password'
|
|
|
|
import { enableCloudPassword } from './methods/password/enable-cloud-password'
|
|
|
|
import { cancelPasswordEmail, resendPasswordEmail, verifyPasswordEmail } from './methods/password/password-email'
|
|
|
|
import { removeCloudPassword } from './methods/password/remove-cloud-password'
|
2021-05-05 23:26:28 +03:00
|
|
|
import { addStickerToSet } from './methods/stickers/add-sticker-to-set'
|
|
|
|
import { createStickerSet } from './methods/stickers/create-sticker-set'
|
|
|
|
import { deleteStickerFromSet } from './methods/stickers/delete-sticker-from-set'
|
2022-08-18 19:52:24 +03:00
|
|
|
import { getCustomEmojis } from './methods/stickers/get-custom-emojis'
|
2021-04-25 15:39:42 +03:00
|
|
|
import { getInstalledStickers } from './methods/stickers/get-installed-stickers'
|
|
|
|
import { getStickerSet } from './methods/stickers/get-sticker-set'
|
2021-05-05 23:26:28 +03:00
|
|
|
import { moveStickerInSet } from './methods/stickers/move-sticker-in-set'
|
2023-10-04 23:34:55 +03:00
|
|
|
import { setChatStickerSet } from './methods/stickers/set-chat-sticker-set'
|
2021-05-06 12:11:09 +03:00
|
|
|
import { setStickerSetThumb } from './methods/stickers/set-sticker-set-thumb'
|
2023-10-04 19:26:21 +03:00
|
|
|
import { applyBoost } from './methods/stories/apply-boost'
|
|
|
|
import { canApplyBoost, CanApplyBoostResult } from './methods/stories/can-apply-boost'
|
|
|
|
import { canSendStory, CanSendStoryResult } from './methods/stories/can-send-story'
|
|
|
|
import { deleteStories } from './methods/stories/delete-stories'
|
|
|
|
import { editStory } from './methods/stories/edit-story'
|
|
|
|
import { _findStoryInUpdate } from './methods/stories/find-in-update'
|
|
|
|
import { getAllStories } from './methods/stories/get-all-stories'
|
|
|
|
import { getBoostStats } from './methods/stories/get-boost-stats'
|
|
|
|
import { getBoosters } from './methods/stories/get-boosters'
|
|
|
|
import { getPeerStories } from './methods/stories/get-peer-stories'
|
|
|
|
import { getProfileStories } from './methods/stories/get-profile-stories'
|
|
|
|
import { getStoriesById } from './methods/stories/get-stories-by-id'
|
|
|
|
import { getStoriesInteractions } from './methods/stories/get-stories-interactions'
|
|
|
|
import { getStoryLink } from './methods/stories/get-story-link'
|
|
|
|
import { getStoryViewers } from './methods/stories/get-story-viewers'
|
|
|
|
import { hideMyStoriesViews } from './methods/stories/hide-my-stories-views'
|
|
|
|
import { incrementStoriesViews } from './methods/stories/increment-stories-views'
|
|
|
|
import { iterAllStories } from './methods/stories/iter-all-stories'
|
|
|
|
import { iterBoosters } from './methods/stories/iter-boosters'
|
|
|
|
import { iterProfileStories } from './methods/stories/iter-profile-stories'
|
|
|
|
import { iterStoryViewers } from './methods/stories/iter-story-viewers'
|
|
|
|
import { readStories } from './methods/stories/read-stories'
|
|
|
|
import { reportStory } from './methods/stories/report-story'
|
|
|
|
import { sendStory } from './methods/stories/send-story'
|
|
|
|
import { sendStoryReaction } from './methods/stories/send-story-reaction'
|
|
|
|
import { togglePeerStoriesArchived } from './methods/stories/toggle-peer-stories-archived'
|
|
|
|
import { toggleStoriesPinned } from './methods/stories/toggle-stories-pinned'
|
2023-10-09 05:59:48 +03:00
|
|
|
import { enableUpdatesProcessing, makeParsedUpdateHandler, ParsedUpdateHandlerParams } from './methods/updates'
|
2021-04-18 16:23:25 +03:00
|
|
|
import {
|
|
|
|
catchUp,
|
2021-11-23 00:03:59 +03:00
|
|
|
enableRps,
|
|
|
|
getCurrentRpsIncoming,
|
|
|
|
getCurrentRpsProcessing,
|
|
|
|
startUpdatesLoop,
|
|
|
|
stopUpdatesLoop,
|
2023-10-09 05:59:48 +03:00
|
|
|
} from './methods/updates/manager'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { blockUser } from './methods/users/block-user'
|
2021-05-09 14:35:58 +03:00
|
|
|
import { deleteProfilePhotos } from './methods/users/delete-profile-photos'
|
2023-10-04 20:50:57 +03:00
|
|
|
import { editCloseFriends, editCloseFriendsRaw } from './methods/users/edit-close-friends'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { getCommonChats } from './methods/users/get-common-chats'
|
2023-10-03 04:05:24 +03:00
|
|
|
import { getGlobalTtl } from './methods/users/get-global-ttl'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { getMe } from './methods/users/get-me'
|
2021-07-05 17:26:30 +03:00
|
|
|
import { getMyUsername } from './methods/users/get-my-username'
|
2023-10-02 18:00:00 +03:00
|
|
|
import { getProfilePhoto } from './methods/users/get-profile-photo'
|
2021-05-09 14:35:58 +03:00
|
|
|
import { getProfilePhotos } from './methods/users/get-profile-photos'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { getUsers } from './methods/users/get-users'
|
2021-05-09 14:35:58 +03:00
|
|
|
import { iterProfilePhotos } from './methods/users/iter-profile-photos'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { resolvePeer } from './methods/users/resolve-peer'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { resolvePeerMany } from './methods/users/resolve-peer-many'
|
2023-10-04 21:05:07 +03:00
|
|
|
import { setEmojiStatus } from './methods/users/set-emoji-status'
|
2023-10-03 04:05:24 +03:00
|
|
|
import { setGlobalTtl } from './methods/users/set-global-ttl'
|
2021-05-08 16:35:25 +03:00
|
|
|
import { setOffline } from './methods/users/set-offline'
|
2021-05-09 14:35:58 +03:00
|
|
|
import { setProfilePhoto } from './methods/users/set-profile-photo'
|
2023-10-03 03:23:23 +03:00
|
|
|
import { setUsername } from './methods/users/set-username'
|
2021-05-09 14:35:58 +03:00
|
|
|
import { unblockUser } from './methods/users/unblock-user'
|
|
|
|
import { updateProfile } from './methods/users/update-profile'
|
2023-06-05 03:30:48 +03:00
|
|
|
import {
|
2023-10-04 19:26:21 +03:00
|
|
|
AllStories,
|
2023-09-29 21:45:11 +03:00
|
|
|
ArrayPaginated,
|
2023-06-05 03:30:48 +03:00
|
|
|
ArrayWithTotal,
|
2023-10-04 19:26:21 +03:00
|
|
|
Booster,
|
|
|
|
BoostStats,
|
2023-06-05 03:30:48 +03:00
|
|
|
BotChatJoinRequestUpdate,
|
|
|
|
BotCommands,
|
|
|
|
BotStoppedUpdate,
|
|
|
|
CallbackQuery,
|
|
|
|
Chat,
|
|
|
|
ChatEvent,
|
|
|
|
ChatInviteLink,
|
2023-09-29 17:02:36 +03:00
|
|
|
ChatInviteLinkMember,
|
2023-06-05 03:30:48 +03:00
|
|
|
ChatJoinRequestUpdate,
|
|
|
|
ChatMember,
|
|
|
|
ChatMemberUpdate,
|
|
|
|
ChatPreview,
|
|
|
|
ChosenInlineResult,
|
|
|
|
DeleteMessageUpdate,
|
2023-10-04 20:50:57 +03:00
|
|
|
DeleteStoryUpdate,
|
2023-06-05 03:30:48 +03:00
|
|
|
Dialog,
|
|
|
|
FileDownloadParameters,
|
|
|
|
FormattedString,
|
2023-10-03 00:58:45 +03:00
|
|
|
ForumTopic,
|
2023-06-05 03:30:48 +03:00
|
|
|
GameHighScore,
|
|
|
|
HistoryReadUpdate,
|
|
|
|
IMessageEntityParser,
|
|
|
|
InlineQuery,
|
2023-09-29 17:02:36 +03:00
|
|
|
InputChatEventFilters,
|
|
|
|
InputDialogFolder,
|
2023-06-05 03:30:48 +03:00
|
|
|
InputFileLike,
|
|
|
|
InputInlineResult,
|
|
|
|
InputMediaLike,
|
2023-10-09 21:44:38 +03:00
|
|
|
InputMessageId,
|
2023-06-05 03:30:48 +03:00
|
|
|
InputPeerLike,
|
2023-10-04 19:26:21 +03:00
|
|
|
InputPrivacyRule,
|
2023-10-01 16:36:29 +03:00
|
|
|
InputReaction,
|
2023-10-04 23:34:55 +03:00
|
|
|
InputStickerSet,
|
2023-06-05 03:30:48 +03:00
|
|
|
InputStickerSetItem,
|
|
|
|
MaybeDynamic,
|
|
|
|
Message,
|
2023-07-20 19:01:34 +03:00
|
|
|
MessageEntity,
|
2023-06-05 03:30:48 +03:00
|
|
|
MessageMedia,
|
|
|
|
MessageReactions,
|
|
|
|
ParsedUpdate,
|
|
|
|
PeerReaction,
|
|
|
|
PeersIndex,
|
2023-10-04 19:26:21 +03:00
|
|
|
PeerStories,
|
2023-06-05 03:30:48 +03:00
|
|
|
Photo,
|
|
|
|
Poll,
|
|
|
|
PollUpdate,
|
|
|
|
PollVoteUpdate,
|
|
|
|
PreCheckoutQuery,
|
|
|
|
RawDocument,
|
|
|
|
ReplyMarkup,
|
|
|
|
SentCode,
|
|
|
|
Sticker,
|
|
|
|
StickerSet,
|
|
|
|
StickerSourceType,
|
|
|
|
StickerType,
|
2023-10-04 19:26:21 +03:00
|
|
|
StoriesStealthMode,
|
|
|
|
Story,
|
|
|
|
StoryInteractions,
|
2023-10-04 20:50:57 +03:00
|
|
|
StoryUpdate,
|
2023-10-04 19:26:21 +03:00
|
|
|
StoryViewer,
|
|
|
|
StoryViewersList,
|
2023-06-05 03:30:48 +03:00
|
|
|
TakeoutSession,
|
|
|
|
TypingStatus,
|
|
|
|
UploadedFile,
|
|
|
|
UploadFileLike,
|
|
|
|
User,
|
|
|
|
UserStatusUpdate,
|
|
|
|
UserTypingUpdate,
|
|
|
|
} from './types'
|
2023-10-09 05:59:48 +03:00
|
|
|
import { Conversation } from './types/conversation'
|
2021-04-08 12:19:38 +03:00
|
|
|
|
2023-10-09 05:59:48 +03:00
|
|
|
// from methods/_init.ts
|
2023-10-06 01:47:45 +03:00
|
|
|
interface TelegramClientOptions extends BaseTelegramClientOptions {
|
|
|
|
/**
|
2023-10-09 05:59:48 +03:00
|
|
|
* Parameters for updates manager.
|
2023-10-06 01:47:45 +03:00
|
|
|
*/
|
2023-10-09 05:59:48 +03:00
|
|
|
updates?: Omit<ParsedUpdateHandlerParams, 'onUpdate' | 'onRawUpdate'>
|
2021-11-23 00:03:59 +03:00
|
|
|
}
|
|
|
|
|
2021-04-18 16:59:05 +03:00
|
|
|
export interface TelegramClient extends BaseTelegramClient {
|
2021-07-17 17:26:31 +03:00
|
|
|
/**
|
|
|
|
* Register a raw update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Raw update handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'raw_update', handler: (upd: tl.TypeUpdate | tl.TypeMessage, peers: PeersIndex) => void): this
|
2021-07-17 17:26:31 +03:00
|
|
|
/**
|
|
|
|
* Register a parsed update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Raw update handler
|
|
|
|
*/
|
|
|
|
on(name: 'update', handler: (upd: ParsedUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register a new message handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler New message handler
|
|
|
|
*/
|
|
|
|
on(name: 'new_message', handler: (upd: Message) => void): this
|
|
|
|
/**
|
|
|
|
* Register an edit message handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Edit message handler
|
|
|
|
*/
|
|
|
|
on(name: 'edit_message', handler: (upd: Message) => void): this
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Register a message group handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Message group handler
|
|
|
|
*/
|
|
|
|
on(name: 'message_group', handler: (upd: Message[]) => void): this
|
2021-07-17 17:26:31 +03:00
|
|
|
/**
|
|
|
|
* Register a delete message handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Delete message handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'delete_message', handler: (upd: DeleteMessageUpdate) => void): this
|
2021-07-17 17:26:31 +03:00
|
|
|
/**
|
|
|
|
* Register a chat member update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Chat member update handler
|
|
|
|
*/
|
|
|
|
on(name: 'chat_member', handler: (upd: ChatMemberUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register an inline query handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Inline query handler
|
|
|
|
*/
|
|
|
|
on(name: 'inline_query', handler: (upd: InlineQuery) => void): this
|
|
|
|
/**
|
|
|
|
* Register a chosen inline result handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Chosen inline result handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'chosen_inline_result', handler: (upd: ChosenInlineResult) => void): this
|
2021-07-17 17:26:31 +03:00
|
|
|
/**
|
|
|
|
* Register a callback query handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Callback query handler
|
|
|
|
*/
|
|
|
|
on(name: 'callback_query', handler: (upd: CallbackQuery) => void): this
|
|
|
|
/**
|
|
|
|
* Register a poll update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Poll update handler
|
|
|
|
*/
|
|
|
|
on(name: 'poll', handler: (upd: PollUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register a poll vote handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Poll vote handler
|
|
|
|
*/
|
|
|
|
on(name: 'poll_vote', handler: (upd: PollVoteUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register an user status update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler User status update handler
|
|
|
|
*/
|
|
|
|
on(name: 'user_status', handler: (upd: UserStatusUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register an user typing handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler User typing handler
|
|
|
|
*/
|
|
|
|
on(name: 'user_typing', handler: (upd: UserTypingUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register a history read handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler History read handler
|
|
|
|
*/
|
|
|
|
on(name: 'history_read', handler: (upd: HistoryReadUpdate) => void): this
|
2021-08-05 20:14:19 +03:00
|
|
|
/**
|
|
|
|
* Register a bot stopped handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Bot stopped handler
|
|
|
|
*/
|
|
|
|
on(name: 'bot_stopped', handler: (upd: BotStoppedUpdate) => void): this
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Register a bot chat join request handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Bot chat join request handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'bot_chat_join_request', handler: (upd: BotChatJoinRequestUpdate) => void): this
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Register a chat join request handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Chat join request handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'chat_join_request', handler: (upd: ChatJoinRequestUpdate) => void): this
|
2022-10-30 20:51:50 +03:00
|
|
|
/**
|
|
|
|
* Register a pre checkout query handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Pre checkout query handler
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
on(name: 'pre_checkout_query', handler: (upd: PreCheckoutQuery) => void): this
|
2023-10-04 20:50:57 +03:00
|
|
|
/**
|
|
|
|
* Register a story update handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Story update handler
|
|
|
|
*/
|
|
|
|
on(name: 'story', handler: (upd: StoryUpdate) => void): this
|
|
|
|
/**
|
|
|
|
* Register a delete story handler
|
|
|
|
*
|
|
|
|
* @param name Event name
|
|
|
|
* @param handler Delete story handler
|
|
|
|
*/
|
|
|
|
on(name: 'delete_story', handler: (upd: DeleteStoryUpdate) => void): this
|
2023-10-07 00:22:08 +03:00
|
|
|
|
2023-10-09 05:59:48 +03:00
|
|
|
getAuthState(): AuthState
|
|
|
|
|
|
|
|
_onAuthorization(auth: tl.auth.TypeAuthorization, bot?: boolean): User
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Check your Two-Step verification password and log in
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param password Your Two-Step verification password
|
|
|
|
* @returns The authorized user
|
|
|
|
* @throws BadRequestError In case the password is invalid
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
checkPassword(password: string): Promise<User>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get your Two-Step Verification password hint.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @returns The password hint as a string, if any
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getPasswordHint(): Promise<string | null>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Log out from Telegram account and optionally reset the session storage.
|
|
|
|
*
|
|
|
|
* When you log out, you can immediately log back in using
|
|
|
|
* the same {@link TelegramClient} instance.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @returns On success, `true` is returned
|
|
|
|
*/
|
2021-07-05 17:26:30 +03:00
|
|
|
logOut(): Promise<true>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Recover your password with a recovery code and log in.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @returns The authorized user
|
|
|
|
* @throws BadRequestError In case the code is invalid
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
recoverPassword(params: {
|
|
|
|
/** The recovery code sent via email */
|
|
|
|
recoveryCode: string
|
|
|
|
}): Promise<User>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Re-send the confirmation code using a different type.
|
|
|
|
*
|
|
|
|
* The type of the code to be re-sent is specified in the `nextType` attribute of
|
|
|
|
* {@link SentCode} object returned by {@link sendCode}
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
resendCode(params: {
|
|
|
|
/** Phone number in international format */
|
|
|
|
phone: string
|
|
|
|
|
|
|
|
/** Confirmation code identifier from {@link SentCode} */
|
|
|
|
phoneCodeHash: string
|
|
|
|
}): Promise<SentCode>
|
2021-04-24 16:33:06 +03:00
|
|
|
/**
|
|
|
|
* Simple wrapper that calls {@link start} and then
|
|
|
|
* provided callback function (if any) without the
|
|
|
|
* need to introduce a `main()` function manually.
|
|
|
|
*
|
|
|
|
* Errors that were encountered while calling {@link start}
|
|
|
|
* and `then` will be emitted as usual, and can be caught with {@link onError}
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* @param params Parameters to be passed to {@link start}
|
|
|
|
* @param then Function to be called after {@link start} returns
|
2021-04-24 16:33:06 +03:00
|
|
|
*/
|
2023-10-09 05:59:48 +03:00
|
|
|
run(params: Parameters<typeof start>[1], then?: (user: User) => void | Promise<void>): void
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Send the confirmation code to the given phone number
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @returns An object containing information about the sent confirmation code
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
sendCode(params: {
|
|
|
|
/** Phone number in international format */
|
|
|
|
phone: string
|
|
|
|
}): Promise<SentCode>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Send a code to email needed to recover your password
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @returns String containing email pattern to which the recovery code was sent
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
sendRecoveryCode(): Promise<string>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Authorize a bot using its token issued by [@BotFather](//t.me/BotFather)
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param token Bot token issued by BotFather
|
|
|
|
* @returns Bot's {@link User} object
|
|
|
|
* @throws BadRequestError In case the bot token is invalid
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
signInBot(token: string): Promise<User>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Authorize a user in Telegram with a valid confirmation code.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @returns If the code was valid and authorization succeeded, the {@link User} is returned.
|
|
|
|
* @throws BadRequestError In case the arguments are invalid
|
|
|
|
* @throws SessionPasswordNeededError In case a password is needed to sign in
|
|
|
|
*/
|
|
|
|
signIn(params: {
|
|
|
|
/** Phone number in international format */
|
|
|
|
phone: string
|
|
|
|
/** Code identifier from {@link sendCode} */
|
|
|
|
phoneCodeHash: string
|
|
|
|
/** The confirmation code that was received */
|
|
|
|
phoneCode: string
|
|
|
|
}): Promise<User>
|
2021-04-17 10:05:31 +03:00
|
|
|
/**
|
|
|
|
* Utility function to quickly authorize on test DC
|
|
|
|
* using a [Test phone number](https://core.telegram.org/api/auth#test-phone-numbers),
|
|
|
|
* which is randomly generated by default.
|
|
|
|
*
|
|
|
|
* > **Note**: Using this method assumes that you
|
|
|
|
* > are using a test DC in `primaryDc` parameter.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-17 10:05:31 +03:00
|
|
|
* @param params Additional parameters
|
|
|
|
*/
|
|
|
|
startTest(params?: {
|
|
|
|
/**
|
|
|
|
* Whether to log out if current session is logged in.
|
|
|
|
*
|
|
|
|
* Defaults to false.
|
|
|
|
*/
|
|
|
|
logout?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override phone number. Must be a valid Test phone number.
|
|
|
|
*
|
|
|
|
* By default is randomly generated.
|
|
|
|
*/
|
|
|
|
phone?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override user's DC. Must be a valid test DC.
|
|
|
|
*/
|
|
|
|
dcId?: number
|
2021-04-18 16:59:05 +03:00
|
|
|
}): Promise<User>
|
2023-10-05 04:00:58 +03:00
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Start the client in an interactive and declarative manner,
|
|
|
|
* by providing callbacks for authorization details.
|
|
|
|
*
|
|
|
|
* This method handles both login and sign up, and also handles 2FV
|
|
|
|
*
|
|
|
|
* All parameters are `MaybeDynamic<T>`, meaning you
|
|
|
|
* can either supply `T`, or a function that returns `MaybeAsync<T>`
|
|
|
|
*
|
|
|
|
* This method is intended for simple and fast use in automated
|
|
|
|
* scripts and bots. If you are developing a custom client,
|
|
|
|
* you'll probably need to use other auth methods.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
|
|
|
start(params: {
|
2021-06-05 20:25:08 +03:00
|
|
|
/**
|
|
|
|
* String session exported using {@link TelegramClient.exportSession}.
|
|
|
|
*
|
|
|
|
* This simply calls {@link TelegramClient.importSession} before anything else.
|
|
|
|
*
|
|
|
|
* Note that passed session will be ignored in case storage already
|
|
|
|
* contains authorization.
|
|
|
|
*/
|
|
|
|
session?: string
|
|
|
|
|
2022-07-31 08:01:40 +03:00
|
|
|
/**
|
|
|
|
* Whether to overwrite existing session.
|
|
|
|
*/
|
|
|
|
sessionForce?: boolean
|
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Phone number of the account.
|
|
|
|
* If account does not exist, it will be created
|
|
|
|
*/
|
|
|
|
phone?: MaybeDynamic<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bot token to use. Ignored if `phone` is supplied.
|
|
|
|
*/
|
|
|
|
botToken?: MaybeDynamic<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2FA password. Ignored if `botToken` is supplied
|
|
|
|
*/
|
|
|
|
password?: MaybeDynamic<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Code sent to the phone (either sms, call, flash call or other).
|
|
|
|
* Ignored if `botToken` is supplied, must be present if `phone` is supplied.
|
|
|
|
*/
|
|
|
|
code?: MaybeDynamic<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If passed, this function will be called if provided code or 2FA password
|
|
|
|
* was invalid. New code/password will be requested later.
|
|
|
|
*
|
|
|
|
* If provided `code`/`password` is a constant string, providing an
|
|
|
|
* invalid one will interrupt authorization flow.
|
|
|
|
*/
|
|
|
|
invalidCodeCallback?: (type: 'code' | 'password') => MaybeAsync<void>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to force code delivery through SMS
|
|
|
|
*/
|
|
|
|
forceSms?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom method that is called when a code is sent. Can be used
|
|
|
|
* to show a GUI alert of some kind.
|
2021-07-27 15:32:18 +03:00
|
|
|
* Defaults to `console.log`.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* This method is called *before* {@link start.params.code}.
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
|
|
|
* @param code
|
|
|
|
*/
|
|
|
|
codeSentCallback?: (code: SentCode) => MaybeAsync<void>
|
2021-04-18 16:59:05 +03:00
|
|
|
}): Promise<User>
|
2021-05-05 01:50:04 +03:00
|
|
|
/**
|
|
|
|
* Send an answer to a callback query.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* @param queryId ID of the callback query, or the query itself
|
2021-05-05 01:50:04 +03:00
|
|
|
* @param params Parameters of the answer
|
|
|
|
*/
|
|
|
|
answerCallbackQuery(
|
2023-10-09 21:44:38 +03:00
|
|
|
queryId: Long | CallbackQuery,
|
2021-05-05 01:50:04 +03:00
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Maximum amount of time in seconds for which
|
|
|
|
* this result can be cached by the client (not server!).
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @default 0
|
2021-05-05 01:50:04 +03:00
|
|
|
*/
|
|
|
|
cacheTime?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text of the notification (0-200 chars).
|
|
|
|
*
|
|
|
|
* If not set, nothing will be displayed
|
|
|
|
*/
|
|
|
|
text?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to show an alert in the middle of the screen
|
|
|
|
* instead of a notification at the top of the screen.
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @default false
|
2021-05-05 01:50:04 +03:00
|
|
|
*/
|
|
|
|
alert?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* URL that the client should open.
|
|
|
|
*
|
|
|
|
* If this was a button containing a game,
|
|
|
|
* you can provide arbitrary link to your game.
|
|
|
|
* Otherwise, you can only use links in the format
|
|
|
|
* `t.me/your_bot?start=...` that open your bot
|
|
|
|
* with a deep-link parameter.
|
|
|
|
*/
|
|
|
|
url?: string
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-05 01:50:04 +03:00
|
|
|
): Promise<void>
|
2021-04-28 23:00:51 +03:00
|
|
|
/**
|
|
|
|
* Answer an inline query.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-28 23:00:51 +03:00
|
|
|
* @param queryId Inline query ID
|
|
|
|
* @param results Results of the query
|
|
|
|
* @param params Additional parameters
|
|
|
|
*/
|
|
|
|
answerInlineQuery(
|
2023-10-09 21:44:38 +03:00
|
|
|
queryId: tl.Long | InlineQuery,
|
2021-04-28 23:00:51 +03:00
|
|
|
results: InputInlineResult[],
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Maximum number of time in seconds that the results of the
|
|
|
|
* query may be cached on the server for.
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @default 300
|
2021-04-28 23:00:51 +03:00
|
|
|
*/
|
|
|
|
cacheTime?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the results should be displayed as a gallery instead
|
|
|
|
* of a vertical list. Only applicable to some media types.
|
|
|
|
*
|
2022-07-23 01:29:36 +03:00
|
|
|
* In some cases changing this may lead to the results not being
|
|
|
|
* displayed by the client.
|
|
|
|
*
|
|
|
|
* Default is derived automatically based on result types
|
2021-04-28 23:00:51 +03:00
|
|
|
*/
|
|
|
|
gallery?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the results should only be cached on the server
|
|
|
|
* for the user who sent the query.
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @default false
|
2021-04-28 23:00:51 +03:00
|
|
|
*/
|
|
|
|
private?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Next pagination offset (up to 64 bytes).
|
|
|
|
*
|
|
|
|
* When user has reached the end of the current results,
|
2023-10-07 00:22:08 +03:00
|
|
|
* the client will re-send the inline query with the same text, but
|
2021-04-28 23:00:51 +03:00
|
|
|
* with `offset` set to this value.
|
|
|
|
*
|
|
|
|
* If omitted or empty string is provided, it is assumed that
|
|
|
|
* there are no more results.
|
|
|
|
*/
|
|
|
|
nextOffset?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If passed, clients will display a button before any other results,
|
|
|
|
* that when clicked switches the user to a private chat with the bot
|
|
|
|
* and sends the bot `/start ${parameter}`.
|
|
|
|
*
|
|
|
|
* An example from the Bot API docs:
|
|
|
|
*
|
|
|
|
* An inline bot that sends YouTube videos can ask the user to connect
|
|
|
|
* the bot to their YouTube account to adapt search results accordingly.
|
|
|
|
* To do this, it displays a "Connect your YouTube account" button above
|
|
|
|
* the results, or even before showing any. The user presses the button,
|
|
|
|
* switches to a private chat with the bot and, in doing so, passes a start
|
|
|
|
* parameter that instructs the bot to return an oauth link. Once done, the
|
|
|
|
* bot can offer a switch_inline button so that the user can easily return to
|
|
|
|
* the chat where they wanted to use the bot's inline capabilities
|
|
|
|
*/
|
|
|
|
switchPm?: {
|
|
|
|
/**
|
|
|
|
* Text of the button
|
|
|
|
*/
|
|
|
|
text: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameter for `/start` command
|
|
|
|
*/
|
|
|
|
parameter: string
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse mode to use when parsing inline message text.
|
|
|
|
* Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*
|
|
|
|
* **Note**: inline results themselves *can not* have markup
|
|
|
|
* entities, only the messages that are sent once a result is clicked.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-04-28 23:00:51 +03:00
|
|
|
): Promise<void>
|
2022-10-30 20:51:50 +03:00
|
|
|
/**
|
|
|
|
* Answer a pre-checkout query.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2022-10-30 20:51:50 +03:00
|
|
|
* @param queryId Pre-checkout query ID
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
answerPreCheckoutQuery(
|
2023-10-09 21:44:38 +03:00
|
|
|
queryId: tl.Long | PreCheckoutQuery,
|
2023-10-07 00:22:08 +03:00
|
|
|
params?: {
|
|
|
|
/** If pre-checkout is rejected, error message to show to the user */
|
|
|
|
error?: string
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-06-26 19:45:06 +03:00
|
|
|
/**
|
|
|
|
* Delete commands for the current bot and the given scope.
|
|
|
|
*
|
|
|
|
* Does the same as passing `null` to {@link setMyCommands}
|
|
|
|
*
|
|
|
|
* Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope)
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-06-26 19:45:06 +03:00
|
|
|
*/
|
|
|
|
deleteMyCommands(params?: {
|
|
|
|
/**
|
|
|
|
* Scope of the commands.
|
|
|
|
*
|
|
|
|
* Defaults to `BotScope.default_` (i.e. `botCommandScopeDefault`)
|
|
|
|
*/
|
|
|
|
scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User language applied to the scope.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
}): Promise<void>
|
2023-10-04 23:34:55 +03:00
|
|
|
/**
|
|
|
|
* Gets information about a bot the current uzer owns (or the current bot)
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 23:34:55 +03:00
|
|
|
*/
|
|
|
|
getBotInfo(params: {
|
|
|
|
/**
|
|
|
|
* When called by a user, a bot the user owns must be specified.
|
|
|
|
* When called by a bot, must be empty
|
|
|
|
*/
|
|
|
|
bot?: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If passed, will retrieve the bot's description in the given language.
|
|
|
|
* If left empty, will retrieve the fallback description.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
}): Promise<tl.bots.RawBotInfo>
|
2022-05-09 00:00:22 +03:00
|
|
|
/**
|
|
|
|
* Fetches the menu button set for the given user.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-09 00:00:22 +03:00
|
|
|
*/
|
|
|
|
getBotMenuButton(user: InputPeerLike): Promise<tl.TypeBotMenuButton>
|
2021-05-16 12:59:00 +03:00
|
|
|
/**
|
|
|
|
* Request a callback answer from a bot,
|
|
|
|
* i.e. click an inline button that contains data.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-16 12:59:00 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
getCallbackAnswer(params: {
|
|
|
|
/** Chat ID where the message was found */
|
|
|
|
chatId: InputPeerLike
|
2021-05-16 12:59:00 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/** ID of the message containing the button */
|
|
|
|
message: number
|
2021-05-16 12:59:00 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/** Data contained in the button */
|
|
|
|
data: string | Buffer
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Timeout for the query in ms.
|
|
|
|
*
|
|
|
|
* Defaults to `10000` (10 sec)
|
|
|
|
*/
|
|
|
|
timeout?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether this is a "play game" button
|
|
|
|
*/
|
|
|
|
game?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the button requires password entry, your 2FA password.
|
|
|
|
*
|
|
|
|
* Your password is never exposed to the bot,
|
|
|
|
* it is checked by Telegram.
|
|
|
|
*/
|
|
|
|
password?: string
|
|
|
|
}): Promise<tl.messages.TypeBotCallbackAnswer>
|
2021-05-16 02:21:59 +03:00
|
|
|
/**
|
|
|
|
* Get high scores of a game
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-16 02:21:59 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getGameHighScores(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/** ID of the user to find high scores for */
|
|
|
|
userId?: InputPeerLike
|
|
|
|
},
|
|
|
|
): Promise<GameHighScore[]>
|
2021-05-16 02:21:59 +03:00
|
|
|
/**
|
|
|
|
* Get high scores of a game from an inline message
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-16 02:21:59 +03:00
|
|
|
* @param messageId ID of the inline message containing the game
|
|
|
|
* @param userId ID of the user to find high scores for
|
|
|
|
*/
|
|
|
|
getInlineGameHighScores(
|
|
|
|
messageId: string | tl.TypeInputBotInlineMessageID,
|
2023-09-24 01:32:22 +03:00
|
|
|
userId?: InputPeerLike,
|
2021-05-16 02:21:59 +03:00
|
|
|
): Promise<GameHighScore[]>
|
2021-06-26 19:45:06 +03:00
|
|
|
/**
|
|
|
|
* Get a list of current bot's commands for the given command scope
|
|
|
|
* and user language. If they are not set, empty set is returned.
|
|
|
|
*
|
|
|
|
* Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope)
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-06-26 19:45:06 +03:00
|
|
|
*/
|
|
|
|
getMyCommands(params?: {
|
|
|
|
/**
|
|
|
|
* Scope of the commands.
|
|
|
|
*
|
|
|
|
* Defaults to `BotScope.default_` (i.e. `botCommandScopeDefault`)
|
|
|
|
*/
|
|
|
|
scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User language applied to the scope.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
}): Promise<tl.RawBotCommand[]>
|
2022-09-12 19:50:39 +03:00
|
|
|
|
|
|
|
_normalizeCommandScope(
|
2023-09-24 01:32:22 +03:00
|
|
|
scope: tl.TypeBotCommandScope | BotCommands.IntermediateScope,
|
2022-09-12 19:50:39 +03:00
|
|
|
): Promise<tl.TypeBotCommandScope>
|
2023-10-04 23:34:55 +03:00
|
|
|
/**
|
|
|
|
* Sets information about a bot the current uzer owns (or the current bot)
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 23:34:55 +03:00
|
|
|
*/
|
|
|
|
setBotInfo(params: {
|
|
|
|
/**
|
|
|
|
* When called by a user, a bot the user owns must be specified.
|
|
|
|
* When called by a bot, must be empty
|
|
|
|
*/
|
|
|
|
bot?: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If passed, will update the bot's description in the given language.
|
|
|
|
* If left empty, will change the fallback description.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
|
|
|
|
/** New bot name */
|
|
|
|
name?: string
|
|
|
|
|
|
|
|
/** New bio text (displayed in the profile) */
|
|
|
|
bio?: string
|
|
|
|
|
|
|
|
/** New description text (displayed when the chat is empty) */
|
|
|
|
description?: string
|
|
|
|
}): Promise<void>
|
2022-05-09 00:00:22 +03:00
|
|
|
/**
|
|
|
|
* Sets a menu button for the given user.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2022-05-09 00:00:22 +03:00
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
setBotMenuButton(user: InputPeerLike, button: tl.TypeBotMenuButton): Promise<void>
|
2021-05-16 02:21:59 +03:00
|
|
|
/**
|
|
|
|
* Set a score of a user in a game
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-16 02:21:59 +03:00
|
|
|
* @param params
|
|
|
|
* @returns The modified message
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
setGameScore(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/** ID of the user who has scored */
|
|
|
|
userId: InputPeerLike
|
2023-10-07 00:22:08 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/** The new score (must be >0) */
|
|
|
|
score: number
|
2023-10-07 00:22:08 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* When `true`, the game message will not be modified
|
|
|
|
* to include the new score
|
|
|
|
*/
|
|
|
|
noEdit?: boolean
|
2021-05-16 02:21:59 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* Whether to allow user's score to decrease.
|
|
|
|
* This can be useful when fixing mistakes or banning cheaters
|
|
|
|
*/
|
|
|
|
force?: boolean
|
|
|
|
},
|
|
|
|
): Promise<Message>
|
2021-05-16 02:21:59 +03:00
|
|
|
/**
|
|
|
|
* Set a score of a user in a game contained in
|
|
|
|
* an inline message
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-16 02:21:59 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
2023-09-03 03:44:02 +03:00
|
|
|
setInlineGameScore(params: {
|
|
|
|
/** ID of the inline message */
|
|
|
|
messageId: string | tl.TypeInputBotInlineMessageID
|
|
|
|
/** ID of the user who has scored */
|
|
|
|
userId: InputPeerLike
|
|
|
|
/** The new score (must be >0) */
|
|
|
|
score: number
|
|
|
|
/**
|
|
|
|
* When `true`, the game message will not be modified
|
|
|
|
* to include the new score
|
|
|
|
*/
|
|
|
|
noEdit?: boolean
|
2021-05-16 02:21:59 +03:00
|
|
|
|
2023-09-03 03:44:02 +03:00
|
|
|
/**
|
|
|
|
* Whether to allow user's score to decrease.
|
|
|
|
* This can be useful when fixing mistakes or banning cheaters
|
|
|
|
*/
|
|
|
|
force?: boolean
|
|
|
|
}): Promise<void>
|
2021-06-26 19:45:06 +03:00
|
|
|
/**
|
|
|
|
* Set or delete commands for the current bot and the given scope
|
|
|
|
*
|
|
|
|
* Learn more about scopes in the [Bot API docs](https://core.telegram.org/bots/api#botcommandscope)
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-06-26 19:45:06 +03:00
|
|
|
*/
|
|
|
|
setMyCommands(params: {
|
|
|
|
/**
|
|
|
|
* New list of bot commands for the given scope.
|
|
|
|
*
|
|
|
|
* Pass empty array or `null` to delete them.
|
|
|
|
*/
|
|
|
|
commands: tl.RawBotCommand[] | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scope of the commands.
|
|
|
|
*
|
|
|
|
* Defaults to `BotScope.default_` (i.e. `botCommandScopeDefault`)
|
|
|
|
*/
|
|
|
|
scope?: tl.TypeBotCommandScope | BotCommands.IntermediateScope
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User language applied to the scope.
|
|
|
|
*/
|
|
|
|
langCode?: string
|
|
|
|
}): Promise<void>
|
2022-05-08 23:34:28 +03:00
|
|
|
/**
|
|
|
|
* Sets the default chat permissions for the bot in the supergroup or channel.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 🤖 bots only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-08 23:34:28 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
setMyDefaultRights(params: {
|
|
|
|
/** Whether to target groups or channels. */
|
|
|
|
target: 'channel' | 'group'
|
|
|
|
/** The default chat permissions. */
|
|
|
|
rights: Omit<tl.RawChatAdminRights, '_'>
|
|
|
|
}): Promise<void>
|
2021-04-10 20:06:33 +03:00
|
|
|
/**
|
2023-10-07 00:22:08 +03:00
|
|
|
* Add one or more new members to a group, supergroup or channel.
|
2021-04-10 20:06:33 +03:00
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:06:33 +03:00
|
|
|
* @param chatId ID of the chat or its username
|
2023-10-07 00:22:08 +03:00
|
|
|
* @param users ID(s) of the user(s) to add
|
2021-04-10 20:06:33 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
addChatMembers(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
users: MaybeArray<InputPeerLike>,
|
|
|
|
params: {
|
|
|
|
/**
|
|
|
|
* Number of old messages to be forwarded (0-100).
|
|
|
|
* Only applicable to legacy groups, ignored for supergroups and channels
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
forwardCount?: number
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-04-10 20:30:28 +03:00
|
|
|
/**
|
|
|
|
* Archive one or more chats
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:30:28 +03:00
|
|
|
* @param chats Chat ID(s), username(s), phone number(s), `"me"` or `"self"`
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
archiveChats(chats: MaybeArray<InputPeerLike>): Promise<void>
|
2021-05-12 22:07:00 +03:00
|
|
|
/**
|
2023-10-04 23:34:55 +03:00
|
|
|
* Ban a user/channel from a legacy group, a supergroup or a channel.
|
2021-05-12 22:07:00 +03:00
|
|
|
* They will not be able to re-join the group on their own,
|
2023-10-04 23:34:55 +03:00
|
|
|
* manual administrator's action will be required.
|
|
|
|
*
|
|
|
|
* When banning a channel, the user won't be able to use
|
|
|
|
* any of their channels to post until the ban is lifted.
|
2021-05-12 22:07:00 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:07:00 +03:00
|
|
|
* @returns Service message about removed user, if one was generated.
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
banChatMember(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** ID of the user/channel to ban */
|
|
|
|
participantId: InputPeerLike
|
|
|
|
}): Promise<Message | null>
|
2021-04-10 20:56:09 +03:00
|
|
|
/**
|
|
|
|
* Create a new broadcast channel
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:56:09 +03:00
|
|
|
* @returns Newly created channel
|
|
|
|
*/
|
2023-10-03 00:58:45 +03:00
|
|
|
createChannel(params: {
|
|
|
|
/**
|
|
|
|
* Channel title
|
|
|
|
*/
|
|
|
|
title: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Channel description
|
|
|
|
*/
|
|
|
|
description?: string
|
|
|
|
}): Promise<Chat>
|
2021-04-11 00:37:12 +03:00
|
|
|
/**
|
|
|
|
* Create a legacy group chat
|
|
|
|
*
|
|
|
|
* If you want to create a supergroup, use {@link createSupergroup}
|
|
|
|
* instead.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 00:37:12 +03:00
|
|
|
*/
|
2023-10-03 04:05:24 +03:00
|
|
|
createGroup(params: {
|
|
|
|
/**
|
|
|
|
* Group title
|
|
|
|
*/
|
|
|
|
title: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User(s) to be invited in the group (ID(s), username(s) or phone number(s)).
|
|
|
|
* Due to Telegram limitations, you can't create a legacy group with just yourself.
|
|
|
|
*/
|
|
|
|
users: MaybeArray<InputPeerLike>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TTL period (in seconds) for the newly created chat
|
|
|
|
*
|
|
|
|
* @default 0 (i.e. messages don't expire)
|
|
|
|
*/
|
|
|
|
ttlPeriod?: number
|
|
|
|
}): Promise<Chat>
|
2021-04-10 21:08:04 +03:00
|
|
|
/**
|
|
|
|
* Create a new supergroup
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @returns Newly created supergroup
|
2021-04-10 21:08:04 +03:00
|
|
|
*/
|
2023-10-03 00:58:45 +03:00
|
|
|
createSupergroup(params: {
|
|
|
|
/**
|
|
|
|
* Supergroup title
|
|
|
|
*/
|
|
|
|
title: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Supergroup description
|
|
|
|
*/
|
|
|
|
description?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to create a forum
|
|
|
|
*/
|
|
|
|
forum?: boolean
|
|
|
|
|
|
|
|
/**
|
2023-10-03 04:05:24 +03:00
|
|
|
* TTL period (in seconds) for the newly created supergroup
|
2023-10-03 00:58:45 +03:00
|
|
|
*
|
|
|
|
* @default 0 (i.e. messages don't expire)
|
|
|
|
*/
|
|
|
|
ttlPeriod?: number
|
|
|
|
}): Promise<Chat>
|
2021-04-10 20:56:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a channel or a supergroup
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:56:09 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
deleteChannel(chatId: InputPeerLike): Promise<void>
|
2021-04-10 20:56:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a channel or a supergroup
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:56:09 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
deleteSupergroup(chatId: InputPeerLike): Promise<void>
|
2021-04-11 15:22:48 +03:00
|
|
|
/**
|
|
|
|
* Delete a chat photo
|
|
|
|
*
|
|
|
|
* You must be an administrator and have the appropriate permissions.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 15:22:48 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
deleteChatPhoto(chatId: InputPeerLike): Promise<void>
|
2021-04-11 00:37:12 +03:00
|
|
|
/**
|
|
|
|
* Delete a legacy group chat for all members
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 00:37:12 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
deleteGroup(chatId: InputPeerLike): Promise<void>
|
2021-04-11 00:37:12 +03:00
|
|
|
/**
|
2023-10-09 05:59:48 +03:00
|
|
|
* Delete communication history (for private chats and legacy groups)
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 00:37:12 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
deleteHistory(
|
|
|
|
chat: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Deletion mode. Can be:
|
|
|
|
* - `delete`: delete messages (only for yourself)
|
|
|
|
* - `clear`: delete messages (only for yourself)
|
|
|
|
* - `revoke`: delete messages for all users
|
|
|
|
* - I'm not sure what's the difference between `delete` and `clear`,
|
|
|
|
* but they are in fact different flags in TL object.
|
|
|
|
*
|
|
|
|
* @default 'delete'
|
|
|
|
*/
|
|
|
|
mode: 'delete' | 'clear' | 'revoke'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum ID of message to delete.
|
|
|
|
*
|
|
|
|
* @default 0, i.e. remove all messages
|
|
|
|
*/
|
|
|
|
maxId?: number
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-05-10 14:27:57 +03:00
|
|
|
/**
|
2022-04-29 17:54:11 +03:00
|
|
|
* Delete all messages of a user (or channel) in a supergroup
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 14:27:57 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
deleteUserHistory(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** User/channel ID whose messages to delete */
|
|
|
|
participantId: InputPeerLike
|
|
|
|
}): Promise<void>
|
2021-05-16 14:55:17 +03:00
|
|
|
/**
|
|
|
|
* Edit supergroup/channel admin rights of a user.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-16 14:55:17 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
editAdminRights(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** User ID */
|
|
|
|
userId: InputPeerLike
|
|
|
|
/** New admin rights */
|
|
|
|
rights: Omit<tl.RawChatAdminRights, '_'>
|
|
|
|
/** Custom admin rank */
|
|
|
|
rank?: string
|
|
|
|
}): Promise<void>
|
2021-05-10 21:51:25 +03:00
|
|
|
/**
|
2023-09-29 17:02:36 +03:00
|
|
|
* Get chat event log ("Recent actions" in official clients).
|
2021-05-10 21:51:25 +03:00
|
|
|
*
|
|
|
|
* Only available for supergroups and channels, and
|
|
|
|
* requires (any) administrator rights.
|
|
|
|
*
|
|
|
|
* Results are returned in reverse chronological
|
|
|
|
* order (i.e. newest first) and event IDs are
|
|
|
|
* in direct chronological order (i.e. newer
|
|
|
|
* events have bigger event ID)
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 21:51:25 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
getChatEventLog(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Search query
|
|
|
|
*/
|
|
|
|
query?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Minimum event ID to return
|
|
|
|
*/
|
|
|
|
minId?: tl.Long
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum event ID to return,
|
|
|
|
* can be used as a base offset
|
|
|
|
*/
|
|
|
|
maxId?: tl.Long
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of users whose actions to return
|
|
|
|
*/
|
|
|
|
users?: InputPeerLike[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event filters. Can be a TL object, or one or more
|
|
|
|
* action types.
|
|
|
|
*
|
|
|
|
* Note that some filters are grouped in TL
|
|
|
|
* (i.e. `info=true` will return `title_changed`,
|
|
|
|
* `username_changed` and many more),
|
|
|
|
* and when passing one or more action types,
|
|
|
|
* they will be filtered locally.
|
|
|
|
*/
|
2023-09-29 17:02:36 +03:00
|
|
|
filters?: InputChatEventFilters
|
2021-05-10 21:51:25 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Limit the number of events returned.
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* > Note: when using filters, there will likely be
|
|
|
|
* > less events returned than specified here.
|
|
|
|
* > This limit is only used to limit the number of
|
|
|
|
* > events to fetch from the server.
|
|
|
|
* >
|
|
|
|
* > If you need to limit the number of events
|
|
|
|
* > returned, use {@link iterChatEventLog} instead.
|
2021-05-10 21:51:25 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @default 100
|
2021-05-10 21:51:25 +03:00
|
|
|
*/
|
2023-09-29 17:02:36 +03:00
|
|
|
limit?: number
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-09-29 17:02:36 +03:00
|
|
|
): Promise<ChatEvent[]>
|
2021-04-11 14:56:34 +03:00
|
|
|
/**
|
|
|
|
* Get information about a single chat member
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 14:56:34 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param userId User ID, username, phone number, `"me"` or `"self"`
|
2021-04-11 15:22:48 +03:00
|
|
|
* @throws UserNotParticipantError In case given user is not a participant of a given chat
|
2021-04-11 14:56:34 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
getChatMember(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** User ID, username, phone number, `"me"` or `"self"` */
|
|
|
|
userId: InputPeerLike
|
|
|
|
}): Promise<ChatMember>
|
2021-04-14 19:43:05 +03:00
|
|
|
/**
|
|
|
|
* Get a chunk of members of some chat.
|
|
|
|
*
|
|
|
|
* You can retrieve up to 200 members at once
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-14 19:43:05 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param params Additional parameters
|
|
|
|
*/
|
|
|
|
getChatMembers(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Search query to filter members by their display names and usernames
|
|
|
|
* Defaults to `''` (empty string)
|
|
|
|
*
|
|
|
|
* > **Note**: Only used for these values of `filter`:
|
2023-10-01 16:36:29 +03:00
|
|
|
* > `all, banned, restricted, mention, contacts`
|
2021-04-14 19:43:05 +03:00
|
|
|
*/
|
|
|
|
query?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sequential number of the first member to be returned.
|
|
|
|
*/
|
|
|
|
offset?: number
|
|
|
|
|
|
|
|
/**
|
2023-09-29 21:45:11 +03:00
|
|
|
* Maximum number of members to be retrieved.
|
|
|
|
*
|
|
|
|
* > **Note**: Telegram currently only allows you to ever retrieve at most
|
|
|
|
* > 200 members, regardless of offset/limit. I.e. when passing
|
|
|
|
* > `offset=201` nothing will ever be returned.
|
|
|
|
*
|
|
|
|
* @default 200
|
2021-04-14 19:43:05 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of the query. Can be:
|
|
|
|
* - `all`: get all members
|
|
|
|
* - `banned`: get only banned members
|
|
|
|
* - `restricted`: get only restricted members
|
|
|
|
* - `bots`: get only bots
|
|
|
|
* - `recent`: get recent members
|
|
|
|
* - `admins`: get only administrators (and creator)
|
|
|
|
* - `contacts`: get only contacts
|
2022-08-29 16:22:57 +03:00
|
|
|
* - `mention`: get users that can be mentioned (see {@link tl.RawChannelParticipantsMentions})
|
2021-04-14 19:43:05 +03:00
|
|
|
*
|
|
|
|
* Only used for channels and supergroups. Defaults to `recent`
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
type?: 'all' | 'banned' | 'restricted' | 'bots' | 'recent' | 'admins' | 'contacts' | 'mention'
|
|
|
|
},
|
2021-06-10 02:31:48 +03:00
|
|
|
): Promise<ArrayWithTotal<ChatMember>>
|
2021-04-10 17:11:25 +03:00
|
|
|
/**
|
|
|
|
* Get preview information about a private chat.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 17:11:25 +03:00
|
|
|
* @param inviteLink Invite link
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtArgumentError In case invite link has invalid format
|
2023-10-07 00:22:08 +03:00
|
|
|
* @throws MtPeerNotFoundError
|
2021-04-10 17:11:25 +03:00
|
|
|
* In case you are trying to get info about private chat that you have already joined.
|
|
|
|
* Use {@link getChat} or {@link getFullChat} instead.
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getChatPreview(inviteLink: string): Promise<ChatPreview>
|
2023-10-09 21:44:38 +03:00
|
|
|
|
2021-04-10 17:11:25 +03:00
|
|
|
/**
|
|
|
|
* Get basic information about a chat.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 17:11:25 +03:00
|
|
|
* @param chatId ID of the chat, its username or invite link
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtArgumentError
|
2021-04-10 17:11:25 +03:00
|
|
|
* In case you are trying to get info about private chat that you haven't joined.
|
|
|
|
* Use {@link getChatPreview} instead.
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getChat(chatId: InputPeerLike): Promise<Chat>
|
2023-10-09 21:44:38 +03:00
|
|
|
|
2021-04-10 17:11:25 +03:00
|
|
|
/**
|
|
|
|
* Get full information about a chat.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 17:11:25 +03:00
|
|
|
* @param chatId ID of the chat, its username or invite link
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtArgumentError
|
2021-04-10 17:11:25 +03:00
|
|
|
* In case you are trying to get info about private chat that you haven't joined.
|
|
|
|
* Use {@link getChatPreview} instead.
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getFullChat(chatId: InputPeerLike): Promise<Chat>
|
2021-05-10 22:51:35 +03:00
|
|
|
/**
|
|
|
|
* Get nearby chats
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 22:51:35 +03:00
|
|
|
* @param latitude Latitude of the location
|
|
|
|
* @param longitude Longitude of the location
|
|
|
|
*/
|
|
|
|
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Iterate over chat event log.
|
|
|
|
*
|
|
|
|
* Small wrapper over {@link getChatEventLog}
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
iterChatEventLog(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getChatEventLog>[2] & {
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Total number of events to return.
|
|
|
|
*
|
|
|
|
* @default Infinity
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size, passed as `limit` to {@link getChatEventLog}.
|
|
|
|
* Usually you don't need to touch this.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<ChatEvent>
|
2021-04-14 19:43:05 +03:00
|
|
|
/**
|
|
|
|
* Iterate through chat members
|
|
|
|
*
|
|
|
|
* This method is a small wrapper over {@link getChatMembers},
|
|
|
|
* which also handles duplicate entries (i.e. does not yield
|
|
|
|
* the same member twice)
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-14 19:43:05 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param params Additional parameters
|
|
|
|
*/
|
|
|
|
iterChatMembers(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getChatMembers>[2] & {
|
2021-04-14 19:43:05 +03:00
|
|
|
/**
|
|
|
|
* Chunk size, which will be passed as `limit` parameter
|
2023-10-09 05:59:48 +03:00
|
|
|
* to {@link getChatMembers}. Usually you shouldn't care about this.
|
2021-04-14 19:43:05 +03:00
|
|
|
*
|
|
|
|
* Defaults to `200`
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-04-18 16:59:05 +03:00
|
|
|
): AsyncIterableIterator<ChatMember>
|
2021-04-10 17:11:25 +03:00
|
|
|
/**
|
|
|
|
* Join a channel or supergroup
|
|
|
|
*
|
2022-05-09 17:25:38 +03:00
|
|
|
* When using with invite links, this method may throw RPC error
|
|
|
|
* `INVITE_REQUEST_SENT`, which means that you need to wait for admin approval.
|
|
|
|
* You will get into the chat once they do so.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 17:11:25 +03:00
|
|
|
* @param chatId
|
|
|
|
* Chat identifier. Either an invite link (`t.me/joinchat/*`), a username (`@username`)
|
|
|
|
* or ID of the linked supergroup or channel.
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
joinChat(chatId: InputPeerLike): Promise<Chat>
|
2021-05-12 22:07:00 +03:00
|
|
|
/**
|
|
|
|
* Kick a user from a chat.
|
|
|
|
*
|
|
|
|
* This effectively bans a user and immediately unbans them.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:07:00 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
kickChatMember(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** User ID */
|
|
|
|
userId: InputPeerLike
|
|
|
|
}): Promise<void>
|
2021-04-11 00:37:12 +03:00
|
|
|
/**
|
|
|
|
* Leave a group chat, supergroup or channel
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 00:37:12 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
leaveChat(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Whether to clear history after leaving (only for legacy group chats)
|
|
|
|
*/
|
|
|
|
clear?: boolean
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-05-12 22:36:03 +03:00
|
|
|
/**
|
|
|
|
* Mark a chat as unread
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-12 22:36:03 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
*/
|
|
|
|
markChatUnread(chatId: InputPeerLike): Promise<void>
|
2023-10-03 03:23:23 +03:00
|
|
|
/**
|
|
|
|
* Reorder usernames
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 03:23:23 +03:00
|
|
|
* @param peerId Bot, channel or "me"/"self"
|
|
|
|
*/
|
|
|
|
reorderUsernames(peerId: InputPeerLike, order: string[]): Promise<void>
|
2021-05-12 22:07:00 +03:00
|
|
|
/**
|
|
|
|
* Restrict a user in a supergroup.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:07:00 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
restrictChatMember(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** User ID */
|
|
|
|
userId: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restrictions for the user. Note that unlike Bot API, this object contains
|
|
|
|
* the restrictions, and not the permissions, i.e.
|
|
|
|
* passing `sendMessages=true` will disallow the user to send messages,
|
|
|
|
* and passing `{}` (empty object) will lift any restrictions
|
|
|
|
*/
|
|
|
|
restrictions: Omit<tl.RawChatBannedRights, '_' | 'untilDate'>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Date when the user will be unrestricted.
|
|
|
|
* When `number` is passed, UNIX time in ms is expected.
|
|
|
|
* If this value is less than 30 seconds or more than 366 days in
|
|
|
|
* the future, user will be restricted forever.
|
|
|
|
*
|
|
|
|
* @default `0`, i.e. forever
|
|
|
|
*/
|
|
|
|
until?: number | Date
|
|
|
|
}): Promise<void>
|
2021-04-14 21:31:51 +03:00
|
|
|
/**
|
|
|
|
* Save or delete a draft message associated with some chat
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-14 21:31:51 +03:00
|
|
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param draft Draft message, or `null` to delete.
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
saveDraft(chatId: InputPeerLike, draft: null | Omit<tl.RawDraftMessage, '_' | 'date'>): Promise<void>
|
2021-04-11 16:11:28 +03:00
|
|
|
/**
|
|
|
|
* Change default chat permissions for all members.
|
|
|
|
*
|
|
|
|
* You must be an administrator in the chat and have appropriate permissions.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 16:11:28 +03:00
|
|
|
* @param chatId Chat ID or username
|
2021-05-12 22:07:00 +03:00
|
|
|
* @param restrictions
|
|
|
|
* Restrictions for the chat. Note that unlike Bot API, this object contains
|
2023-10-07 00:22:08 +03:00
|
|
|
* the restrictions, and not the permissions, i.e.
|
2021-05-12 22:07:00 +03:00
|
|
|
* passing `sendMessages=true` will disallow the users to send messages,
|
|
|
|
* and passing `{}` (empty object) will lift any restrictions
|
2021-04-11 16:11:28 +03:00
|
|
|
*/
|
|
|
|
setChatDefaultPermissions(
|
|
|
|
chatId: InputPeerLike,
|
2023-09-24 01:32:22 +03:00
|
|
|
restrictions: Omit<tl.RawChatBannedRights, '_' | 'untilDate'>,
|
2021-04-18 16:59:05 +03:00
|
|
|
): Promise<Chat>
|
2021-04-11 15:32:38 +03:00
|
|
|
/**
|
|
|
|
* Change chat description
|
|
|
|
*
|
|
|
|
* You must be an administrator and have the appropriate permissions.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 15:32:38 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param description New chat description, 0-255 characters
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
setChatDescription(chatId: InputPeerLike, description: string): Promise<void>
|
2021-04-11 15:22:48 +03:00
|
|
|
/**
|
|
|
|
* Set a new chat photo or video.
|
|
|
|
*
|
|
|
|
* You must be an administrator and have the appropriate permissions.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 15:22:48 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
setChatPhoto(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** Media type (photo or video) */
|
|
|
|
|
|
|
|
type: 'photo' | 'video'
|
|
|
|
|
|
|
|
/** Input media file */
|
|
|
|
media: InputFileLike
|
|
|
|
/**
|
|
|
|
* When `type = video`, timestamp in seconds which will be shown
|
|
|
|
* as a static preview.
|
|
|
|
*/
|
|
|
|
previewSec?: number
|
|
|
|
}): Promise<void>
|
2021-04-11 15:32:38 +03:00
|
|
|
/**
|
|
|
|
* Change chat title
|
|
|
|
*
|
|
|
|
* You must be an administrator and have the appropriate permissions.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 15:32:38 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param title New chat title, 1-255 characters
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
setChatTitle(chatId: InputPeerLike, title: string): Promise<void>
|
2023-10-03 04:05:24 +03:00
|
|
|
/**
|
|
|
|
* Set maximum Time-To-Live of all newly sent messages in the specified chat
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 04:05:24 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param period New TTL period, in seconds (or 0 to disable)
|
|
|
|
*/
|
|
|
|
setChatTtl(chatId: InputPeerLike, period: number): Promise<void>
|
2021-04-11 16:32:10 +03:00
|
|
|
/**
|
|
|
|
* Change supergroup/channel username
|
|
|
|
*
|
|
|
|
* You must be an administrator and have the appropriate permissions.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 16:32:10 +03:00
|
|
|
* @param chatId Chat ID or current username
|
|
|
|
* @param username New username, or `null` to remove
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
setChatUsername(chatId: InputPeerLike, username: string | null): Promise<void>
|
2021-04-11 16:11:28 +03:00
|
|
|
/**
|
|
|
|
* Set supergroup's slow mode interval.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-11 16:11:28 +03:00
|
|
|
* @param chatId Chat ID or username
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [seconds=0]
|
2021-04-11 16:11:28 +03:00
|
|
|
* Slow mode interval in seconds.
|
|
|
|
* Users will be able to send a message only once per this interval.
|
|
|
|
* Valid values are: `0 (off), 10, 30, 60 (1m), 300 (5m), 900 (15m) or 3600 (1h)`
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
setSlowMode(chatId: InputPeerLike, seconds?: number): Promise<void>
|
2023-10-03 03:48:52 +03:00
|
|
|
/**
|
|
|
|
* Set whether a chat has content protection (i.e. forwarding messages is disabled)
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 03:48:52 +03:00
|
|
|
* @param chatId Chat ID or username
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [enabled=false] Whether content protection should be enabled
|
2023-10-03 03:48:52 +03:00
|
|
|
*/
|
|
|
|
toggleContentProtection(chatId: InputPeerLike, enabled?: boolean): Promise<void>
|
2023-10-03 03:23:23 +03:00
|
|
|
/**
|
|
|
|
* Toggle a collectible (Fragment) username
|
|
|
|
*
|
|
|
|
* > **Note**: non-collectible usernames must still be changed
|
|
|
|
* > using {@link setUsername}/{@link setChatUsername}
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 03:23:23 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
toggleFragmentUsername(params: {
|
|
|
|
/** Peer ID whose username to toggle */
|
|
|
|
peerId: InputPeerLike
|
2023-10-03 03:23:23 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Username to toggle
|
|
|
|
*/
|
|
|
|
username: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to enable or disable the username
|
|
|
|
*/
|
|
|
|
active: boolean
|
|
|
|
}): Promise<void>
|
2023-10-02 19:54:11 +03:00
|
|
|
/**
|
|
|
|
* Set whether a channel/supergroup has join requests enabled.
|
|
|
|
*
|
|
|
|
* > **Note**: this method only affects primary invite links.
|
|
|
|
* > Additional invite links may exist with the opposite setting.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 19:54:11 +03:00
|
|
|
* @param chatId Chat ID or username
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [enabled=false] Whether join requests should be enabled
|
2023-10-02 19:54:11 +03:00
|
|
|
*/
|
|
|
|
toggleJoinRequests(chatId: InputPeerLike, enabled?: boolean): Promise<void>
|
|
|
|
/**
|
|
|
|
* Set whether a channel/supergroup has join-to-send setting enabled.
|
|
|
|
*
|
|
|
|
* This only affects discussion groups where users can send messages
|
|
|
|
* without joining the group.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 19:54:11 +03:00
|
|
|
* @param chatId Chat ID or username
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [enabled=false] Whether join-to-send setting should be enabled
|
2023-10-02 19:54:11 +03:00
|
|
|
*/
|
|
|
|
toggleJoinToSend(chatId: InputPeerLike, enabled?: boolean): Promise<void>
|
2021-04-10 20:30:28 +03:00
|
|
|
/**
|
|
|
|
* Unarchive one or more chats
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 20:30:28 +03:00
|
|
|
* @param chats Chat ID(s), username(s), phone number(s), `"me"` or `"self"`
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
unarchiveChats(chats: MaybeArray<InputPeerLike>): Promise<void>
|
2021-05-12 22:07:00 +03:00
|
|
|
|
|
|
|
/**
|
2023-10-04 23:34:55 +03:00
|
|
|
* Unban a user/channel from a supergroup or a channel,
|
2021-05-12 22:07:00 +03:00
|
|
|
* or remove any restrictions that they have.
|
|
|
|
* Unbanning does not add the user back to the chat, this
|
|
|
|
* just allows the user to join the chat again, if they want.
|
|
|
|
*
|
|
|
|
* This method acts as a no-op in case a legacy group is passed.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:07:00 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
unbanChatMember(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** User/channel ID who should be unbanned */
|
|
|
|
participantId: InputPeerLike
|
|
|
|
}): Promise<void>
|
2021-05-12 22:07:00 +03:00
|
|
|
|
|
|
|
/**
|
2023-10-04 23:34:55 +03:00
|
|
|
* Unban a user/channel from a supergroup or a channel,
|
2021-05-12 22:07:00 +03:00
|
|
|
* or remove any restrictions that they have.
|
|
|
|
* Unbanning does not add the user back to the chat, this
|
|
|
|
* just allows the user to join the chat again, if they want.
|
|
|
|
*
|
|
|
|
* This method acts as a no-op in case a legacy group is passed.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:07:00 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
unrestrictChatMember(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** User/channel ID who should be unbanned */
|
|
|
|
participantId: InputPeerLike
|
|
|
|
}): Promise<void>
|
2021-04-25 17:10:37 +03:00
|
|
|
/**
|
|
|
|
* Add an existing Telegram user as a contact
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-25 17:10:37 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
addContact(params: {
|
|
|
|
/** User ID, username or phone number */
|
|
|
|
userId: InputPeerLike
|
2021-04-25 17:10:37 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* First name of the contact
|
|
|
|
*/
|
|
|
|
firstName: string
|
2021-04-25 17:10:37 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Last name of the contact
|
|
|
|
*/
|
|
|
|
lastName?: string
|
2021-04-25 17:10:37 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Phone number of the contact, if available
|
|
|
|
*/
|
|
|
|
phone?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to share your own phone number
|
|
|
|
* with the newly created contact (defaults to `false`)
|
|
|
|
*/
|
|
|
|
sharePhone?: boolean
|
|
|
|
}): Promise<User>
|
2021-04-25 17:10:37 +03:00
|
|
|
/**
|
|
|
|
* Delete a single contact from your Telegram contacts list
|
|
|
|
*
|
|
|
|
* Returns deleted contact's profile or `null` in case
|
|
|
|
* that user was not in your contacts list
|
|
|
|
*
|
|
|
|
* @param userId User ID, username or phone number
|
|
|
|
*/
|
|
|
|
deleteContacts(userId: InputPeerLike): Promise<User | null>
|
|
|
|
/**
|
|
|
|
* Delete one or more contacts from your Telegram contacts list
|
|
|
|
*
|
|
|
|
* Returns deleted contact's profiles. Does not return
|
|
|
|
* profiles of users that were not in your contacts list
|
|
|
|
*
|
|
|
|
* @param userIds User IDs, usernames or phone numbers
|
|
|
|
*/
|
|
|
|
deleteContacts(userIds: InputPeerLike[]): Promise<User[]>
|
|
|
|
/**
|
|
|
|
* Get list of contacts from your Telegram contacts list.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-25 17:10:37 +03:00
|
|
|
*/
|
|
|
|
getContacts(): Promise<User[]>
|
|
|
|
/**
|
|
|
|
* Import contacts to your Telegram contacts list.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-25 17:10:37 +03:00
|
|
|
* @param contacts List of contacts
|
|
|
|
*/
|
|
|
|
importContacts(
|
2023-09-24 01:32:22 +03:00
|
|
|
contacts: PartialOnly<Omit<tl.RawInputPhoneContact, '_'>, 'clientId'>[],
|
2021-04-25 17:10:37 +03:00
|
|
|
): Promise<tl.contacts.RawImportedContacts>
|
2021-04-16 00:12:07 +03:00
|
|
|
/**
|
|
|
|
* Create a folder from given parameters
|
|
|
|
*
|
|
|
|
* ID for the folder is optional, if not
|
|
|
|
* provided it will be derived automatically.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-16 00:12:07 +03:00
|
|
|
* @param folder Parameters for the folder
|
|
|
|
* @returns Newly created folder
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
createFolder(folder: PartialExcept<tl.RawDialogFilter, 'title'>): Promise<tl.RawDialogFilter>
|
2021-04-16 00:12:07 +03:00
|
|
|
/**
|
|
|
|
* Delete a folder by its ID
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-16 00:12:07 +03:00
|
|
|
* @param id Folder ID or folder itself
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
deleteFolder(id: number | tl.RawDialogFilter): Promise<void>
|
2021-04-16 00:12:07 +03:00
|
|
|
/**
|
|
|
|
* Edit a folder with given modification
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-16 00:12:07 +03:00
|
|
|
* @returns Modified folder
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
editFolder(params: {
|
|
|
|
/**
|
|
|
|
* Folder, folder ID or name.
|
|
|
|
* Note that passing an ID or name will require re-fetching all folders,
|
|
|
|
* and passing name might affect not the right folder if you have multiple
|
|
|
|
* with the same name.
|
|
|
|
*/
|
|
|
|
folder: tl.RawDialogFilter | number | string
|
|
|
|
|
|
|
|
/** Modification to be applied to this folder */
|
|
|
|
modification: Partial<Omit<tl.RawDialogFilter, 'id' | '_'>>
|
|
|
|
}): Promise<tl.RawDialogFilter>
|
2021-04-24 19:27:14 +03:00
|
|
|
/**
|
|
|
|
* Find a folder by its parameter.
|
|
|
|
*
|
|
|
|
* > **Note**: Searching by title and/or emoji might not be
|
|
|
|
* > accurate since you can set the same title and/or emoji
|
|
|
|
* > to multiple folders.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-24 19:27:14 +03:00
|
|
|
* @param params Search parameters. At least one must be set.
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
findFolder(params: {
|
|
|
|
/** Folder title */
|
|
|
|
title?: string
|
|
|
|
/** Folder emoji */
|
|
|
|
emoji?: string
|
|
|
|
/** Folder ID */
|
|
|
|
id?: number
|
|
|
|
}): Promise<tl.RawDialogFilter | null>
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Get list of folders.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
*/
|
|
|
|
getFolders(): Promise<tl.TypeDialogFilter[]>
|
|
|
|
|
|
|
|
_normalizeInputFolder(folder: InputDialogFolder): Promise<tl.TypeDialogFilter>
|
|
|
|
/**
|
|
|
|
* Get dialogs with certain peers.
|
|
|
|
*
|
|
|
|
* @param peers Peers for which to fetch dialogs.
|
|
|
|
*/
|
|
|
|
getPeerDialogs(peers: InputPeerLike): Promise<Dialog>
|
|
|
|
/**
|
|
|
|
* Get dialogs with certain peers.
|
|
|
|
*
|
|
|
|
* @param peers Peers for which to fetch dialogs.
|
|
|
|
*/
|
|
|
|
getPeerDialogs(peers: InputPeerLike[]): Promise<Dialog[]>
|
2021-04-16 00:12:07 +03:00
|
|
|
/**
|
2021-04-17 10:05:31 +03:00
|
|
|
* Iterate over dialogs.
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* Note that due to Telegram API limitations,
|
2021-04-17 10:05:31 +03:00
|
|
|
* ordering here can only be anti-chronological
|
|
|
|
* (i.e. newest - first), and draft update date
|
|
|
|
* is not considered when sorting.
|
2021-04-16 00:12:07 +03:00
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-16 00:12:07 +03:00
|
|
|
* @param params Fetch parameters
|
|
|
|
*/
|
2023-09-29 17:02:36 +03:00
|
|
|
iterDialogs(params?: {
|
2021-04-16 00:12:07 +03:00
|
|
|
/**
|
|
|
|
* Offset message date used as an anchor for pagination.
|
|
|
|
*/
|
|
|
|
offsetDate?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset message ID used as an anchor for pagination
|
|
|
|
*/
|
|
|
|
offsetId?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset peer used as an anchor for pagination
|
|
|
|
*/
|
|
|
|
offsetPeer?: tl.TypeInputPeer
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Limits the number of dialogs to be received.
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @default `Infinity`, i.e. all dialogs are fetched
|
2021-04-16 00:12:07 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size which will be passed to `messages.getDialogs`.
|
|
|
|
* You shouldn't usually care about this.
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @default 100.
|
2021-04-16 00:12:07 +03:00
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How to handle pinned dialogs?
|
|
|
|
*
|
|
|
|
* Whether to `include` them at the start of the list,
|
|
|
|
* `exclude` them at all, or `only` return pinned dialogs.
|
|
|
|
*
|
|
|
|
* Additionally, for folders you can specify
|
|
|
|
* `keep`, which will return pinned dialogs
|
|
|
|
* ordered by date among other non-pinned dialogs.
|
|
|
|
*
|
2021-04-17 10:05:31 +03:00
|
|
|
* > **Note**: When using `include` mode with folders,
|
|
|
|
* > pinned dialogs will only be fetched if all offset
|
|
|
|
* > parameters are unset.
|
2023-09-29 17:02:36 +03:00
|
|
|
*
|
|
|
|
* @default `include`.
|
2021-04-16 00:12:07 +03:00
|
|
|
*/
|
|
|
|
pinned?: 'include' | 'exclude' | 'only' | 'keep'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How to handle archived chats?
|
|
|
|
*
|
|
|
|
* Whether to `keep` them among other dialogs,
|
|
|
|
* `exclude` them from the list, or `only`
|
|
|
|
* return archived dialogs
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* Ignored for folders, since folders
|
2021-04-16 00:12:07 +03:00
|
|
|
* themselves contain information about archived chats.
|
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* > **Note**: when `pinned=only`, `archived=keep` will act as `only`
|
|
|
|
* > because of Telegram API limitations.
|
|
|
|
*
|
|
|
|
* @default `exclude`
|
2021-04-16 00:12:07 +03:00
|
|
|
*/
|
|
|
|
archived?: 'keep' | 'exclude' | 'only'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Folder from which the dialogs will be fetched.
|
|
|
|
*
|
|
|
|
* You can pass folder object, id or title
|
|
|
|
*
|
|
|
|
* Note that passing anything except object will
|
|
|
|
* cause the list of the folders to be fetched,
|
|
|
|
* and passing a title may fetch from
|
|
|
|
* a wrong folder if you have multiple with the same title.
|
|
|
|
*
|
2021-04-17 10:05:31 +03:00
|
|
|
* Also note that fetching dialogs in a folder is
|
|
|
|
* *orders of magnitudes* slower than normal because
|
|
|
|
* of Telegram API limitations - we have to fetch all dialogs
|
|
|
|
* and filter the ones we need manually. If possible,
|
|
|
|
* use {@link Dialog.filterFolder} instead.
|
|
|
|
*
|
2021-04-16 00:12:07 +03:00
|
|
|
* When a folder with given ID or title is not found,
|
2021-08-05 20:38:24 +03:00
|
|
|
* {@link MtArgumentError} is thrown
|
2021-04-16 00:12:07 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @default <empty> (fetches from "All" folder)
|
2021-04-16 00:12:07 +03:00
|
|
|
*/
|
2023-09-29 17:02:36 +03:00
|
|
|
folder?: InputDialogFolder
|
2021-04-25 21:47:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional filtering for the dialogs.
|
|
|
|
*
|
|
|
|
* If `folder` is not provided, this filter is used instead.
|
|
|
|
* If `folder` is provided, fields from this object are used
|
|
|
|
* to override filters inside the folder.
|
|
|
|
*/
|
|
|
|
filter?: Partial<Omit<tl.RawDialogFilter, '_' | 'id' | 'title'>>
|
2021-04-18 16:59:05 +03:00
|
|
|
}): AsyncIterableIterator<Dialog>
|
2022-06-18 22:47:31 +03:00
|
|
|
/**
|
|
|
|
* Reorder folders
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @param order New order of folders (folder IDs, where default = 0)
|
2022-06-18 22:47:31 +03:00
|
|
|
*/
|
|
|
|
setFoldersOrder(order: number[]): Promise<void>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Download a file and return its contents as a Buffer.
|
|
|
|
*
|
|
|
|
* > **Note**: This method _will_ download the entire file
|
|
|
|
* > into memory at once. This might cause an issue, so use wisely!
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param params File download parameters
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
downloadAsBuffer(params: FileDownloadParameters): Promise<Buffer>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Download a remote file to a local file (only for NodeJS).
|
|
|
|
* Promise will resolve once the download is complete.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param filename Local file name to which the remote file will be downloaded
|
|
|
|
* @param params File download parameters
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
downloadToFile(filename: string, params: FileDownloadParameters): Promise<void>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Download a file and return it as an iterable, which yields file contents
|
|
|
|
* in chunks of a given size. Order of the chunks is guaranteed to be
|
|
|
|
* consecutive.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param params Download parameters
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
downloadAsIterable(params: FileDownloadParameters): AsyncIterableIterator<Buffer>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Download a file and return it as a Node readable stream,
|
|
|
|
* streaming file contents.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param params File download parameters
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
downloadAsStream(params: FileDownloadParameters): Readable
|
2023-10-05 04:00:58 +03:00
|
|
|
/**
|
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
|
|
|
*/
|
2022-09-12 19:50:39 +03:00
|
|
|
_normalizeFileToDocument(
|
|
|
|
file: InputFileLike | tl.TypeInputDocument,
|
|
|
|
params: {
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2022-09-12 19:50:39 +03:00
|
|
|
): Promise<tl.TypeInputDocument>
|
2021-06-24 00:15:12 +03:00
|
|
|
/**
|
|
|
|
* Normalize a {@link InputFileLike} to `InputFile`,
|
|
|
|
* uploading it if needed.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-06-24 00:15:12 +03:00
|
|
|
*/
|
|
|
|
_normalizeInputFile(
|
|
|
|
input: InputFileLike,
|
|
|
|
params: {
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
|
|
|
fileName?: string
|
|
|
|
fileSize?: number
|
|
|
|
fileMime?: string
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-06-24 00:15:12 +03:00
|
|
|
): Promise<tl.TypeInputFile>
|
|
|
|
/**
|
|
|
|
* Normalize an {@link InputMediaLike} to `InputMedia`,
|
|
|
|
* uploading the file if needed.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-06-24 00:15:12 +03:00
|
|
|
*/
|
|
|
|
_normalizeInputMedia(
|
|
|
|
media: InputMediaLike,
|
|
|
|
params: {
|
|
|
|
parseMode?: string | null
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2021-07-10 01:09:49 +03:00
|
|
|
uploadPeer?: tl.TypeInputPeer
|
2021-06-24 00:15:12 +03:00
|
|
|
},
|
2023-09-24 01:32:22 +03:00
|
|
|
uploadMedia?: boolean,
|
2021-06-24 00:15:12 +03:00
|
|
|
): Promise<tl.TypeInputMedia>
|
2023-10-05 04:00:58 +03:00
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Upload a file to Telegram servers, without actually
|
|
|
|
* sending a message anywhere. Useful when an `InputFile` is required.
|
|
|
|
*
|
|
|
|
* This method is quite low-level, and you should use other
|
2021-06-24 00:13:10 +03:00
|
|
|
* methods like {@link sendMedia} that handle this under the hood.
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param params Upload parameters
|
|
|
|
*/
|
|
|
|
uploadFile(params: {
|
|
|
|
/**
|
|
|
|
* Upload file source.
|
|
|
|
*
|
|
|
|
* > **Note**: `fs.ReadStream` is a subclass of `stream.Readable` and contains
|
|
|
|
* > info about file name, thus you don't need to pass them explicitly.
|
|
|
|
*/
|
|
|
|
file: UploadFileLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* File name for the uploaded file. Is usually inferred from path,
|
|
|
|
* but should be provided for files sent as `Buffer` or stream.
|
|
|
|
*
|
|
|
|
* When file name can't be inferred, it falls back to "unnamed"
|
|
|
|
*/
|
|
|
|
fileName?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Total file size. Automatically inferred for Buffer, File and local files.
|
|
|
|
*/
|
|
|
|
fileSize?: number
|
|
|
|
|
2023-08-23 22:11:42 +03:00
|
|
|
/**
|
|
|
|
* If the file size is unknown, you can provide an estimate,
|
|
|
|
* which will be used to determine appropriate part size.
|
|
|
|
*/
|
|
|
|
estimatedSize?: number
|
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* File MIME type. By default is automatically inferred from magic number
|
|
|
|
* If MIME can't be inferred, it defaults to `application/octet-stream`
|
|
|
|
*/
|
|
|
|
fileMime?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload part size (in KB).
|
|
|
|
*
|
|
|
|
* By default, automatically selected by file size.
|
|
|
|
* Must not be bigger than 512 and must not be a fraction.
|
|
|
|
*/
|
|
|
|
partSize?: number
|
|
|
|
|
2023-08-23 22:11:42 +03:00
|
|
|
/**
|
|
|
|
* Number of parts to be sent in parallel per connection.
|
|
|
|
*/
|
|
|
|
requestsPerConnection?: number
|
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Function that will be called after some part has been uploaded.
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes already uploaded
|
2023-08-23 22:11:42 +03:00
|
|
|
* @param total Total file size, if known
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2021-04-18 16:59:05 +03:00
|
|
|
}): Promise<UploadedFile>
|
2021-07-02 17:04:45 +03:00
|
|
|
/**
|
|
|
|
* Upload a media to Telegram servers, without actually
|
|
|
|
* sending a message anywhere. Useful when File ID is needed.
|
|
|
|
*
|
|
|
|
* The difference with {@link uploadFile} is that
|
|
|
|
* the returned object will act like a message media
|
|
|
|
* and contain fields like File ID.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-07-02 17:04:45 +03:00
|
|
|
* @param media Media to upload
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [params={}] Upload parameters
|
2021-07-02 17:04:45 +03:00
|
|
|
*/
|
|
|
|
uploadMedia(
|
|
|
|
media: InputMediaLike,
|
|
|
|
params?: {
|
|
|
|
peer?: InputPeerLike
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-07-02 17:04:45 +03:00
|
|
|
): Promise<Extract<MessageMedia, Photo | RawDocument>>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Create a topic in a forum
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @returns Service message for the created topic
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
createForumTopic(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
2023-10-03 00:58:45 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Topic title
|
|
|
|
*/
|
|
|
|
title: string
|
2023-10-03 00:58:45 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Icon of the topic.
|
|
|
|
*
|
|
|
|
* Can be a number (color in RGB, see {@link ForumTopic} static members for allowed values)
|
|
|
|
* or a custom emoji ID.
|
|
|
|
*
|
|
|
|
* Icon color can't be changed after the topic is created.
|
|
|
|
*/
|
|
|
|
icon?: number | tl.Long
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send as a specific channel
|
|
|
|
*/
|
|
|
|
sendAs?: InputPeerLike
|
|
|
|
}): Promise<Message>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Delete a forum topic and all its history
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chat Chat or user ID, username, phone number, `"me"` or `"self"`
|
|
|
|
* @param topicId ID of the topic (i.e. its top message ID)
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
deleteForumTopicHistory(chat: InputPeerLike, topicId: number | ForumTopic): Promise<void>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Modify a topic in a forum
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param topicId ID of the topic (i.e. its top message ID)
|
|
|
|
* @returns Service message about the modification
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
editForumTopic(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
2023-10-09 21:44:38 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/** ID of the topic (i.e. its top message ID) */
|
2023-10-09 21:44:38 +03:00
|
|
|
topicId: number | ForumTopic
|
2023-10-03 00:58:45 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* New topic title
|
|
|
|
*/
|
|
|
|
title?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New icon of the topic.
|
|
|
|
*
|
|
|
|
* Can be a custom emoji ID, or `null` to remove the icon
|
|
|
|
* and use static color instead
|
|
|
|
*/
|
|
|
|
icon?: tl.Long | null
|
|
|
|
}): Promise<Message>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Get a single forum topic by its ID
|
|
|
|
*
|
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
|
|
|
getForumTopicsById(chatId: InputPeerLike, ids: number): Promise<ForumTopic>
|
|
|
|
/**
|
|
|
|
* Get forum topics by their IDs
|
|
|
|
*
|
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
|
|
|
getForumTopicsById(chatId: InputPeerLike, ids: number[]): Promise<ForumTopic[]>
|
|
|
|
/**
|
|
|
|
* Get forum topics
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
|
|
|
getForumTopics(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Search query
|
|
|
|
*/
|
|
|
|
query?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset for pagination
|
|
|
|
*/
|
|
|
|
offset?: GetForumTopicsOffset
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of topics to return.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
},
|
|
|
|
): Promise<ArrayPaginated<ForumTopic, GetForumTopicsOffset>>
|
|
|
|
/**
|
|
|
|
* Iterate over forum topics. Wrapper over {@link getForumTopics}.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
*/
|
|
|
|
iterForumTopics(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getForumTopics>[2] & {
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Maximum number of topics to return.
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. return all topics
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size. Usually you shouldn't care about this.
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<ForumTopic>
|
|
|
|
/**
|
|
|
|
* Reorder pinned forum topics
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
reorderPinnedForumTopics(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
2023-10-03 00:58:45 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Order of the pinned topics
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
order: (number | ForumTopic)[]
|
2023-10-07 00:22:08 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to un-pin topics not present in the order
|
|
|
|
*/
|
|
|
|
force?: boolean
|
|
|
|
}): Promise<void>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Toggle open/close status of a topic in a forum
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @returns Service message about the modification
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
toggleForumTopicClosed(parmas: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** ID of the topic (i.e. its top message ID) */
|
2023-10-09 21:44:38 +03:00
|
|
|
topicId: number | ForumTopic
|
2023-10-07 00:22:08 +03:00
|
|
|
|
|
|
|
/** Whether the topic should be closed */
|
|
|
|
closed: boolean
|
|
|
|
}): Promise<Message>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Toggle whether a topic in a forum is pinned
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
toggleForumTopicPinned(params: {
|
|
|
|
/** Chat ID or username */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** ID of the topic (i.e. its top message ID) */
|
2023-10-09 21:44:38 +03:00
|
|
|
topicId: number | ForumTopic
|
2023-10-07 00:22:08 +03:00
|
|
|
/** Whether the topic should be pinned */
|
|
|
|
pinned: boolean
|
|
|
|
}): Promise<void>
|
2023-10-03 00:58:45 +03:00
|
|
|
/**
|
|
|
|
* Set whether a supergroup is a forum.
|
|
|
|
*
|
|
|
|
* Only owner of the supergroup can change this setting.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chatId Chat ID or username
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [enabled=false] Whether the supergroup should be a forum
|
2023-10-03 00:58:45 +03:00
|
|
|
*/
|
|
|
|
toggleForum(chatId: InputPeerLike, enabled?: boolean): Promise<void>
|
|
|
|
/**
|
|
|
|
* Toggle whether "General" topic in a forum is hidden or not
|
|
|
|
*
|
|
|
|
* Only admins with `manageTopics` permission can do this.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 00:58:45 +03:00
|
|
|
* @param chatId Chat ID or username
|
|
|
|
* @param hidden Whether the topic should be hidden
|
|
|
|
* @returns Service message about the modification
|
|
|
|
*/
|
|
|
|
toggleGeneralTopicHidden(chatId: InputPeerLike, hidden: boolean): Promise<Message>
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Create an additional invite link for the chat.
|
|
|
|
*
|
|
|
|
* You must be an administrator and have appropriate rights.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
createInviteLink(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Date when this link will expire.
|
|
|
|
* If `number` is passed, UNIX time in ms is expected.
|
|
|
|
*/
|
|
|
|
expires?: number | Date
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of users that can be members of this chat
|
|
|
|
* at the same time after joining using this link.
|
|
|
|
*
|
|
|
|
* Integer in range `[1, 99999]` or `Infinity`, defaults to `Infinity`
|
|
|
|
*/
|
|
|
|
usageLimit?: number
|
2022-05-09 17:25:38 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether users to be joined via this link need to be
|
|
|
|
* approved by an admin
|
|
|
|
*/
|
|
|
|
withApproval?: boolean
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-10 00:35:29 +03:00
|
|
|
): Promise<ChatInviteLink>
|
|
|
|
/**
|
|
|
|
* Edit an invite link. You can only edit non-primary
|
|
|
|
* invite links.
|
|
|
|
*
|
|
|
|
* Only pass the fields that you want to modify.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param link Invite link to edit
|
|
|
|
* @param params
|
|
|
|
* @returns Modified invite link
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
editInviteLink(params: {
|
|
|
|
/** Chat ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** Invite link to edit */
|
2023-10-09 21:44:38 +03:00
|
|
|
link: string | ChatInviteLink
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Date when this link will expire.
|
|
|
|
* If `number` is passed, UNIX time in ms is expected.
|
|
|
|
*/
|
|
|
|
expires?: number | Date
|
2021-05-10 00:35:29 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Maximum number of users that can be members of this chat
|
|
|
|
* at the same time after joining using this link.
|
|
|
|
*
|
|
|
|
* Integer in range `[1, 99999]` or `Infinity`,
|
|
|
|
*/
|
|
|
|
usageLimit?: number
|
2022-05-09 17:25:38 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Whether users to be joined via this link need to be
|
|
|
|
* approved by an admin
|
|
|
|
*/
|
|
|
|
withApproval?: boolean
|
|
|
|
}): Promise<ChatInviteLink>
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Generate a new primary invite link for a chat,
|
|
|
|
* old primary link is revoked.
|
|
|
|
*
|
|
|
|
* > **Note**: each administrator has their own primary invite link,
|
|
|
|
* > and bots by default don't have one.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-10 14:27:57 +03:00
|
|
|
* @param chatId Chat IDs
|
2021-05-10 00:35:29 +03:00
|
|
|
*/
|
|
|
|
exportInviteLink(chatId: InputPeerLike): Promise<ChatInviteLink>
|
|
|
|
/**
|
|
|
|
* Iterate over users who have joined
|
|
|
|
* the chat with the given invite link.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
2022-05-09 17:25:38 +03:00
|
|
|
* @param params Additional params
|
2021-05-10 00:35:29 +03:00
|
|
|
*/
|
|
|
|
getInviteLinkMembers(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-07 00:22:08 +03:00
|
|
|
params?: {
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Invite link for which to get members
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
link?: string | ChatInviteLink
|
2022-05-09 17:25:38 +03:00
|
|
|
|
|
|
|
/**
|
2023-09-29 17:02:36 +03:00
|
|
|
* Maximum number of users to return
|
|
|
|
*
|
|
|
|
* @default 100
|
2022-05-09 17:25:38 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Offset request/join date used as an anchor for pagination.
|
|
|
|
*/
|
|
|
|
offsetDate?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset user used as an anchor for pagination
|
|
|
|
*/
|
|
|
|
offsetUser?: tl.TypeInputUser
|
|
|
|
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Whether to get users who have requested to join
|
|
|
|
* the chat but weren't accepted yet
|
|
|
|
*/
|
|
|
|
requested?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search for a user in the pending join requests list
|
2023-09-29 17:02:36 +03:00
|
|
|
* (if passed, {@link requested} is assumed to be true)
|
2022-05-09 17:25:38 +03:00
|
|
|
*
|
2022-08-18 19:52:24 +03:00
|
|
|
* Doesn't work when {@link link} is set (Telegram limitation)
|
2022-05-09 17:25:38 +03:00
|
|
|
*/
|
|
|
|
requestedSearch?: string
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-09-29 21:45:11 +03:00
|
|
|
): Promise<ArrayPaginated<ChatInviteLinkMember, { date: number; user: tl.TypeInputUser }>>
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Get detailed information about an invite link
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param link The invite link
|
|
|
|
*/
|
|
|
|
getInviteLink(chatId: InputPeerLike, link: string): Promise<ChatInviteLink>
|
|
|
|
/**
|
|
|
|
* Get invite links created by some administrator in the chat.
|
|
|
|
*
|
|
|
|
* As an administrator you can only get your own links
|
|
|
|
* (i.e. `adminId = "self"`), as a creator you can get
|
|
|
|
* any other admin's links.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param adminId Admin who created the links
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
getInviteLinks(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Only return this admin's links.
|
|
|
|
*
|
|
|
|
* @default `"self"`
|
|
|
|
*/
|
|
|
|
admin?: InputPeerLike
|
|
|
|
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Whether to fetch revoked invite links
|
|
|
|
*/
|
|
|
|
revoked?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Limit the number of invite links to be fetched.
|
2023-09-29 17:02:36 +03:00
|
|
|
*
|
|
|
|
* @default 100
|
2021-05-10 00:35:29 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Offset for pagination.
|
2021-05-10 00:35:29 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
offset?: GetInviteLinksOffset
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-10-02 18:00:00 +03:00
|
|
|
): Promise<ArrayPaginated<ChatInviteLink, GetInviteLinksOffset>>
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Get primary invite link of a chat
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
*/
|
|
|
|
getPrimaryInviteLink(chatId: InputPeerLike): Promise<ChatInviteLink>
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Approve or deny multiple join requests to a chat.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-09 17:25:38 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
hideAllJoinRequests(params: {
|
|
|
|
/** Chat/channel ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
|
|
|
|
/** Whether to approve or deny the join requests */
|
|
|
|
action: 'approve' | 'deny'
|
|
|
|
|
|
|
|
/** Invite link to target */
|
2023-10-09 21:44:38 +03:00
|
|
|
link?: string | ChatInviteLink
|
2023-10-07 00:22:08 +03:00
|
|
|
}): Promise<void>
|
2022-05-09 17:25:38 +03:00
|
|
|
/**
|
|
|
|
* Approve or deny join request to a chat.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2022-05-09 17:25:38 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
hideJoinRequest(params: {
|
|
|
|
/** Chat/channel ID */
|
|
|
|
chatId: InputPeerLike
|
|
|
|
/** User ID */
|
|
|
|
user: InputPeerLike
|
|
|
|
/** Whether to approve or deny the join request */
|
|
|
|
action: 'approve' | 'deny'
|
|
|
|
}): Promise<void>
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Iterate over users who have joined
|
|
|
|
* the chat with the given invite link.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param params Additional params
|
|
|
|
*/
|
|
|
|
iterInviteLinkMembers(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getInviteLinkMembers>[2] & {
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Maximum number of users to return
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. all users are fetched
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size which will be passed to `messages.getChatInviteImporters`.
|
|
|
|
* You shouldn't usually care about this.
|
|
|
|
*
|
|
|
|
* @default 100.
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<ChatInviteLinkMember>
|
|
|
|
/**
|
|
|
|
* Iterate over invite links created by some administrator in the chat.
|
|
|
|
*
|
|
|
|
* As an administrator you can only get your own links
|
|
|
|
* (i.e. `adminId = "self"`), as a creator you can get
|
|
|
|
* any other admin's links.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-09-29 17:02:36 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param adminId Admin who created the links
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
iterInviteLinks(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getInviteLinks>[2] & {
|
2023-09-29 17:02:36 +03:00
|
|
|
/**
|
|
|
|
* Limit the number of invite links to be fetched.
|
|
|
|
* By default, all links are fetched.
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of chunks which are fetched. Usually not needed.
|
|
|
|
*
|
|
|
|
* Defaults to `100`
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<ChatInviteLink>
|
2021-05-10 00:35:29 +03:00
|
|
|
/**
|
|
|
|
* Revoke an invite link.
|
|
|
|
*
|
|
|
|
* If `link` is a primary invite link, a new invite link will be
|
|
|
|
* generated automatically by Telegram
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-10 00:35:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param link Invite link to revoke
|
|
|
|
* @returns If `link` is a primary invite, newly generated invite link, otherwise the revoked link
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
revokeInviteLink(chatId: InputPeerLike, link: string | ChatInviteLink): Promise<ChatInviteLink>
|
2021-05-08 13:19:37 +03:00
|
|
|
/**
|
|
|
|
* Close a poll sent by you.
|
|
|
|
*
|
|
|
|
* Once closed, poll can't be re-opened, and nobody
|
|
|
|
* will be able to vote in it
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-08 13:19:37 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
closePoll(params: InputMessageId): Promise<Poll>
|
2021-04-08 20:25:15 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Delete messages by their IDs
|
2021-04-08 20:25:15 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 20:25:15 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param ids Message(s) ID(s) to delete.
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
deleteMessagesById(chatId: InputPeerLike, ids: number[], params?: DeleteMessagesParams): Promise<void>
|
2021-07-10 15:00:40 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Delete one or more {@link Message}
|
|
|
|
*
|
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
|
|
|
* @param messages Message(s) to delete
|
|
|
|
*/
|
|
|
|
deleteMessages(messages: Message[], params?: DeleteMessagesParams): Promise<void>
|
|
|
|
/**
|
|
|
|
* Delete scheduled messages by their IDs.
|
2021-07-10 15:00:40 +03:00
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-07-10 15:00:40 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param ids Message(s) ID(s) to delete.
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
deleteScheduledMessages(chatId: InputPeerLike, ids: number[]): Promise<void>
|
2021-05-04 14:07:40 +03:00
|
|
|
/**
|
|
|
|
* Edit sent inline message text, media and reply markup.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-16 02:09:51 +03:00
|
|
|
* @param messageId
|
2021-05-04 14:07:40 +03:00
|
|
|
* Inline message ID, either as a TL object, or as a
|
|
|
|
* TDLib and Bot API compatible string
|
|
|
|
* @param params
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
editInlineMessage(params: {
|
|
|
|
/**
|
|
|
|
* Inline message ID, either as a TL object, or as a
|
|
|
|
* TDLib and Bot API compatible string
|
|
|
|
*/
|
|
|
|
messageId: tl.TypeInputBotInlineMessageID | string
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* New message text
|
|
|
|
*
|
|
|
|
* When `media` is passed, `media.caption` is used instead
|
|
|
|
*/
|
|
|
|
text?: string | FormattedString<string>
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* List of formatting entities to use instead of parsing via a
|
|
|
|
* parse mode.
|
|
|
|
*
|
|
|
|
* **Note:** Passing this makes the method ignore {@link parseMode}
|
|
|
|
*
|
|
|
|
* When `media` is passed, `media.entities` is used instead
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* New message media
|
|
|
|
*/
|
|
|
|
media?: InputMediaLike
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* Whether to disable links preview in this message
|
|
|
|
*/
|
|
|
|
disableWebPreview?: boolean
|
2021-05-04 14:07:40 +03:00
|
|
|
|
2023-10-07 00:22:08 +03:00
|
|
|
/**
|
|
|
|
* For bots: new reply markup.
|
|
|
|
* If omitted, existing markup will be removed.
|
|
|
|
*/
|
|
|
|
replyMarkup?: ReplyMarkup
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For media, upload progress callback.
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes uploaded
|
|
|
|
* @param total Total file size in bytes
|
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
|
|
|
}): Promise<void>
|
2021-04-09 23:19:58 +03:00
|
|
|
/**
|
2021-05-03 14:30:12 +03:00
|
|
|
* Edit message text, media, reply markup and schedule date.
|
2021-04-09 23:19:58 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-09 23:19:58 +03:00
|
|
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param message Message or its ID
|
|
|
|
* @param params
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
editMessage(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/**
|
|
|
|
* New message text
|
|
|
|
*
|
|
|
|
* When `media` is passed, `media.caption` is used instead
|
|
|
|
*/
|
|
|
|
text?: string | FormattedString<string>
|
2021-04-09 23:19:58 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
2021-04-09 23:19:58 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* List of formatting entities to use instead of parsing via a
|
|
|
|
* parse mode.
|
|
|
|
*
|
|
|
|
* **Note:** Passing this makes the method ignore {@link parseMode}
|
|
|
|
*
|
|
|
|
* When `media` is passed, `media.entities` is used instead
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
2021-05-03 14:30:12 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* New message media
|
|
|
|
*/
|
|
|
|
media?: InputMediaLike
|
2021-04-09 23:19:58 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* Whether to disable links preview in this message
|
|
|
|
*/
|
|
|
|
disableWebPreview?: boolean
|
2021-05-03 14:30:12 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* For bots: new reply markup.
|
|
|
|
* If omitted, existing markup will be removed.
|
|
|
|
*/
|
|
|
|
replyMarkup?: ReplyMarkup
|
2021-05-03 14:30:12 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* To re-schedule a message: new schedule date.
|
|
|
|
* When passing a number, a UNIX time in ms is expected.
|
|
|
|
*/
|
|
|
|
scheduleDate?: Date | number
|
2023-10-07 00:22:08 +03:00
|
|
|
|
2023-10-09 21:44:38 +03:00
|
|
|
/**
|
|
|
|
* For media, upload progress callback.
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes uploaded
|
|
|
|
* @param total Total file size in bytes
|
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
|
|
|
},
|
|
|
|
): Promise<Message>
|
2022-09-12 19:50:39 +03:00
|
|
|
|
|
|
|
_findMessageInUpdate(res: tl.TypeUpdates, isEdit?: boolean): Message
|
2021-04-24 19:00:11 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Forward one or more messages by their IDs.
|
2021-04-24 21:11:34 +03:00
|
|
|
* You can forward no more than 100 messages at once.
|
2021-04-24 19:00:11 +03:00
|
|
|
*
|
|
|
|
* If a caption message was sent, it will be the first message in the resulting array.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-24 19:00:11 +03:00
|
|
|
* @param toChatId Destination chat ID, username, phone, `"me"` or `"self"`
|
|
|
|
* @param fromChatId Source chat ID, username, phone, `"me"` or `"self"`
|
|
|
|
* @param messages Message IDs
|
|
|
|
* @param params Additional sending parameters
|
2023-10-09 21:44:38 +03:00
|
|
|
* @returns Newly sent, forwarded messages in the destination chat.
|
|
|
|
*/
|
|
|
|
forwardMessagesById(
|
|
|
|
params: ForwardMessageOptions & {
|
|
|
|
/** Source chat ID, username, phone, `"me"` or `"self"` */
|
|
|
|
fromChatId: InputPeerLike
|
|
|
|
/** Message IDs to forward */
|
|
|
|
messages: number[]
|
|
|
|
},
|
|
|
|
): Promise<Message[]>
|
|
|
|
/**
|
|
|
|
* Forward one or more {@link Message}s to another chat.
|
|
|
|
*
|
|
|
|
* > **Note**: all messages must be from the same chat.
|
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-24 19:00:11 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
forwardMessages(
|
|
|
|
params: ForwardMessageOptions & {
|
|
|
|
messages: Message[]
|
|
|
|
},
|
|
|
|
): Promise<Message[]>
|
2022-09-12 19:50:39 +03:00
|
|
|
|
2023-09-24 01:32:22 +03:00
|
|
|
_getDiscussionMessage(peer: InputPeerLike, message: number): Promise<[tl.TypeInputPeer, number]>
|
2021-07-25 14:00:51 +03:00
|
|
|
// public version of the same method because why not
|
|
|
|
/**
|
|
|
|
* Get discussion message for some channel post.
|
|
|
|
*
|
|
|
|
* Returns `null` if the post does not have a discussion
|
|
|
|
* message.
|
|
|
|
*
|
|
|
|
* This method might throw `FLOOD_WAIT_X` error in case
|
|
|
|
* the discussion message was not *yet* created. Error
|
|
|
|
* is usually handled by the client, but if you disabled that,
|
|
|
|
* you'll need to handle it manually.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-07-25 14:00:51 +03:00
|
|
|
* @param peer Channel where the post was found
|
|
|
|
* @param message ID of the channel post
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getDiscussionMessage(params: InputMessageId): Promise<Message | null>
|
2021-04-08 20:25:15 +03:00
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Get chat history.
|
2021-04-08 20:25:15 +03:00
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 20:25:15 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param params Additional fetch parameters
|
|
|
|
*/
|
|
|
|
getHistory(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default 100
|
2021-04-08 20:25:15 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
2021-04-08 12:19:38 +03:00
|
|
|
|
2021-04-08 20:25:15 +03:00
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Offset for pagination
|
2021-04-08 20:25:15 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
offset?: GetHistoryOffset
|
2021-04-08 20:25:15 +03:00
|
|
|
|
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Additional offset from {@link offset}, in resulting messages.
|
|
|
|
*
|
|
|
|
* This can be used for advanced use cases, like:
|
|
|
|
* - Loading 20 messages newer than message with ID `MSGID`:
|
|
|
|
* `offset = MSGID, addOffset = -20, limit = 20`
|
|
|
|
* - Loading 20 messages around message with ID `MSGID`:
|
|
|
|
* `offset = MSGID, addOffset = -10, limit = 20`
|
|
|
|
*
|
|
|
|
* @default `0` (disabled)
|
2021-04-08 20:25:15 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
|
|
|
|
addOffset?: number
|
2021-04-08 20:25:15 +03:00
|
|
|
|
2022-07-23 02:22:20 +03:00
|
|
|
/**
|
|
|
|
* Minimum message ID to return
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `0` (disabled).
|
2022-07-23 02:22:20 +03:00
|
|
|
*/
|
|
|
|
minId?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum message ID to return.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* Unless {@link addOffset} is used, this will work the same as {@link offset}.
|
2022-07-23 02:22:20 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `0` (disabled).
|
2022-07-23 02:22:20 +03:00
|
|
|
*/
|
|
|
|
maxId?: number
|
|
|
|
|
2021-04-08 20:25:15 +03:00
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Whether to retrieve messages in reversed order (from older to recent),
|
|
|
|
* starting from {@link offset} (inclusive).
|
2022-07-23 02:22:20 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* > **Note**: Using `reverse=true` requires you to pass offset from which to start
|
|
|
|
* > fetching the messages "downwards". If you call `getHistory` with `reverse=true`
|
|
|
|
* > and without any offset, it will return an empty array.
|
|
|
|
*
|
|
|
|
* @default false
|
2022-07-23 02:22:20 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
reverse?: boolean
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-10-02 18:00:00 +03:00
|
|
|
): Promise<ArrayPaginated<Message, GetHistoryOffset>>
|
2021-05-09 18:29:33 +03:00
|
|
|
/**
|
|
|
|
* Get all messages inside of a message group
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-09 18:29:33 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param message ID of one of the messages in the group
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessageGroup(params: InputMessageId): Promise<Message[]>
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Get reactions to messages by their IDs.
|
2022-05-12 10:09:37 +03:00
|
|
|
*
|
|
|
|
* > Apps should short-poll reactions for visible messages
|
|
|
|
* > (that weren't sent by the user) once every 15-30 seconds,
|
|
|
|
* > but only if `message.reactions` is set
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: 👤 users only
|
|
|
|
*
|
|
|
|
* @param chatId ID of the chat with messages
|
|
|
|
* @param messages Message IDs
|
|
|
|
* @returns Reactions to corresponding messages, or `null` if there are none
|
2022-05-12 10:09:37 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessageReactionsById(chatId: InputPeerLike, messages: number[]): Promise<(MessageReactions | null)[]>
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Get reactions to {@link Message}s.
|
|
|
|
*
|
|
|
|
* > **Note**: messages must all be from the same chat.
|
2022-05-12 10:09:37 +03:00
|
|
|
*
|
|
|
|
* > Apps should short-poll reactions for visible messages
|
|
|
|
* > (that weren't sent by the user) once every 15-30 seconds,
|
|
|
|
* > but only if `message.reactions` is set
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2022-05-12 10:09:37 +03:00
|
|
|
* @param chatId ID of the chat with messages
|
|
|
|
* @param messages Message IDs
|
|
|
|
* @returns Reactions to corresponding messages, or `null` if there are none
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessageReactions(messages: Message[]): Promise<(MessageReactions | null)[]>
|
2021-07-06 02:24:58 +03:00
|
|
|
/**
|
|
|
|
* Get messages from PM or legacy group by their IDs.
|
|
|
|
* For channels, use {@link getMessages}.
|
|
|
|
*
|
|
|
|
* Unlike {@link getMessages}, this method does not
|
|
|
|
* check if the message belongs to some chat.
|
|
|
|
*
|
|
|
|
* Fot messages that were not found, `null` will be
|
|
|
|
* returned at that position.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* @param messageIds Messages IDs
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param [fromReply=false]
|
|
|
|
* Whether the reply to a given message should be fetched
|
|
|
|
* (i.e. `getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId`)
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessagesUnsafe(messageIds: MaybeArray<number>, fromReply?: boolean): Promise<(Message | null)[]>
|
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get messages in chat by their IDs
|
|
|
|
*
|
2021-07-06 02:24:58 +03:00
|
|
|
* Fot messages that were not found, `null` will be
|
|
|
|
* returned at that position.
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param messageIds Messages IDs
|
|
|
|
* @param [fromReply=false]
|
|
|
|
* Whether the reply to a given message should be fetched
|
|
|
|
* (i.e. `getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId`)
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessages(chatId: InputPeerLike, messageIds: MaybeArray<number>, fromReply?: boolean): Promise<(Message | null)[]>
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
|
|
|
* Get users who have reacted to the message.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-12 10:09:37 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
getReactionUsers(
|
2023-10-09 21:44:38 +03:00
|
|
|
params: InputMessageId & {
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
|
|
|
* Get only reactions with the specified emoji
|
|
|
|
*/
|
2023-10-01 16:36:29 +03:00
|
|
|
emoji?: InputReaction
|
2022-09-12 13:54:33 +03:00
|
|
|
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Limit the number of users returned.
|
2022-05-12 10:09:37 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default 100
|
2022-05-12 10:09:37 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Offset for pagination
|
2022-05-12 10:09:37 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
offset?: GetReactionUsersOffset
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-10-02 18:00:00 +03:00
|
|
|
): Promise<ArrayPaginated<PeerReaction, GetReactionUsersOffset>>
|
2021-07-10 01:19:59 +03:00
|
|
|
/**
|
|
|
|
* Get scheduled messages in chat by their IDs
|
|
|
|
*
|
|
|
|
* Fot messages that were not found, `null` will be
|
|
|
|
* returned at that position.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: 👤 users only
|
|
|
|
*
|
2021-07-10 01:19:59 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param messageIds Scheduled messages IDs
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getScheduledMessages(chatId: InputPeerLike, messageIds: MaybeArray<number>): Promise<(Message | null)[]>
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Iterate over chat history. Wrapper over {@link getHistory}
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param params Additional fetch parameters
|
|
|
|
*/
|
|
|
|
iterHistory(
|
|
|
|
chatId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getHistory>[2] & {
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
|
|
|
* @default Infinity, i.e. all messages
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size. Usually you shouldn't care about this.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<Message>
|
|
|
|
/**
|
|
|
|
* Iterate over users who have reacted to the message.
|
|
|
|
*
|
|
|
|
* Wrapper over {@link getReactionUsers}.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
* @param messageId Message ID
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
iterReactionUsers(
|
2023-10-09 21:44:38 +03:00
|
|
|
params: Parameters<typeof getReactionUsers>[1] & {
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Limit the number of events returned.
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. all events are returned
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size, usually not needed.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<PeerReaction>
|
|
|
|
/**
|
|
|
|
* Search for messages globally from all of your chats.
|
|
|
|
*
|
|
|
|
* Iterable version of {@link searchGlobal}
|
|
|
|
*
|
|
|
|
* **Note**: Due to Telegram limitations, you can only get up to ~10000 messages
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @param params Search parameters
|
|
|
|
*/
|
|
|
|
iterSearchGlobal(
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof searchGlobal>[1] & {
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. all messages are returned
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size, which will be passed as `limit` parameter
|
|
|
|
* for `messages.search`. Usually you shouldn't care about this.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<Message>
|
|
|
|
/**
|
|
|
|
* Search for messages inside a specific chat
|
|
|
|
*
|
|
|
|
* Iterable version of {@link searchMessages}
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param params Additional search parameters
|
|
|
|
*/
|
|
|
|
iterSearchMessages(
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof searchMessages>[1] & {
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. all messages are returned
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Chunk size, which will be passed as `limit` parameter
|
|
|
|
* for `messages.search`. Usually you shouldn't care about this.
|
|
|
|
*
|
|
|
|
* @default `100`
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<Message>
|
2022-09-12 19:50:39 +03:00
|
|
|
|
|
|
|
_parseEntities(
|
2023-06-05 03:30:48 +03:00
|
|
|
text?: string | FormattedString<string>,
|
2022-09-12 19:50:39 +03:00
|
|
|
mode?: string | null,
|
2023-09-24 01:32:22 +03:00
|
|
|
entities?: tl.TypeMessageEntity[],
|
2022-09-12 19:50:39 +03:00
|
|
|
): Promise<[string, tl.TypeMessageEntity[] | undefined]>
|
2021-04-11 16:25:17 +03:00
|
|
|
/**
|
|
|
|
* Pin a message in a group, supergroup, channel or PM.
|
|
|
|
*
|
|
|
|
* For supergroups/channels, you must have appropriate permissions,
|
|
|
|
* either as an admin, or as default permissions
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 16:25:17 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
pinMessage(
|
2023-10-09 21:44:38 +03:00
|
|
|
params: InputMessageId & {
|
2023-10-07 00:22:08 +03:00
|
|
|
/** Whether to send a notification (only for legacy groups and supergroups) */
|
|
|
|
notify?: boolean
|
|
|
|
/** Whether to pin for both sides (only for private chats) */
|
|
|
|
bothSides?: boolean
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-05-12 22:31:29 +03:00
|
|
|
/**
|
|
|
|
* Mark chat history as read.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-12 22:31:29 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
readHistory(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Message up until which to read history
|
|
|
|
*
|
|
|
|
* @default 0, i.e. read everything
|
|
|
|
*/
|
|
|
|
maxId?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to also clear all mentions in the chat
|
|
|
|
*/
|
|
|
|
clearMentions?: boolean
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
|
|
|
* Mark all reactions in chat as read.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-12 10:09:37 +03:00
|
|
|
* @param chatId Chat ID
|
|
|
|
*/
|
|
|
|
readReactions(chatId: InputPeerLike): Promise<void>
|
2021-04-09 13:08:32 +03:00
|
|
|
/**
|
|
|
|
* Search for messages globally from all of your chats
|
|
|
|
*
|
|
|
|
* **Note**: Due to Telegram limitations, you can only get up to ~10000 messages
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-09 13:08:32 +03:00
|
|
|
* @param params Search parameters
|
|
|
|
*/
|
|
|
|
searchGlobal(params?: {
|
|
|
|
/**
|
|
|
|
* Text query string. Use `"@"` to search for mentions.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `""` (empty string)
|
2021-04-09 13:08:32 +03:00
|
|
|
*/
|
|
|
|
query?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default 100
|
2021-04-09 13:08:32 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the results using some filter.
|
|
|
|
* Defaults to {@link SearchFilters.Empty} (i.e. will return all messages)
|
|
|
|
*
|
|
|
|
* @link SearchFilters
|
|
|
|
*/
|
|
|
|
filter?: tl.TypeMessagesFilter
|
|
|
|
|
|
|
|
/**
|
2023-10-02 18:00:00 +03:00
|
|
|
* Offset data used for pagination
|
2021-04-09 13:08:32 +03:00
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
offset?: SearchGlobalOffset
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only return messages newer than this date
|
|
|
|
*/
|
|
|
|
minDate?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only return messages older than this date
|
|
|
|
*/
|
|
|
|
maxDate?: Date | number
|
|
|
|
}): Promise<ArrayPaginated<Message, SearchGlobalOffset>>
|
2021-04-08 22:56:40 +03:00
|
|
|
/**
|
|
|
|
* Search for messages inside a specific chat
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 22:56:40 +03:00
|
|
|
* @param chatId Chat's marked ID, its username, phone or `"me"` or `"self"`.
|
|
|
|
* @param params Additional search parameters
|
|
|
|
*/
|
2023-10-02 18:00:00 +03:00
|
|
|
searchMessages(params?: {
|
|
|
|
/**
|
|
|
|
* Text query string. Required for text-only messages,
|
|
|
|
* optional for media.
|
|
|
|
*
|
|
|
|
* @default `""` (empty string)
|
|
|
|
*/
|
|
|
|
query?: string
|
2021-04-08 22:56:40 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Chat where to search for messages.
|
|
|
|
*
|
|
|
|
* When empty, will search across common message box (i.e. private messages and legacy chats)
|
|
|
|
*/
|
|
|
|
chatId?: InputPeerLike
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Offset ID for the search. Only messages earlier than this ID will be returned.
|
|
|
|
*
|
|
|
|
* @default `0` (starting from the latest message).
|
|
|
|
*/
|
|
|
|
offset?: SearchMessagesOffset
|
2021-04-08 22:56:40 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Additional offset from {@link offset}, in resulting messages.
|
|
|
|
*
|
|
|
|
* This can be used for advanced use cases, like:
|
|
|
|
* - Loading 20 results newer than message with ID `MSGID`:
|
|
|
|
* `offset = MSGID, addOffset = -20, limit = 20`
|
|
|
|
* - Loading 20 results around message with ID `MSGID`:
|
|
|
|
* `offset = MSGID, addOffset = -10, limit = 20`
|
|
|
|
*
|
|
|
|
* When {@link offset} is not set, this will be relative to the last message
|
|
|
|
*
|
|
|
|
* @default `0` (disabled)
|
|
|
|
*/
|
|
|
|
addOffset?: number
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Minimum message ID to return
|
|
|
|
*
|
|
|
|
* @default `0` (disabled).
|
|
|
|
*/
|
|
|
|
minId?: number
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Maximum message ID to return.
|
|
|
|
*
|
|
|
|
* Unless {@link addOffset} is used, this will work the same as {@link offset}.
|
|
|
|
*
|
|
|
|
* @default `0` (disabled).
|
|
|
|
*/
|
|
|
|
maxId?: number
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Minimum message date to return
|
|
|
|
*
|
|
|
|
* Defaults to `0` (disabled).
|
|
|
|
*/
|
|
|
|
minDate?: number | Date
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Maximum message date to return
|
|
|
|
*
|
|
|
|
* Defaults to `0` (disabled).
|
|
|
|
*/
|
|
|
|
maxDate?: number | Date
|
2022-07-23 01:29:36 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Thread ID to return only messages from this thread.
|
|
|
|
*/
|
|
|
|
threadId?: number
|
2021-04-08 22:56:40 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Limits the number of messages to be retrieved.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
limit?: number
|
2021-04-08 22:56:40 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Filter the results using some filter.
|
|
|
|
* Defaults to {@link SearchFilters.Empty} (i.e. will return all messages)
|
|
|
|
*
|
|
|
|
* @link SearchFilters
|
|
|
|
*/
|
|
|
|
filter?: tl.TypeMessagesFilter
|
2021-04-08 22:56:40 +03:00
|
|
|
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Search only for messages sent by a specific user.
|
|
|
|
*
|
|
|
|
* You can pass their marked ID, username, phone or `"me"` or `"self"`
|
|
|
|
*/
|
|
|
|
fromUser?: InputPeerLike
|
|
|
|
}): Promise<ArrayPaginated<Message, SearchMessagesOffset>>
|
2021-05-08 16:35:25 +03:00
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Copy a message (i.e. send the same message, but do not forward it).
|
2021-05-08 16:35:25 +03:00
|
|
|
*
|
2021-05-08 17:54:18 +03:00
|
|
|
* Note that if the message contains a webpage,
|
|
|
|
* it will be copied simply as a text message,
|
|
|
|
* and if the message contains an invoice,
|
|
|
|
* it can't be copied.
|
2021-05-08 16:35:25 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-08 17:54:18 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
sendCopy(
|
|
|
|
params: SendCopyParams &
|
|
|
|
(
|
|
|
|
| {
|
|
|
|
/** Source chat ID */
|
|
|
|
fromChatId: InputPeerLike
|
|
|
|
/** Message ID to forward */
|
|
|
|
message: number
|
|
|
|
}
|
|
|
|
| { message: Message }
|
|
|
|
),
|
|
|
|
): Promise<Message>
|
2021-05-01 00:30:53 +03:00
|
|
|
/**
|
|
|
|
* Send a group of media.
|
|
|
|
*
|
2021-06-10 02:31:48 +03:00
|
|
|
* To add a caption to the group, add caption to the first
|
|
|
|
* media in the group and don't add caption for any other.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-01 00:30:53 +03:00
|
|
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param medias Medias contained in the message.
|
|
|
|
* @param params Additional sending parameters
|
2021-05-04 13:08:20 +03:00
|
|
|
* @link InputMedia
|
2021-05-01 00:30:53 +03:00
|
|
|
*/
|
|
|
|
sendMediaGroup(
|
|
|
|
chatId: InputPeerLike,
|
2021-06-10 02:31:48 +03:00
|
|
|
medias: (InputMediaLike | string)[],
|
2021-05-01 00:30:53 +03:00
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Message to reply to. Either a message object or message ID.
|
2023-10-03 00:58:45 +03:00
|
|
|
*
|
|
|
|
* For forums - can also be an ID of the topic (i.e. its top message ID)
|
2021-05-01 00:30:53 +03:00
|
|
|
*/
|
|
|
|
replyTo?: number | Message
|
|
|
|
|
2021-07-06 02:36:20 +03:00
|
|
|
/**
|
|
|
|
* Whether to throw an error if {@link replyTo}
|
|
|
|
* message does not exist.
|
|
|
|
*
|
|
|
|
* If that message was not found, `NotFoundError` is thrown,
|
|
|
|
* with `text` set to `MESSAGE_NOT_FOUND`.
|
|
|
|
*
|
|
|
|
* Incurs an additional request, so only use when really needed.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
mustReply?: boolean
|
|
|
|
|
2021-05-27 15:57:05 +03:00
|
|
|
/**
|
|
|
|
* Message to comment to. Either a message object or message ID.
|
|
|
|
*
|
|
|
|
* This overwrites `replyTo` if it was passed
|
|
|
|
*/
|
|
|
|
commentTo?: number | Message
|
|
|
|
|
2021-05-01 00:30:53 +03:00
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to send this message silently.
|
|
|
|
*/
|
|
|
|
silent?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If set, the message will be scheduled to this date.
|
|
|
|
* When passing a number, a UNIX time in ms is expected.
|
2021-05-25 11:58:14 +03:00
|
|
|
*
|
|
|
|
* You can also pass `0x7FFFFFFE`, this will send the message
|
|
|
|
* once the peer is online
|
2021-05-01 00:30:53 +03:00
|
|
|
*/
|
|
|
|
schedule?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that will be called after some part has been uploaded.
|
|
|
|
* Only used when a file that requires uploading is passed,
|
|
|
|
* and not used when uploading a thumbnail.
|
|
|
|
*
|
|
|
|
* @param index Index of the media in the original array
|
|
|
|
* @param uploaded Number of bytes already uploaded
|
|
|
|
* @param total Total file size
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
progressCallback?: (index: number, uploaded: number, total: number) => void
|
2021-05-01 00:30:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to clear draft after sending this message.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
clearDraft?: boolean
|
2022-06-21 21:07:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to disallow further forwards of this message.
|
|
|
|
*
|
|
|
|
* Only for bots, works even if the target chat does not
|
|
|
|
* have content protection.
|
|
|
|
*/
|
|
|
|
forbidForwards?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer to use when sending the message.
|
|
|
|
*/
|
|
|
|
sendAs?: InputPeerLike
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-16 14:43:23 +03:00
|
|
|
): Promise<Message[]>
|
2021-04-10 13:28:02 +03:00
|
|
|
/**
|
2021-04-30 23:57:24 +03:00
|
|
|
* Send a single media (a photo or a document-based media)
|
2021-04-10 13:28:02 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-10 13:28:02 +03:00
|
|
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
2021-04-30 20:51:50 +03:00
|
|
|
* @param media
|
|
|
|
* Media contained in the message. You can also pass TDLib
|
|
|
|
* and Bot API compatible File ID, which will be wrapped
|
|
|
|
* in {@link InputMedia.auto}
|
2021-04-10 13:28:02 +03:00
|
|
|
* @param params Additional sending parameters
|
2021-05-04 13:08:20 +03:00
|
|
|
* @link InputMedia
|
2021-04-10 13:28:02 +03:00
|
|
|
*/
|
|
|
|
sendMedia(
|
|
|
|
chatId: InputPeerLike,
|
2021-04-30 20:51:50 +03:00
|
|
|
media: InputMediaLike | string,
|
2021-04-10 13:28:02 +03:00
|
|
|
params?: {
|
2021-06-18 17:44:52 +03:00
|
|
|
/**
|
|
|
|
* Override caption for `media`.
|
|
|
|
*
|
|
|
|
* Can be used, for example. when using File IDs
|
|
|
|
* or when using existing InputMedia objects.
|
|
|
|
*/
|
2023-06-05 03:30:48 +03:00
|
|
|
caption?: string | FormattedString<string>
|
2021-06-18 17:44:52 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Override entities for `media`.
|
|
|
|
*
|
|
|
|
* Can be used, for example. when using File IDs
|
|
|
|
* or when using existing InputMedia objects.
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
|
|
|
|
2021-04-10 13:28:02 +03:00
|
|
|
/**
|
|
|
|
* Message to reply to. Either a message object or message ID.
|
2023-10-03 00:58:45 +03:00
|
|
|
*
|
|
|
|
* For forums - can also be an ID of the topic (i.e. its top message ID)
|
2021-04-10 13:28:02 +03:00
|
|
|
*/
|
|
|
|
replyTo?: number | Message
|
|
|
|
|
2021-07-06 02:36:20 +03:00
|
|
|
/**
|
|
|
|
* Whether to throw an error if {@link replyTo}
|
|
|
|
* message does not exist.
|
|
|
|
*
|
|
|
|
* If that message was not found, `NotFoundError` is thrown,
|
|
|
|
* with `text` set to `MESSAGE_NOT_FOUND`.
|
|
|
|
*
|
|
|
|
* Incurs an additional request, so only use when really needed.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
mustReply?: boolean
|
|
|
|
|
2021-05-27 15:57:05 +03:00
|
|
|
/**
|
|
|
|
* Message to comment to. Either a message object or message ID.
|
|
|
|
*
|
|
|
|
* This overwrites `replyTo` if it was passed
|
|
|
|
*/
|
|
|
|
commentTo?: number | Message
|
|
|
|
|
2021-04-10 13:28:02 +03:00
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to send this message silently.
|
|
|
|
*/
|
|
|
|
silent?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If set, the message will be scheduled to this date.
|
|
|
|
* When passing a number, a UNIX time in ms is expected.
|
2021-05-25 11:58:14 +03:00
|
|
|
*
|
|
|
|
* You can also pass `0x7FFFFFFE`, this will send the message
|
|
|
|
* once the peer is online
|
2021-04-10 13:28:02 +03:00
|
|
|
*/
|
|
|
|
schedule?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For bots: inline or reply markup or an instruction
|
|
|
|
* to hide a reply keyboard or to force a reply.
|
|
|
|
*/
|
|
|
|
replyMarkup?: ReplyMarkup
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function that will be called after some part has been uploaded.
|
|
|
|
* Only used when a file that requires uploading is passed,
|
|
|
|
* and not used when uploading a thumbnail.
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes already uploaded
|
|
|
|
* @param total Total file size
|
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2021-04-14 21:31:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to clear draft after sending this message.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
clearDraft?: boolean
|
2022-06-21 21:07:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to disallow further forwards of this message.
|
|
|
|
*
|
|
|
|
* Only for bots, works even if the target chat does not
|
|
|
|
* have content protection.
|
|
|
|
*/
|
|
|
|
forbidForwards?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer to use when sending the message.
|
|
|
|
*/
|
|
|
|
sendAs?: InputPeerLike
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-04-18 16:59:05 +03:00
|
|
|
): Promise<Message>
|
2022-05-12 10:09:37 +03:00
|
|
|
/**
|
|
|
|
* Send or remove a reaction.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-05-12 10:09:37 +03:00
|
|
|
* @returns Message to which the reaction was sent
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
sendReaction(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/** Reaction emoji (or `null` to remove reaction) */
|
|
|
|
emoji?: InputReaction | null
|
|
|
|
/** Whether to use a big reaction */
|
|
|
|
big?: boolean
|
|
|
|
},
|
|
|
|
): Promise<Message>
|
2021-07-10 01:19:59 +03:00
|
|
|
/**
|
|
|
|
* Send previously scheduled message(s)
|
|
|
|
*
|
|
|
|
* Note that if the message belongs to a media group,
|
|
|
|
* the entire group will be sent, and all the messages
|
|
|
|
* will be returned.
|
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: 👤 users only
|
|
|
|
*
|
2021-07-10 01:19:59 +03:00
|
|
|
* @param peer Chat where the messages were scheduled
|
|
|
|
* @param ids ID(s) of the messages
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
sendScheduled(peer: InputPeerLike, ids: MaybeArray<number>): Promise<Message[]>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Send a text message
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param chatId ID of the chat, its username, phone or `"me"` or `"self"`
|
|
|
|
* @param text Text of the message
|
|
|
|
* @param params Additional sending parameters
|
|
|
|
*/
|
|
|
|
sendText(
|
|
|
|
chatId: InputPeerLike,
|
2023-06-05 03:30:48 +03:00
|
|
|
text: string | FormattedString<string>,
|
2021-04-08 12:19:38 +03:00
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Message to reply to. Either a message object or message ID.
|
2023-10-03 00:58:45 +03:00
|
|
|
*
|
|
|
|
* For forums - can also be an ID of the topic (i.e. its top message ID)
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
|
|
|
replyTo?: number | Message
|
|
|
|
|
2021-07-06 02:24:58 +03:00
|
|
|
/**
|
|
|
|
* Whether to throw an error if {@link replyTo}
|
|
|
|
* message does not exist.
|
|
|
|
*
|
|
|
|
* If that message was not found, `NotFoundError` is thrown,
|
|
|
|
* with `text` set to `MESSAGE_NOT_FOUND`.
|
|
|
|
*
|
|
|
|
* Incurs an additional request, so only use when really needed.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
mustReply?: boolean
|
|
|
|
|
2021-05-27 15:57:05 +03:00
|
|
|
/**
|
|
|
|
* Message to comment to. Either a message object or message ID.
|
|
|
|
*
|
|
|
|
* This overwrites `replyTo` if it was passed
|
|
|
|
*/
|
|
|
|
commentTo?: number | Message
|
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of formatting entities to use instead of parsing via a
|
|
|
|
* parse mode.
|
|
|
|
*
|
|
|
|
* **Note:** Passing this makes the method ignore {@link parseMode}
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to disable links preview in this message
|
|
|
|
*/
|
|
|
|
disableWebPreview?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to send this message silently.
|
|
|
|
*/
|
|
|
|
silent?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If set, the message will be scheduled to this date.
|
|
|
|
* When passing a number, a UNIX time in ms is expected.
|
2021-05-25 11:58:14 +03:00
|
|
|
*
|
|
|
|
* You can also pass `0x7FFFFFFE`, this will send the message
|
|
|
|
* once the peer is online
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
|
|
|
schedule?: Date | number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For bots: inline or reply markup or an instruction
|
|
|
|
* to hide a reply keyboard or to force a reply.
|
|
|
|
*/
|
|
|
|
replyMarkup?: ReplyMarkup
|
2021-04-14 21:31:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to clear draft after sending this message.
|
|
|
|
*
|
|
|
|
* Defaults to `false`
|
|
|
|
*/
|
|
|
|
clearDraft?: boolean
|
2022-06-21 21:07:54 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to disallow further forwards of this message.
|
|
|
|
*
|
|
|
|
* Only for bots, works even if the target chat does not
|
|
|
|
* have content protection.
|
|
|
|
*/
|
|
|
|
forbidForwards?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer to use when sending the message.
|
|
|
|
*/
|
|
|
|
sendAs?: InputPeerLike
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-04-18 16:59:05 +03:00
|
|
|
): Promise<Message>
|
2021-05-08 17:54:18 +03:00
|
|
|
/**
|
|
|
|
* Sends a current user/bot typing event
|
|
|
|
* to a conversation partner or group.
|
|
|
|
*
|
|
|
|
* This status is set for 6 seconds, and is
|
|
|
|
* automatically cancelled if you send a
|
|
|
|
* message.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-08 17:54:18 +03:00
|
|
|
* @param chatId Chat ID
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [status='typing'] Typing status
|
2021-05-27 15:57:05 +03:00
|
|
|
* @param params
|
2021-05-08 17:54:18 +03:00
|
|
|
*/
|
|
|
|
sendTyping(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
status?: TypingStatus | tl.TypeSendMessageAction,
|
2021-05-27 15:57:05 +03:00
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* For `upload_*` and history import actions, progress of the upload
|
|
|
|
*/
|
|
|
|
progress?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For comment threads, ID of the thread (i.e. top message)
|
|
|
|
*/
|
|
|
|
threadId?: number
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-08 17:54:18 +03:00
|
|
|
): Promise<void>
|
2021-05-08 12:36:15 +03:00
|
|
|
/**
|
|
|
|
* Send or retract a vote in a poll.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-08 12:36:15 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
sendVote(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/**
|
|
|
|
* Selected options, or `null` to retract.
|
|
|
|
* You can pass indexes of the answers or the `Buffer`s
|
|
|
|
* representing them. In case of indexes, the poll will first
|
|
|
|
* be requested from the server.
|
|
|
|
*/
|
|
|
|
options: null | MaybeArray<number | Buffer>
|
|
|
|
},
|
|
|
|
): Promise<Poll>
|
2022-04-29 17:54:11 +03:00
|
|
|
/**
|
|
|
|
* Translate message text to a given language.
|
|
|
|
*
|
|
|
|
* Returns `null` if it could not translate the message.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-04-29 17:54:11 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
translateMessage(
|
|
|
|
params: InputMessageId & {
|
|
|
|
/** Target language (two-letter ISO 639-1 language code) */
|
|
|
|
toLanguage: string
|
|
|
|
},
|
|
|
|
): Promise<[string, MessageEntity[]] | null>
|
2022-04-29 17:54:11 +03:00
|
|
|
/**
|
|
|
|
* Translate text to a given language.
|
|
|
|
*
|
|
|
|
* Returns `null` if it could not translate the message.
|
|
|
|
*
|
|
|
|
* > **Note**: For now doesn't seem to work, returns null for all messages.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2022-04-29 17:54:11 +03:00
|
|
|
* @param text Text to translate
|
|
|
|
* @param toLanguage Target language (two-letter ISO 639-1 language code)
|
|
|
|
*/
|
2023-07-24 00:12:17 +03:00
|
|
|
translateText(text: string, toLanguage: string): Promise<string | null>
|
2021-05-12 22:18:08 +03:00
|
|
|
/**
|
|
|
|
* Unpin all pinned messages in a chat.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-12 22:18:08 +03:00
|
|
|
* @param chatId Chat or user ID
|
|
|
|
*/
|
2023-10-03 00:58:45 +03:00
|
|
|
unpinAllMessages(
|
|
|
|
chatId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* For forums - unpin only messages from the given topic
|
|
|
|
*/
|
|
|
|
topicId?: number
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2021-04-11 16:25:17 +03:00
|
|
|
/**
|
|
|
|
* Unpin a message in a group, supergroup, channel or PM.
|
|
|
|
*
|
|
|
|
* For supergroups/channels, you must have appropriate permissions,
|
|
|
|
* either as an admin, or as default permissions
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-11 16:25:17 +03:00
|
|
|
* @param chatId Chat ID, username, phone number, `"self"` or `"me"`
|
|
|
|
* @param messageId Message ID
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
unpinMessage(params: InputMessageId): Promise<void>
|
2021-04-24 21:11:34 +03:00
|
|
|
/**
|
|
|
|
* Create a new takeout session
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-24 21:11:34 +03:00
|
|
|
* @param params Takeout session parameters
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
initTakeoutSession(params: Omit<tl.account.RawInitTakeoutSessionRequest, '_'>): Promise<TakeoutSession>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Normalize {@link InputPrivacyRule}[] to `tl.TypeInputPrivacyRule`,
|
|
|
|
* resolving the peers if needed.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
_normalizePrivacyRules(rules: InputPrivacyRule[]): Promise<tl.TypeInputPrivacyRule[]>
|
2023-10-09 05:59:48 +03:00
|
|
|
|
|
|
|
getParseModesState(): ParseModesState
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Register a given {@link IMessageEntityParser} as a parse mode
|
|
|
|
* for messages. When this method is first called, given parse
|
|
|
|
* mode is also set as default.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param parseMode Parse mode to register
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtClientError When the parse mode with a given name is already registered.
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2021-07-09 16:39:45 +03:00
|
|
|
registerParseMode(parseMode: IMessageEntityParser): void
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Unregister a parse mode by its name.
|
|
|
|
* Will silently fail if given parse mode does not exist.
|
|
|
|
*
|
|
|
|
* Also updates the default parse mode to the next one available, if any
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param name Name of the parse mode to unregister
|
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
unregisterParseMode(name: string): void
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get a {@link IMessageEntityParser} registered under a given name (or a default one).
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param name Name of the parse mode which parser to get.
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtClientError When the provided parse mode is not registered
|
|
|
|
* @throws MtClientError When `name` is omitted and there is no default parse mode
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getParseMode(name?: string | null): IMessageEntityParser
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Set a given parse mode as a default one.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param name Name of the parse mode
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtClientError When given parse mode is not registered.
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
setDefaultParseMode(name: string): void
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Change your 2FA password
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
changeCloudPassword(params: {
|
|
|
|
/** Current password as plaintext */
|
|
|
|
currentPassword: string
|
|
|
|
/** New password as plaintext */
|
|
|
|
newPassword: string
|
|
|
|
/** Hint for the new password */
|
|
|
|
hint?: string
|
|
|
|
}): Promise<void>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Enable 2FA password on your account
|
|
|
|
*
|
|
|
|
* Note that if you pass `email`, `EmailUnconfirmedError` may be
|
|
|
|
* thrown, and you should use {@link verifyPasswordEmail},
|
|
|
|
* {@link resendPasswordEmail} or {@link cancelPasswordEmail},
|
|
|
|
* and the call this method again
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
enableCloudPassword(params: {
|
|
|
|
/** 2FA password as plaintext */
|
|
|
|
password: string
|
|
|
|
/** Hint for the new password */
|
|
|
|
hint?: string
|
|
|
|
/** Recovery email */
|
|
|
|
email?: string
|
|
|
|
}): Promise<void>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Verify an email to use as 2FA recovery method
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param code Code which was sent via email
|
|
|
|
*/
|
|
|
|
verifyPasswordEmail(code: string): Promise<void>
|
|
|
|
/**
|
|
|
|
* Resend the code to verify an email to use as 2FA recovery method.
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
resendPasswordEmail(): Promise<void>
|
|
|
|
/**
|
|
|
|
* Cancel the code that was sent to verify an email to use as 2FA recovery method
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
cancelPasswordEmail(): Promise<void>
|
|
|
|
/**
|
|
|
|
* Remove 2FA password from your account
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param password 2FA password as plaintext
|
|
|
|
*/
|
|
|
|
removeCloudPassword(password: string): Promise<void>
|
2021-05-05 23:26:28 +03:00
|
|
|
/**
|
|
|
|
* Add a sticker to a sticker set.
|
|
|
|
*
|
|
|
|
* Only for bots, and the sticker set must
|
|
|
|
* have been created by this bot.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @param setId Sticker set short name or TL object with input sticker set
|
2021-05-05 23:26:28 +03:00
|
|
|
* @param sticker Sticker to be added
|
|
|
|
* @param params
|
|
|
|
* @returns Modfiied sticker set
|
|
|
|
*/
|
|
|
|
addStickerToSet(
|
2023-10-07 00:22:08 +03:00
|
|
|
setId: InputStickerSet,
|
2021-05-05 23:26:28 +03:00
|
|
|
sticker: InputStickerSetItem,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Upload progress callback
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes uploaded
|
|
|
|
* @param total Total file size
|
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-05 23:26:28 +03:00
|
|
|
): Promise<StickerSet>
|
|
|
|
/**
|
2021-07-02 19:52:14 +03:00
|
|
|
* Create a new sticker set.
|
2021-05-05 23:26:28 +03:00
|
|
|
*
|
2021-07-02 19:52:14 +03:00
|
|
|
* This is the only sticker-related method that
|
|
|
|
* users can use (they allowed it with the "import stickers" update)
|
2021-05-05 23:26:28 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-05 23:26:28 +03:00
|
|
|
* @param params
|
|
|
|
* @returns Newly created sticker set
|
|
|
|
*/
|
|
|
|
createStickerSet(params: {
|
|
|
|
/**
|
2021-07-02 19:52:14 +03:00
|
|
|
* Owner of the sticker set (must be user).
|
|
|
|
*
|
|
|
|
* If this pack is created from a user account,
|
|
|
|
* can only be `"self"`
|
2021-05-05 23:26:28 +03:00
|
|
|
*/
|
|
|
|
owner: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Title of the sticker set (1-64 chars)
|
|
|
|
*/
|
|
|
|
title: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Short name of the sticker set.
|
|
|
|
* Can only contain English letters, digits and underscores
|
|
|
|
* (i.e. must match `/^[a-zA-Z0-9_]+$/),
|
2021-07-02 19:52:14 +03:00
|
|
|
* and (for bots) must end with `_by_<bot username>`
|
|
|
|
* (`<bot username>` is case-insensitive).
|
2021-05-05 23:26:28 +03:00
|
|
|
*/
|
|
|
|
shortName: string
|
|
|
|
|
|
|
|
/**
|
2022-08-18 19:52:24 +03:00
|
|
|
* Type of the stickers in this set.
|
|
|
|
* Defaults to `sticker`, i.e. regular stickers.
|
|
|
|
*
|
|
|
|
* Creating `emoji` stickers via API is not supported yet
|
2021-05-05 23:26:28 +03:00
|
|
|
*/
|
2023-06-05 03:30:48 +03:00
|
|
|
type?: StickerType
|
2021-05-05 23:26:28 +03:00
|
|
|
|
|
|
|
/**
|
2022-08-18 19:52:24 +03:00
|
|
|
* File source type for the stickers in this set.
|
|
|
|
* Defaults to `static`, i.e. regular WEBP stickers.
|
2021-05-05 23:26:28 +03:00
|
|
|
*/
|
2023-06-05 03:30:48 +03:00
|
|
|
sourceType?: StickerSourceType
|
2021-05-05 23:26:28 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of stickers to be immediately added into the pack.
|
|
|
|
* There must be at least one sticker in this list.
|
|
|
|
*/
|
|
|
|
stickers: InputStickerSetItem[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail for the set.
|
|
|
|
*
|
|
|
|
* The file must be either a `.png` file
|
|
|
|
* up to 128kb, having size of exactly `100x100` px,
|
|
|
|
* or a `.tgs` file up to 32kb.
|
|
|
|
*
|
|
|
|
* If not set, Telegram will use the first sticker
|
|
|
|
* in the sticker set as the thumbnail
|
|
|
|
*/
|
|
|
|
thumb?: InputFileLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload progress callback.
|
|
|
|
*
|
|
|
|
* @param idx Index of the sticker
|
|
|
|
* @param uploaded Number of bytes uploaded
|
|
|
|
* @param total Total file size
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
progressCallback?: (idx: number, uploaded: number, total: number) => void
|
2021-05-05 23:26:28 +03:00
|
|
|
}): Promise<StickerSet>
|
|
|
|
/**
|
|
|
|
* Delete a sticker from a sticker set
|
|
|
|
*
|
|
|
|
* Only for bots, and the sticker set must
|
|
|
|
* have been created by this bot.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-05 23:26:28 +03:00
|
|
|
* @param sticker
|
|
|
|
* TDLib and Bot API compatible File ID, or a
|
|
|
|
* TL object representing a sticker to be removed
|
|
|
|
* @returns Modfiied sticker set
|
|
|
|
*/
|
|
|
|
deleteStickerFromSet(
|
2023-09-24 01:32:22 +03:00
|
|
|
sticker: string | tdFileId.RawFullRemoteFileLocation | tl.TypeInputDocument,
|
2021-05-05 23:26:28 +03:00
|
|
|
): Promise<StickerSet>
|
2022-08-18 19:52:24 +03:00
|
|
|
/**
|
|
|
|
* Get custom emoji stickers by their IDs
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2022-08-18 19:52:24 +03:00
|
|
|
* @param ids IDs of the stickers (as defined in {@link MessageEntity.emojiId})
|
|
|
|
*/
|
|
|
|
getCustomEmojis(ids: tl.Long[]): Promise<Sticker[]>
|
2021-04-25 15:39:42 +03:00
|
|
|
/**
|
|
|
|
* Get a list of all installed sticker packs
|
|
|
|
*
|
|
|
|
* > **Note**: This method returns *brief* meta information about
|
|
|
|
* > the packs, that does not include the stickers themselves.
|
|
|
|
* > Use {@link StickerSet.getFull} or {@link getStickerSet}
|
|
|
|
* > to get a stickerset that will include the stickers
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-25 15:39:42 +03:00
|
|
|
*/
|
|
|
|
getInstalledStickers(): Promise<StickerSet[]>
|
|
|
|
/**
|
|
|
|
* Get a sticker pack and stickers inside of it.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @param setId Sticker pack short name, dice emoji, `"emoji"` for animated emojis or input ID
|
2021-04-25 15:39:42 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
getStickerSet(setId: InputStickerSet): Promise<StickerSet>
|
2021-05-05 23:26:28 +03:00
|
|
|
/**
|
|
|
|
* Move a sticker in a sticker set
|
|
|
|
* to another position
|
|
|
|
*
|
|
|
|
* Only for bots, and the sticker set must
|
|
|
|
* have been created by this bot.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-05 23:26:28 +03:00
|
|
|
* @param sticker
|
|
|
|
* TDLib and Bot API compatible File ID, or a
|
|
|
|
* TL object representing a sticker to be removed
|
|
|
|
* @param position New sticker position (starting from 0)
|
|
|
|
* @returns Modfiied sticker set
|
|
|
|
*/
|
|
|
|
moveStickerInSet(
|
2023-09-24 01:32:22 +03:00
|
|
|
sticker: string | tdFileId.RawFullRemoteFileLocation | tl.TypeInputDocument,
|
|
|
|
position: number,
|
2021-05-05 23:26:28 +03:00
|
|
|
): Promise<StickerSet>
|
2023-10-04 23:34:55 +03:00
|
|
|
/**
|
|
|
|
* Set group sticker set for a supergroup
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-07 00:22:08 +03:00
|
|
|
* @param setId Sticker set short name or a TL object with input sticker set
|
2023-10-04 23:34:55 +03:00
|
|
|
* @param thumb Sticker set thumbnail
|
|
|
|
* @param params
|
|
|
|
* @returns Modified sticker set
|
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
setChatStickerSet(chatId: InputPeerLike, setId: InputStickerSet): Promise<void>
|
2021-05-06 12:11:09 +03:00
|
|
|
/**
|
|
|
|
* Set sticker set thumbnail
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-06 12:11:09 +03:00
|
|
|
* @param id Sticker set short name or a TL object with input sticker set
|
|
|
|
* @param thumb Sticker set thumbnail
|
|
|
|
* @param params
|
|
|
|
* @returns Modified sticker set
|
|
|
|
*/
|
|
|
|
setStickerSetThumb(
|
2023-10-04 23:34:55 +03:00
|
|
|
id: InputStickerSet,
|
2021-05-06 12:11:09 +03:00
|
|
|
thumb: InputFileLike | tl.TypeInputDocument,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Upload progress callback
|
|
|
|
*
|
|
|
|
* @param uploaded Number of bytes uploaded
|
|
|
|
* @param total Total file size
|
|
|
|
*/
|
|
|
|
progressCallback?: (uploaded: number, total: number) => void
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-06 12:11:09 +03:00
|
|
|
): Promise<StickerSet>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Boost a given channel
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID to boost
|
|
|
|
*/
|
|
|
|
applyBoost(peerId: InputPeerLike): Promise<void>
|
|
|
|
/**
|
|
|
|
* Check if the current user can apply boost to a given channel
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID whose stories to fetch
|
|
|
|
* @returns
|
|
|
|
* - `{ can: true }` if the user can apply boost
|
|
|
|
* - `.current` - {@link Chat} that the current user is currently boosting, if any
|
|
|
|
* - `{ can: false }` if the user can't apply boost
|
|
|
|
* - `.reason == "already_boosting"` if the user is already boosting this channel
|
|
|
|
* - `.reason == "need_premium"` if the user needs Premium to boost this channel
|
2023-10-04 20:50:57 +03:00
|
|
|
* - `.reason == "timeout"` if the user has recently boosted a channel and needs to wait
|
|
|
|
* (`.until` contains the date until which the user needs to wait)
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
canApplyBoost(peerId: InputPeerLike): Promise<CanApplyBoostResult>
|
|
|
|
/**
|
|
|
|
* Check if the current user can post stories as a given peer
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID whose stories to fetch
|
|
|
|
* @returns
|
|
|
|
* - `true` if the user can post stories
|
|
|
|
* - `"need_admin"` if the user is not an admin in the chat
|
|
|
|
* - `"need_boosts"` if the channel doesn't have enough boosts
|
|
|
|
*/
|
|
|
|
canSendStory(peerId: InputPeerLike): Promise<CanSendStoryResult>
|
|
|
|
/**
|
|
|
|
* Delete a story
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns IDs of stories that were removed
|
|
|
|
*/
|
|
|
|
deleteStories(params: {
|
|
|
|
/**
|
|
|
|
* Story IDs to delete
|
|
|
|
*/
|
|
|
|
ids: MaybeArray<number>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer ID whose stories to delete
|
|
|
|
*
|
|
|
|
* @default `self`
|
|
|
|
*/
|
|
|
|
peer?: InputPeerLike
|
|
|
|
}): Promise<number[]>
|
|
|
|
/**
|
|
|
|
* Edit a sent story
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns Edited story
|
|
|
|
*/
|
|
|
|
editStory(params: {
|
|
|
|
/**
|
|
|
|
* Story ID to edit
|
|
|
|
*/
|
|
|
|
id: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer ID to whose story to edit
|
|
|
|
*
|
|
|
|
* @default `self`
|
|
|
|
*/
|
|
|
|
peer?: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Media contained in a story. Currently can only be a photo or a video.
|
|
|
|
*/
|
|
|
|
media?: InputMediaLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override caption for {@link media}
|
|
|
|
*/
|
|
|
|
caption?: string | FormattedString<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override entities for {@link media}
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interactive elements to add to the story
|
|
|
|
*/
|
|
|
|
interactiveElements?: tl.TypeMediaArea[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Privacy rules to apply to the story
|
|
|
|
*
|
|
|
|
* @default "Everyone"
|
|
|
|
*/
|
|
|
|
privacyRules?: InputPrivacyRule[]
|
|
|
|
}): Promise<Story>
|
|
|
|
|
|
|
|
_findStoryInUpdate(res: tl.TypeUpdates): Story
|
|
|
|
/**
|
|
|
|
* Get all stories (e.g. to load the top bar)
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
getAllStories(params?: {
|
|
|
|
/**
|
|
|
|
* Offset from which to fetch stories
|
|
|
|
*/
|
|
|
|
offset?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to fetch stories from "archived" (or "hidden") peers
|
|
|
|
*/
|
|
|
|
archived?: boolean
|
|
|
|
}): Promise<AllStories>
|
|
|
|
/**
|
|
|
|
* Get information about boosts in a channel
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns IDs of stories that were removed
|
|
|
|
*/
|
|
|
|
getBoostStats(peerId: InputPeerLike): Promise<BoostStats>
|
|
|
|
/**
|
|
|
|
* Get boosters of a channel
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns IDs of stories that were removed
|
|
|
|
*/
|
|
|
|
getBoosters(
|
|
|
|
peerId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Offset for pagination
|
|
|
|
*/
|
|
|
|
offset?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of boosters to fetch
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
},
|
|
|
|
): Promise<ArrayPaginated<Booster, string>>
|
|
|
|
/**
|
|
|
|
* Get stories of a given peer
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID whose stories to fetch
|
|
|
|
*/
|
|
|
|
getPeerStories(peerId: InputPeerLike): Promise<PeerStories>
|
|
|
|
/**
|
|
|
|
* Get profile stories
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
getProfileStories(
|
|
|
|
peerId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Kind of stories to fetch
|
|
|
|
* - `pinned` - stories pinned to the profile and visible to everyone
|
|
|
|
* - `archived` - "archived" stories that can later be pinned, only visible to the owner
|
|
|
|
*
|
|
|
|
* @default `pinned`
|
|
|
|
*/
|
|
|
|
kind?: 'pinned' | 'archived'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset ID for pagination
|
|
|
|
*/
|
|
|
|
offsetId?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of stories to fetch
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
},
|
|
|
|
): Promise<ArrayPaginated<Story, number>>
|
|
|
|
/**
|
2023-10-09 21:44:38 +03:00
|
|
|
* Get one or more stories by their IDs
|
2023-10-04 19:26:21 +03:00
|
|
|
*
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-04 19:26:21 +03:00
|
|
|
*
|
|
|
|
* @param peerId Peer ID whose stories to fetch
|
|
|
|
* @param storyIds Story IDs
|
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getStoriesById(peerId: InputPeerLike, storyIds: MaybeArray<number>): Promise<Story[]>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Get brief information about stories interactions.
|
|
|
|
*
|
|
|
|
* The result will be in the same order as the input IDs
|
2023-10-09 21:44:38 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
2023-10-09 21:44:38 +03:00
|
|
|
getStoriesInteractions(peerId: InputPeerLike, storyIds: MaybeArray<number>): Promise<StoryInteractions[]>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Generate a link to a story.
|
|
|
|
*
|
|
|
|
* Basically the link format is `t.me/<username>/s/<story_id>`,
|
|
|
|
* and if the user doesn't have a username, `USER_PUBLIC_MISSING` is thrown.
|
|
|
|
*
|
|
|
|
* I have no idea why is this an RPC call, but whatever
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
getStoryLink(peerId: InputPeerLike, storyId: number): Promise<string>
|
|
|
|
/**
|
|
|
|
* Get viewers list of a story
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
getStoryViewers(
|
|
|
|
peerId: InputPeerLike,
|
|
|
|
storyId: number,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Whether to only fetch viewers from contacts
|
|
|
|
*/
|
|
|
|
onlyContacts?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* How to sort the results?
|
|
|
|
* - `reaction` - by reaction (viewers who has reacted are first), then by date (newest first)
|
|
|
|
* - `date` - by date, newest first
|
|
|
|
*
|
|
|
|
* @default `reaction`
|
|
|
|
*/
|
|
|
|
sortBy?: 'reaction' | 'date'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search query
|
|
|
|
*/
|
|
|
|
query?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset ID for pagination
|
|
|
|
*/
|
|
|
|
offset?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of viewers to fetch
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
},
|
|
|
|
): Promise<StoryViewersList>
|
|
|
|
/**
|
|
|
|
* Hide own stories views (activate so called "stealth mode")
|
|
|
|
*
|
|
|
|
* Currently has a cooldown of 1 hour, and throws FLOOD_WAIT error if it is on cooldown.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
hideMyStoriesViews(params?: {
|
|
|
|
/**
|
|
|
|
* Whether to hide views from the last 5 minutes
|
|
|
|
*
|
|
|
|
* @default true
|
|
|
|
*/
|
|
|
|
past?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to hide views for the next 25 minutes
|
|
|
|
*
|
|
|
|
* @default true
|
|
|
|
*/
|
|
|
|
future?: boolean
|
|
|
|
}): Promise<StoriesStealthMode>
|
|
|
|
/**
|
|
|
|
* Increment views of one or more stories.
|
|
|
|
*
|
|
|
|
* This should be used for pinned stories, as they can't
|
|
|
|
* be marked as read when the user sees them ({@link Story#isActive} == false)
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID whose stories to mark as read
|
|
|
|
* @param ids ID(s) of the stories to increment views of (max 200)
|
|
|
|
*/
|
|
|
|
incrementStoriesViews(peerId: InputPeerLike, ids: MaybeArray<number>): Promise<boolean>
|
|
|
|
/**
|
|
|
|
* Iterate over all stories (e.g. to load the top bar)
|
|
|
|
*
|
|
|
|
* Wrapper over {@link getAllStories}
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
2023-10-09 05:59:48 +03:00
|
|
|
iterAllStories(
|
|
|
|
params?: Parameters<typeof getAllStories>[1] & {
|
|
|
|
/**
|
|
|
|
* Maximum number of stories to fetch
|
|
|
|
*
|
|
|
|
* @default Infinity
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<PeerStories>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Iterate over boosters of a channel.
|
|
|
|
*
|
|
|
|
* Wrapper over {@link getBoosters}
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns IDs of stories that were removed
|
|
|
|
*/
|
|
|
|
iterBoosters(
|
|
|
|
peerId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getBoosters>[2] & {
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Total number of boosters to fetch
|
|
|
|
*
|
|
|
|
* @default Infinity, i.e. fetch all boosters
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of boosters to fetch per request
|
|
|
|
* Usually you don't need to change this
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<Booster>
|
|
|
|
/**
|
|
|
|
* Iterate over profile stories. Wrapper over {@link getProfileStories}
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
iterProfileStories(
|
|
|
|
peerId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getProfileStories>[2] & {
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Total number of stories to fetch
|
|
|
|
*
|
|
|
|
* @default `Infinity`, i.e. fetch all stories
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of stories to fetch per request.
|
|
|
|
* Usually you shouldn't care about this.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<Story>
|
|
|
|
/**
|
|
|
|
* Iterate over viewers list of a story.
|
|
|
|
* Wrapper over {@link getStoryViewers}
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
iterStoryViewers(
|
|
|
|
peerId: InputPeerLike,
|
|
|
|
storyId: number,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getStoryViewers>[3] & {
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Total number of viewers to fetch
|
|
|
|
*
|
|
|
|
* @default Infinity, i.e. fetch all viewers
|
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of viewers to fetch per request.
|
|
|
|
* Usually you don't need to change this.
|
|
|
|
*
|
|
|
|
* @default 100
|
|
|
|
*/
|
|
|
|
chunkSize?: number
|
|
|
|
},
|
|
|
|
): AsyncIterableIterator<StoryViewer>
|
|
|
|
/**
|
|
|
|
* Mark all stories up to a given ID as read
|
|
|
|
*
|
|
|
|
* This should only be used for "active" stories ({@link Story#isActive} == false)
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @param peerId Peer ID whose stories to mark as read
|
|
|
|
* @returns IDs of the stores that were marked as read
|
|
|
|
*/
|
|
|
|
readStories(peerId: InputPeerLike, maxId: number): Promise<number[]>
|
|
|
|
/**
|
|
|
|
* Report a story (or multiple stories) to the moderation team
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
reportStory(
|
|
|
|
peerId: InputPeerLike,
|
|
|
|
storyIds: MaybeArray<number>,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Reason for reporting
|
|
|
|
*
|
|
|
|
* @default inputReportReasonSpam
|
|
|
|
*/
|
|
|
|
reason?: tl.TypeReportReason
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional comment to the report
|
|
|
|
*/
|
|
|
|
message?: string
|
|
|
|
},
|
|
|
|
): Promise<void>
|
|
|
|
/**
|
|
|
|
* Send (or remove) a reaction to a story
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
2023-10-09 05:59:48 +03:00
|
|
|
sendStoryReaction(params: {
|
|
|
|
peerId: InputPeerLike
|
|
|
|
storyId: number
|
|
|
|
reaction: InputReaction
|
|
|
|
/**
|
|
|
|
* Whether to add this reaction to recently used
|
|
|
|
*/
|
|
|
|
addToRecent?: boolean
|
|
|
|
}): Promise<void>
|
2023-10-04 19:26:21 +03:00
|
|
|
/**
|
|
|
|
* Send a story
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns Created story
|
|
|
|
*/
|
|
|
|
sendStory(params: {
|
|
|
|
/**
|
|
|
|
* Peer ID to send story as
|
|
|
|
*
|
|
|
|
* @default `self`
|
|
|
|
*/
|
|
|
|
peer?: InputPeerLike
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Media contained in a story. Currently can only be a photo or a video.
|
|
|
|
*
|
|
|
|
* You can also pass TDLib and Bot API compatible File ID,
|
|
|
|
* which will be wrapped in {@link InputMedia.auto}
|
|
|
|
*/
|
|
|
|
media: InputMediaLike | string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override caption for {@link media}
|
|
|
|
*/
|
|
|
|
caption?: string | FormattedString<string>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override entities for {@link media}
|
|
|
|
*/
|
|
|
|
entities?: tl.TypeMessageEntity[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse mode to use to parse entities before sending
|
|
|
|
* the message. Defaults to current default parse mode (if any).
|
|
|
|
*
|
|
|
|
* Passing `null` will explicitly disable formatting.
|
|
|
|
*/
|
|
|
|
parseMode?: string | null
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to automatically pin this story to the profile
|
|
|
|
*/
|
|
|
|
pinned?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to disallow sharing this story
|
|
|
|
*/
|
|
|
|
forbidForwards?: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interactive elements to add to the story
|
|
|
|
*/
|
|
|
|
interactiveElements?: tl.TypeMediaArea[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Privacy rules to apply to the story
|
|
|
|
*
|
|
|
|
* @default "Everyone"
|
|
|
|
*/
|
|
|
|
privacyRules?: InputPrivacyRule[]
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TTL period of the story, in seconds
|
|
|
|
*
|
|
|
|
* @default 86400
|
|
|
|
*/
|
|
|
|
period?: number
|
|
|
|
}): Promise<Story>
|
|
|
|
/**
|
|
|
|
* Toggle whether peer's stories are archived (hidden) or not.
|
|
|
|
*
|
|
|
|
* This **does not** archive the chat with that peer, only stories.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
*/
|
|
|
|
togglePeerStoriesArchived(peerId: InputPeerLike, archived: boolean): Promise<void>
|
|
|
|
/**
|
|
|
|
* Toggle one or more stories pinned status
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 19:26:21 +03:00
|
|
|
* @returns IDs of stories that were toggled
|
|
|
|
*/
|
|
|
|
toggleStoriesPinned(params: {
|
|
|
|
/**
|
|
|
|
* Story ID(s) to toggle
|
|
|
|
*/
|
|
|
|
ids: MaybeArray<number>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to pin or unpin the story
|
|
|
|
*/
|
|
|
|
pinned: boolean
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Peer ID whose stories to toggle
|
|
|
|
*
|
|
|
|
* @default `self`
|
|
|
|
*/
|
|
|
|
peer?: InputPeerLike
|
|
|
|
}): Promise<number[]>
|
2023-10-09 05:59:48 +03:00
|
|
|
// code in this file is very bad, thanks to Telegram's awesome updates mechanism
|
2021-11-23 00:03:59 +03:00
|
|
|
/**
|
|
|
|
* Enable RPS meter.
|
|
|
|
* Only available in NodeJS v10.7.0 and newer
|
|
|
|
*
|
|
|
|
* > **Note**: This may have negative impact on performance
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-11-23 00:03:59 +03:00
|
|
|
* @param size Sampling size
|
|
|
|
* @param time Window time
|
|
|
|
*/
|
|
|
|
enableRps(size?: number, time?: number): void
|
|
|
|
/**
|
|
|
|
* Get current average incoming RPS
|
|
|
|
*
|
|
|
|
* Incoming RPS is calculated based on
|
|
|
|
* incoming update containers. Normally,
|
|
|
|
* they should be around the same, except
|
|
|
|
* rare situations when processing rps
|
|
|
|
* may peak.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-11-23 00:03:59 +03:00
|
|
|
*/
|
|
|
|
getCurrentRpsIncoming(): number
|
|
|
|
/**
|
|
|
|
* Get current average processing RPS
|
|
|
|
*
|
|
|
|
* Processing RPS is calculated based on
|
|
|
|
* dispatched updates. Normally,
|
|
|
|
* they should be around the same, except
|
|
|
|
* rare situations when processing rps
|
|
|
|
* may peak.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-11-23 00:03:59 +03:00
|
|
|
*/
|
|
|
|
getCurrentRpsProcessing(): number
|
2022-09-12 19:50:39 +03:00
|
|
|
/**
|
2023-10-09 05:59:48 +03:00
|
|
|
* Start updates loop.
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* You must first call {@link enableUpdatesProcessing} to use this method.
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* It is recommended to use this method in callback to {@link start},
|
|
|
|
* or otherwise make sure the user is logged in.
|
2021-11-23 00:03:59 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* > **Note**: If you are using {@link UpdatesManagerParams.catchUp} option,
|
|
|
|
* > catching up will be done in background, you can't await it.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-11-23 00:03:59 +03:00
|
|
|
*/
|
2023-10-09 05:59:48 +03:00
|
|
|
startUpdatesLoop(): Promise<void>
|
2021-11-23 00:03:59 +03:00
|
|
|
/**
|
|
|
|
* **ADVANCED**
|
|
|
|
*
|
|
|
|
* Manually stop updates loop.
|
|
|
|
* Usually done automatically when stopping the client with {@link close}
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-11-23 00:03:59 +03:00
|
|
|
*/
|
|
|
|
stopUpdatesLoop(): void
|
2021-04-18 16:23:25 +03:00
|
|
|
/**
|
|
|
|
* Catch up with the server by loading missed updates.
|
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* > **Note**: In case the storage was not properly
|
|
|
|
* > closed the last time, "catching up" might
|
|
|
|
* > result in duplicate updates.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-18 16:23:25 +03:00
|
|
|
*/
|
2021-11-23 00:03:59 +03:00
|
|
|
catchUp(): void
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Block a user
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param id User ID, username or phone number
|
|
|
|
*/
|
|
|
|
blockUser(id: InputPeerLike): Promise<void>
|
|
|
|
/**
|
|
|
|
* Delete your own profile photos
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param ids ID(s) of the photos. Can be file IDs or raw TL objects
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
deleteProfilePhotos(ids: MaybeArray<string | tl.TypeInputPhoto>): Promise<void>
|
2023-10-04 20:50:57 +03:00
|
|
|
/**
|
|
|
|
* Edit "close friends" list directly using user IDs
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 20:50:57 +03:00
|
|
|
* @param ids User IDs
|
|
|
|
*/
|
|
|
|
editCloseFriendsRaw(ids: number[]): Promise<void>
|
|
|
|
/**
|
|
|
|
* Edit "close friends" list using `InputPeerLike`s
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-04 20:50:57 +03:00
|
|
|
* @param ids User IDs
|
|
|
|
*/
|
|
|
|
editCloseFriends(ids: InputPeerLike[]): Promise<void>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get a list of common chats you have with a given user
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param userId User's ID, username or phone number
|
2021-08-05 20:38:24 +03:00
|
|
|
* @throws MtInvalidPeerTypeError
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getCommonChats(userId: InputPeerLike): Promise<Chat[]>
|
2023-10-03 04:05:24 +03:00
|
|
|
/**
|
|
|
|
* Gets the current default value of the Time-To-Live setting, applied to all new chats.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 04:05:24 +03:00
|
|
|
*/
|
|
|
|
getGlobalTtl(): Promise<number>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get currently authorized user's full information
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2021-04-18 16:59:05 +03:00
|
|
|
getMe(): Promise<User>
|
2021-07-05 17:26:30 +03:00
|
|
|
/**
|
|
|
|
* Get currently authorized user's username.
|
|
|
|
*
|
|
|
|
* This method uses locally available information and
|
|
|
|
* does not call any API methods.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-07-05 17:26:30 +03:00
|
|
|
*/
|
|
|
|
getMyUsername(): string | null
|
2023-10-02 18:00:00 +03:00
|
|
|
/**
|
|
|
|
* Get a single profile picture of a user by its ID
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @param userId User ID, username, phone number, `"me"` or `"self"`
|
|
|
|
* @param photoId ID of the photo to fetch
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
getProfilePhoto(userId: InputPeerLike, photoId: tl.Long): Promise<Photo>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Get a list of profile pictures of a user
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param userId User ID, username, phone number, `"me"` or `"self"`
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
getProfilePhotos(
|
|
|
|
userId: InputPeerLike,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Offset from which to fetch.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `0`
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
offset?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maximum number of items to fetch (up to 100)
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `100`
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2023-10-02 18:00:00 +03:00
|
|
|
): Promise<ArrayPaginated<Photo, number>>
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get information about a single user.
|
|
|
|
*
|
|
|
|
* @param id User's identifier. Can be ID, username, phone number, `"me"` or `"self"` or TL object
|
|
|
|
*/
|
|
|
|
getUsers(id: InputPeerLike): Promise<User>
|
|
|
|
/**
|
|
|
|
* Get information about multiple users.
|
2021-05-12 22:07:00 +03:00
|
|
|
* You can retrieve up to 200 users at once.
|
|
|
|
*
|
|
|
|
* Note that order is not guaranteed.
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
|
|
|
* @param ids Users' identifiers. Can be ID, username, phone number, `"me"`, `"self"` or TL object
|
|
|
|
*/
|
|
|
|
getUsers(ids: InputPeerLike[]): Promise<User[]>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Iterate over profile photos
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param userId User ID, username, phone number, `"me"` or `"self"`
|
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
iterProfilePhotos(
|
|
|
|
userId: InputPeerLike,
|
2023-10-09 05:59:48 +03:00
|
|
|
params?: Parameters<typeof getProfilePhotos>[2] & {
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Maximum number of items to fetch
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default `Infinity`, i.e. all items are fetched
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
limit?: number
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of chunks which are fetched. Usually not needed.
|
|
|
|
*
|
2023-10-02 18:00:00 +03:00
|
|
|
* @default 100
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
|
|
|
chunkSize?: number
|
2023-09-24 01:32:22 +03:00
|
|
|
},
|
2021-05-09 14:35:58 +03:00
|
|
|
): AsyncIterableIterator<Photo>
|
2021-05-11 22:43:11 +03:00
|
|
|
/**
|
|
|
|
* Get multiple `InputPeer`s at once,
|
|
|
|
* while also normalizing and removing
|
|
|
|
* peers that can't be normalized to that type.
|
2023-10-05 04:38:55 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* Uses async pool internally, with a concurrent limit of 8
|
2021-05-11 22:43:11 +03:00
|
|
|
*
|
|
|
|
* @param peerIds Peer Ids
|
|
|
|
* @param normalizer Normalization function
|
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
resolvePeerMany<T extends tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel>(
|
2021-05-11 22:43:11 +03:00
|
|
|
peerIds: InputPeerLike[],
|
2023-09-24 01:32:22 +03:00
|
|
|
normalizer: (obj: tl.TypeInputPeer) => T | null,
|
2021-05-11 22:43:11 +03:00
|
|
|
): Promise<T[]>
|
|
|
|
/**
|
|
|
|
* Get multiple `InputPeer`s at once.
|
2023-10-05 04:38:55 +03:00
|
|
|
*
|
2023-10-09 05:59:48 +03:00
|
|
|
* Uses async pool internally, with a concurrent limit of 8
|
2021-05-11 22:43:11 +03:00
|
|
|
*
|
|
|
|
* @param peerIds Peer Ids
|
|
|
|
*/
|
2021-05-15 20:25:59 +03:00
|
|
|
resolvePeerMany(peerIds: InputPeerLike[]): Promise<tl.TypeInputPeer[]>
|
2023-10-05 04:00:58 +03:00
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
/**
|
|
|
|
* Get the `InputPeer` of a known peer id.
|
2023-10-07 00:22:08 +03:00
|
|
|
* Useful when an `InputPeer` is needed in Raw API.
|
2021-04-08 12:19:38 +03:00
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-04-08 12:19:38 +03:00
|
|
|
* @param peerId The peer identifier that you want to extract the `InputPeer` from.
|
2023-10-05 04:00:58 +03:00
|
|
|
* @param [force=false] Whether to force re-fetch the peer from the server
|
2021-04-08 12:19:38 +03:00
|
|
|
*/
|
2023-09-24 01:32:22 +03:00
|
|
|
resolvePeer(peerId: InputPeerLike, force?: boolean): Promise<tl.TypeInputPeer>
|
2023-10-04 21:05:07 +03:00
|
|
|
/**
|
|
|
|
* Set an emoji status for the current user
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-04 21:05:07 +03:00
|
|
|
* @param emoji Custom emoji ID or `null` to remove the emoji
|
|
|
|
*/
|
|
|
|
setEmojiStatus(
|
|
|
|
emoji: tl.Long | null,
|
|
|
|
params?: {
|
|
|
|
/**
|
|
|
|
* Date when the emoji status should expire (only if `emoji` is not `null`)
|
|
|
|
*/
|
|
|
|
until?: number | Date
|
|
|
|
},
|
|
|
|
): Promise<void>
|
2023-10-03 04:05:24 +03:00
|
|
|
/**
|
|
|
|
* Changes the current default value of the Time-To-Live setting,
|
|
|
|
* applied to all new chats.
|
|
|
|
*
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2023-10-03 04:05:24 +03:00
|
|
|
* @param period New TTL period, in seconds (or 0 to disable)
|
|
|
|
*/
|
|
|
|
setGlobalTtl(period: number): Promise<void>
|
2021-05-08 16:35:25 +03:00
|
|
|
/**
|
|
|
|
* Change user status to offline or online
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
|
|
|
* @param [offline=true] Whether the user is currently offline
|
2021-05-08 16:35:25 +03:00
|
|
|
*/
|
|
|
|
setOffline(offline?: boolean): Promise<void>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Set a new profile photo or video.
|
|
|
|
*
|
2021-07-02 16:27:08 +03:00
|
|
|
* You can also pass a file ID or an InputPhoto to re-use existing photo.
|
2023-10-05 04:00:58 +03:00
|
|
|
* **Available**: ✅ both users and bots
|
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
*/
|
2023-10-07 00:22:08 +03:00
|
|
|
setProfilePhoto(params: {
|
|
|
|
/** Media type (photo or video) */
|
|
|
|
type: 'photo' | 'video'
|
|
|
|
/** Input media file */
|
|
|
|
media: InputFileLike | tl.TypeInputPhoto
|
|
|
|
/** When `type = video`, timestamp in seconds which will be shown as a static preview. */
|
|
|
|
previewSec?: number
|
|
|
|
}): Promise<Photo>
|
2023-10-03 03:23:23 +03:00
|
|
|
/**
|
|
|
|
* Change username of the current user.
|
|
|
|
*
|
|
|
|
* Note that bots usernames must be changed through
|
|
|
|
* bot support or re-created from scratch.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2023-10-03 03:23:23 +03:00
|
|
|
* @param username New username (5-32 chars, allowed chars: `a-zA-Z0-9_`), or `null` to remove
|
|
|
|
*/
|
|
|
|
setUsername(username: string | null): Promise<User>
|
2021-05-09 14:35:58 +03:00
|
|
|
/**
|
|
|
|
* Unblock a user
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param id User ID, username or phone number
|
|
|
|
*/
|
|
|
|
unblockUser(id: InputPeerLike): Promise<void>
|
|
|
|
/**
|
|
|
|
* Update your profile details.
|
|
|
|
*
|
|
|
|
* Only pass fields that you want to change.
|
|
|
|
*
|
2023-10-05 04:38:55 +03:00
|
|
|
* **Available**: 👤 users only
|
2023-10-05 04:00:58 +03:00
|
|
|
*
|
2021-05-09 14:35:58 +03:00
|
|
|
* @param params
|
|
|
|
*/
|
|
|
|
updateProfile(params: {
|
|
|
|
/**
|
|
|
|
* New first name
|
|
|
|
*/
|
|
|
|
firstName?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New last name. Pass `''` (empty string) to remove it
|
|
|
|
*/
|
|
|
|
lastName?: string
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New bio (max 70 chars). Pass `''` (empty string) to remove it
|
|
|
|
*/
|
|
|
|
bio?: string
|
|
|
|
}): Promise<User>
|
2021-04-18 16:59:05 +03:00
|
|
|
}
|
2023-10-05 04:38:55 +03:00
|
|
|
|
2023-10-06 01:47:45 +03:00
|
|
|
export { TelegramClientOptions }
|
|
|
|
|
2021-04-18 16:59:05 +03:00
|
|
|
export class TelegramClient extends BaseTelegramClient {
|
2023-10-05 01:32:22 +03:00
|
|
|
constructor(opts: TelegramClientOptions) {
|
2021-04-18 16:59:05 +03:00
|
|
|
super(opts)
|
2023-10-09 05:59:48 +03:00
|
|
|
|
|
|
|
if (!opts.disableUpdates) {
|
|
|
|
enableUpdatesProcessing(this, {
|
|
|
|
onUpdate: makeParsedUpdateHandler({
|
|
|
|
...opts.updates,
|
|
|
|
onUpdate: (update) => {
|
|
|
|
Conversation.handleUpdate(this, update)
|
|
|
|
this.emit('update', update)
|
|
|
|
this.emit(update.name, update.data)
|
|
|
|
},
|
|
|
|
onRawUpdate: (update, peers) => {
|
|
|
|
this.emit('raw_update', update, peers)
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
|
|
|
|
this.start = async (params) => {
|
|
|
|
const user = await start(this, params)
|
|
|
|
await this.startUpdatesLoop()
|
|
|
|
|
|
|
|
return user
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.start = start.bind(null, this)
|
|
|
|
}
|
2021-04-08 12:19:38 +03:00
|
|
|
}
|
2023-10-09 05:59:48 +03:00
|
|
|
getAuthState = getAuthState.bind(null, this)
|
|
|
|
_onAuthorization = _onAuthorization.bind(null, this)
|
|
|
|
checkPassword = checkPassword.bind(null, this)
|
|
|
|
getPasswordHint = getPasswordHint.bind(null, this)
|
|
|
|
logOut = logOut.bind(null, this)
|
|
|
|
recoverPassword = recoverPassword.bind(null, this)
|
|
|
|
resendCode = resendCode.bind(null, this)
|
|
|
|
run = run.bind(null, this)
|
|
|
|
sendCode = sendCode.bind(null, this)
|
|
|
|
sendRecoveryCode = sendRecoveryCode.bind(null, this)
|
|
|
|
signInBot = signInBot.bind(null, this)
|
|
|
|
signIn = signIn.bind(null, this)
|
|
|
|
startTest = startTest.bind(null, this)
|
|
|
|
answerCallbackQuery = answerCallbackQuery.bind(null, this)
|
|
|
|
answerInlineQuery = answerInlineQuery.bind(null, this)
|
|
|
|
answerPreCheckoutQuery = answerPreCheckoutQuery.bind(null, this)
|
|
|
|
deleteMyCommands = deleteMyCommands.bind(null, this)
|
|
|
|
getBotInfo = getBotInfo.bind(null, this)
|
|
|
|
getBotMenuButton = getBotMenuButton.bind(null, this)
|
|
|
|
getCallbackAnswer = getCallbackAnswer.bind(null, this)
|
|
|
|
getGameHighScores = getGameHighScores.bind(null, this)
|
|
|
|
getInlineGameHighScores = getInlineGameHighScores.bind(null, this)
|
|
|
|
getMyCommands = getMyCommands.bind(null, this)
|
|
|
|
_normalizeCommandScope = _normalizeCommandScope.bind(null, this)
|
|
|
|
setBotInfo = setBotInfo.bind(null, this)
|
|
|
|
setBotMenuButton = setBotMenuButton.bind(null, this)
|
|
|
|
setGameScore = setGameScore.bind(null, this)
|
|
|
|
setInlineGameScore = setInlineGameScore.bind(null, this)
|
|
|
|
setMyCommands = setMyCommands.bind(null, this)
|
|
|
|
setMyDefaultRights = setMyDefaultRights.bind(null, this)
|
|
|
|
addChatMembers = addChatMembers.bind(null, this)
|
|
|
|
archiveChats = archiveChats.bind(null, this)
|
|
|
|
banChatMember = banChatMember.bind(null, this)
|
|
|
|
createChannel = createChannel.bind(null, this)
|
|
|
|
createGroup = createGroup.bind(null, this)
|
|
|
|
createSupergroup = createSupergroup.bind(null, this)
|
|
|
|
deleteChannel = deleteChannel.bind(null, this)
|
|
|
|
deleteSupergroup = deleteChannel.bind(null, this)
|
|
|
|
deleteChatPhoto = deleteChatPhoto.bind(null, this)
|
|
|
|
deleteGroup = deleteGroup.bind(null, this)
|
|
|
|
deleteHistory = deleteHistory.bind(null, this)
|
|
|
|
deleteUserHistory = deleteUserHistory.bind(null, this)
|
|
|
|
editAdminRights = editAdminRights.bind(null, this)
|
|
|
|
getChatEventLog = getChatEventLog.bind(null, this)
|
|
|
|
getChatMember = getChatMember.bind(null, this)
|
|
|
|
getChatMembers = getChatMembers.bind(null, this)
|
|
|
|
getChatPreview = getChatPreview.bind(null, this)
|
|
|
|
getChat = getChat.bind(null, this)
|
|
|
|
getFullChat = getFullChat.bind(null, this)
|
|
|
|
getNearbyChats = getNearbyChats.bind(null, this)
|
|
|
|
iterChatEventLog = iterChatEventLog.bind(null, this)
|
|
|
|
iterChatMembers = iterChatMembers.bind(null, this)
|
|
|
|
joinChat = joinChat.bind(null, this)
|
|
|
|
kickChatMember = kickChatMember.bind(null, this)
|
|
|
|
leaveChat = leaveChat.bind(null, this)
|
|
|
|
markChatUnread = markChatUnread.bind(null, this)
|
|
|
|
reorderUsernames = reorderUsernames.bind(null, this)
|
|
|
|
restrictChatMember = restrictChatMember.bind(null, this)
|
|
|
|
saveDraft = saveDraft.bind(null, this)
|
|
|
|
setChatDefaultPermissions = setChatDefaultPermissions.bind(null, this)
|
|
|
|
setChatDescription = setChatDescription.bind(null, this)
|
|
|
|
setChatPhoto = setChatPhoto.bind(null, this)
|
|
|
|
setChatTitle = setChatTitle.bind(null, this)
|
|
|
|
setChatTtl = setChatTtl.bind(null, this)
|
|
|
|
setChatUsername = setChatUsername.bind(null, this)
|
|
|
|
setSlowMode = setSlowMode.bind(null, this)
|
|
|
|
toggleContentProtection = toggleContentProtection.bind(null, this)
|
|
|
|
toggleFragmentUsername = toggleFragmentUsername.bind(null, this)
|
|
|
|
toggleJoinRequests = toggleJoinRequests.bind(null, this)
|
|
|
|
toggleJoinToSend = toggleJoinToSend.bind(null, this)
|
|
|
|
unarchiveChats = unarchiveChats.bind(null, this)
|
|
|
|
unbanChatMember = unbanChatMember.bind(null, this)
|
|
|
|
unrestrictChatMember = unbanChatMember.bind(null, this)
|
|
|
|
addContact = addContact.bind(null, this)
|
|
|
|
// @ts-expect-error .bind() kinda breaks typings for overloads
|
|
|
|
deleteContacts = deleteContacts.bind(null, this)
|
|
|
|
getContacts = getContacts.bind(null, this)
|
|
|
|
importContacts = importContacts.bind(null, this)
|
|
|
|
createFolder = createFolder.bind(null, this)
|
|
|
|
deleteFolder = deleteFolder.bind(null, this)
|
|
|
|
editFolder = editFolder.bind(null, this)
|
|
|
|
findFolder = findFolder.bind(null, this)
|
|
|
|
getFolders = getFolders.bind(null, this)
|
|
|
|
_normalizeInputFolder = _normalizeInputFolder.bind(null, this)
|
|
|
|
// @ts-expect-error .bind() kinda breaks typings for overloads
|
|
|
|
getPeerDialogs = getPeerDialogs.bind(null, this)
|
|
|
|
iterDialogs = iterDialogs.bind(null, this)
|
|
|
|
setFoldersOrder = setFoldersOrder.bind(null, this)
|
|
|
|
downloadAsBuffer = downloadAsBuffer.bind(null, this)
|
|
|
|
downloadToFile = downloadToFile.bind(null, this)
|
|
|
|
downloadAsIterable = downloadAsIterable.bind(null, this)
|
|
|
|
downloadAsStream = downloadAsStream.bind(null, this)
|
|
|
|
_normalizeFileToDocument = _normalizeFileToDocument.bind(null, this)
|
|
|
|
_normalizeInputFile = _normalizeInputFile.bind(null, this)
|
|
|
|
_normalizeInputMedia = _normalizeInputMedia.bind(null, this)
|
|
|
|
uploadFile = uploadFile.bind(null, this)
|
|
|
|
uploadMedia = uploadMedia.bind(null, this)
|
|
|
|
createForumTopic = createForumTopic.bind(null, this)
|
|
|
|
deleteForumTopicHistory = deleteForumTopicHistory.bind(null, this)
|
|
|
|
editForumTopic = editForumTopic.bind(null, this)
|
|
|
|
// @ts-expect-error .bind() kinda breaks typings for overloads
|
|
|
|
getForumTopicsById = getForumTopicsById.bind(null, this)
|
|
|
|
getForumTopics = getForumTopics.bind(null, this)
|
|
|
|
iterForumTopics = iterForumTopics.bind(null, this)
|
|
|
|
reorderPinnedForumTopics = reorderPinnedForumTopics.bind(null, this)
|
|
|
|
toggleForumTopicClosed = toggleForumTopicClosed.bind(null, this)
|
|
|
|
toggleForumTopicPinned = toggleForumTopicPinned.bind(null, this)
|
|
|
|
toggleForum = toggleForum.bind(null, this)
|
|
|
|
toggleGeneralTopicHidden = toggleGeneralTopicHidden.bind(null, this)
|
|
|
|
createInviteLink = createInviteLink.bind(null, this)
|
|
|
|
editInviteLink = editInviteLink.bind(null, this)
|
|
|
|
exportInviteLink = exportInviteLink.bind(null, this)
|
|
|
|
getInviteLinkMembers = getInviteLinkMembers.bind(null, this)
|
|
|
|
getInviteLink = getInviteLink.bind(null, this)
|
|
|
|
getInviteLinks = getInviteLinks.bind(null, this)
|
|
|
|
getPrimaryInviteLink = getPrimaryInviteLink.bind(null, this)
|
|
|
|
hideAllJoinRequests = hideAllJoinRequests.bind(null, this)
|
|
|
|
hideJoinRequest = hideJoinRequest.bind(null, this)
|
|
|
|
iterInviteLinkMembers = iterInviteLinkMembers.bind(null, this)
|
|
|
|
iterInviteLinks = iterInviteLinks.bind(null, this)
|
|
|
|
revokeInviteLink = revokeInviteLink.bind(null, this)
|
|
|
|
closePoll = closePoll.bind(null, this)
|
2023-10-09 21:44:38 +03:00
|
|
|
deleteMessagesById = deleteMessagesById.bind(null, this)
|
2023-10-09 05:59:48 +03:00
|
|
|
deleteMessages = deleteMessages.bind(null, this)
|
|
|
|
deleteScheduledMessages = deleteScheduledMessages.bind(null, this)
|
|
|
|
editInlineMessage = editInlineMessage.bind(null, this)
|
|
|
|
editMessage = editMessage.bind(null, this)
|
|
|
|
_findMessageInUpdate = _findMessageInUpdate.bind(null, this)
|
2023-10-09 21:44:38 +03:00
|
|
|
forwardMessagesById = forwardMessagesById.bind(null, this)
|
2023-10-09 05:59:48 +03:00
|
|
|
forwardMessages = forwardMessages.bind(null, this)
|
|
|
|
_getDiscussionMessage = _getDiscussionMessage.bind(null, this)
|
|
|
|
getDiscussionMessage = getDiscussionMessage.bind(null, this)
|
|
|
|
getHistory = getHistory.bind(null, this)
|
|
|
|
getMessageGroup = getMessageGroup.bind(null, this)
|
2023-10-09 21:44:38 +03:00
|
|
|
getMessageReactionsById = getMessageReactionsById.bind(null, this)
|
2023-10-09 05:59:48 +03:00
|
|
|
getMessageReactions = getMessageReactions.bind(null, this)
|
|
|
|
getMessagesUnsafe = getMessagesUnsafe.bind(null, this)
|
|
|
|
getMessages = getMessages.bind(null, this)
|
|
|
|
getReactionUsers = getReactionUsers.bind(null, this)
|
|
|
|
getScheduledMessages = getScheduledMessages.bind(null, this)
|
|
|
|
iterHistory = iterHistory.bind(null, this)
|
|
|
|
iterReactionUsers = iterReactionUsers.bind(null, this)
|
|
|
|
iterSearchGlobal = iterSearchGlobal.bind(null, this)
|
|
|
|
iterSearchMessages = iterSearchMessages.bind(null, this)
|
|
|
|
_parseEntities = _parseEntities.bind(null, this)
|
|
|
|
pinMessage = pinMessage.bind(null, this)
|
|
|
|
readHistory = readHistory.bind(null, this)
|
|
|
|
readReactions = readReactions.bind(null, this)
|
|
|
|
searchGlobal = searchGlobal.bind(null, this)
|
|
|
|
searchMessages = searchMessages.bind(null, this)
|
|
|
|
sendCopy = sendCopy.bind(null, this)
|
|
|
|
sendMediaGroup = sendMediaGroup.bind(null, this)
|
|
|
|
sendMedia = sendMedia.bind(null, this)
|
|
|
|
sendReaction = sendReaction.bind(null, this)
|
|
|
|
sendScheduled = sendScheduled.bind(null, this)
|
|
|
|
sendText = sendText.bind(null, this)
|
|
|
|
sendTyping = sendTyping.bind(null, this)
|
|
|
|
sendVote = sendVote.bind(null, this)
|
|
|
|
translateMessage = translateMessage.bind(null, this)
|
|
|
|
translateText = translateText.bind(null, this)
|
|
|
|
unpinAllMessages = unpinAllMessages.bind(null, this)
|
|
|
|
unpinMessage = unpinMessage.bind(null, this)
|
|
|
|
initTakeoutSession = initTakeoutSession.bind(null, this)
|
|
|
|
_normalizePrivacyRules = _normalizePrivacyRules.bind(null, this)
|
|
|
|
getParseModesState = getParseModesState.bind(null, this)
|
|
|
|
registerParseMode = registerParseMode.bind(null, this)
|
|
|
|
unregisterParseMode = unregisterParseMode.bind(null, this)
|
|
|
|
getParseMode = getParseMode.bind(null, this)
|
|
|
|
setDefaultParseMode = setDefaultParseMode.bind(null, this)
|
|
|
|
changeCloudPassword = changeCloudPassword.bind(null, this)
|
|
|
|
enableCloudPassword = enableCloudPassword.bind(null, this)
|
|
|
|
verifyPasswordEmail = verifyPasswordEmail.bind(null, this)
|
|
|
|
resendPasswordEmail = resendPasswordEmail.bind(null, this)
|
|
|
|
cancelPasswordEmail = cancelPasswordEmail.bind(null, this)
|
|
|
|
removeCloudPassword = removeCloudPassword.bind(null, this)
|
|
|
|
addStickerToSet = addStickerToSet.bind(null, this)
|
|
|
|
createStickerSet = createStickerSet.bind(null, this)
|
|
|
|
deleteStickerFromSet = deleteStickerFromSet.bind(null, this)
|
|
|
|
getCustomEmojis = getCustomEmojis.bind(null, this)
|
|
|
|
getInstalledStickers = getInstalledStickers.bind(null, this)
|
|
|
|
getStickerSet = getStickerSet.bind(null, this)
|
|
|
|
moveStickerInSet = moveStickerInSet.bind(null, this)
|
|
|
|
setChatStickerSet = setChatStickerSet.bind(null, this)
|
|
|
|
setStickerSetThumb = setStickerSetThumb.bind(null, this)
|
|
|
|
applyBoost = applyBoost.bind(null, this)
|
|
|
|
canApplyBoost = canApplyBoost.bind(null, this)
|
|
|
|
canSendStory = canSendStory.bind(null, this)
|
|
|
|
deleteStories = deleteStories.bind(null, this)
|
|
|
|
editStory = editStory.bind(null, this)
|
|
|
|
_findStoryInUpdate = _findStoryInUpdate.bind(null, this)
|
|
|
|
getAllStories = getAllStories.bind(null, this)
|
|
|
|
getBoostStats = getBoostStats.bind(null, this)
|
|
|
|
getBoosters = getBoosters.bind(null, this)
|
|
|
|
getPeerStories = getPeerStories.bind(null, this)
|
|
|
|
getProfileStories = getProfileStories.bind(null, this)
|
|
|
|
getStoriesById = getStoriesById.bind(null, this)
|
|
|
|
getStoriesInteractions = getStoriesInteractions.bind(null, this)
|
|
|
|
getStoryLink = getStoryLink.bind(null, this)
|
|
|
|
getStoryViewers = getStoryViewers.bind(null, this)
|
|
|
|
hideMyStoriesViews = hideMyStoriesViews.bind(null, this)
|
|
|
|
incrementStoriesViews = incrementStoriesViews.bind(null, this)
|
|
|
|
iterAllStories = iterAllStories.bind(null, this)
|
|
|
|
iterBoosters = iterBoosters.bind(null, this)
|
|
|
|
iterProfileStories = iterProfileStories.bind(null, this)
|
|
|
|
iterStoryViewers = iterStoryViewers.bind(null, this)
|
|
|
|
readStories = readStories.bind(null, this)
|
|
|
|
reportStory = reportStory.bind(null, this)
|
|
|
|
sendStoryReaction = sendStoryReaction.bind(null, this)
|
|
|
|
sendStory = sendStory.bind(null, this)
|
|
|
|
togglePeerStoriesArchived = togglePeerStoriesArchived.bind(null, this)
|
|
|
|
toggleStoriesPinned = toggleStoriesPinned.bind(null, this)
|
|
|
|
enableRps = enableRps.bind(null, this)
|
|
|
|
getCurrentRpsIncoming = getCurrentRpsIncoming.bind(null, this)
|
|
|
|
getCurrentRpsProcessing = getCurrentRpsProcessing.bind(null, this)
|
|
|
|
startUpdatesLoop = startUpdatesLoop.bind(null, this)
|
|
|
|
stopUpdatesLoop = stopUpdatesLoop.bind(null, this)
|
|
|
|
catchUp = catchUp.bind(null, this)
|
|
|
|
blockUser = blockUser.bind(null, this)
|
|
|
|
deleteProfilePhotos = deleteProfilePhotos.bind(null, this)
|
|
|
|
editCloseFriendsRaw = editCloseFriendsRaw.bind(null, this)
|
|
|
|
editCloseFriends = editCloseFriends.bind(null, this)
|
|
|
|
getCommonChats = getCommonChats.bind(null, this)
|
|
|
|
getGlobalTtl = getGlobalTtl.bind(null, this)
|
|
|
|
getMe = getMe.bind(null, this)
|
|
|
|
getMyUsername = getMyUsername.bind(null, this)
|
|
|
|
getProfilePhoto = getProfilePhoto.bind(null, this)
|
|
|
|
getProfilePhotos = getProfilePhotos.bind(null, this)
|
|
|
|
// @ts-expect-error .bind() kinda breaks typings for overloads
|
|
|
|
getUsers = getUsers.bind(null, this)
|
|
|
|
iterProfilePhotos = iterProfilePhotos.bind(null, this)
|
|
|
|
// @ts-expect-error .bind() kinda breaks typings for overloads
|
|
|
|
resolvePeerMany = resolvePeerMany.bind(null, this)
|
|
|
|
resolvePeer = resolvePeer.bind(null, this)
|
|
|
|
setEmojiStatus = setEmojiStatus.bind(null, this)
|
|
|
|
setGlobalTtl = setGlobalTtl.bind(null, this)
|
|
|
|
setOffline = setOffline.bind(null, this)
|
|
|
|
setProfilePhoto = setProfilePhoto.bind(null, this)
|
|
|
|
setUsername = setUsername.bind(null, this)
|
|
|
|
unblockUser = unblockUser.bind(null, this)
|
|
|
|
updateProfile = updateProfile.bind(null, this)
|
2021-04-08 12:19:38 +03:00
|
|
|
}
|