Skip to content

Latest commit

 

History

History
4506 lines (2733 loc) · 144 KB

documentation.md

File metadata and controls

4506 lines (2733 loc) · 144 KB

Table of Contents

TelegramBot

Extends BaseClient

A class representing a Telegram Bot client.

Parameters

  • token string The Telegram Bot API token.
  • options Object? The client options. (optional, default {})

token

The Telegram Bot API token.

Type: string

baseUrl

The base URL for the Telegram Bot API.

Type: string

login

Registers a listener for the specified event.

Parameters

  • eventName string The name of the event.
  • listener Function The listener function.

login

on(eventName, listener) { return this.on(eventName, listener); }

login

Removes the specified listener for the given event.

Parameters

  • eventName string The name of the event.
  • listener Function The listener function to remove.

login

off(eventName, listener) { return this.off(eventName, listener); }

login

Registers a one-time listener for the specified event. The listener is automatically removed after it's invoked.

Parameters

  • eventName string The name of the event.
  • listener Function The listener function.

login

once(eventName, listener) { return this.once(eventName, listener); }

login

The function that starts the whole process

TelegramApiError

Extends Error

Custom error class for errors returned by the Telegram Bot API

Parameters

  • error string The error message returned by the Telegram Bot API

EventError

Extends Error

Custom error class for errors related to event handling

Parameters

  • error string The error message

TelegramTokenError

Extends Error

Custom error class for errors related to Telegram tokens

Parameters

  • error string The error message

BitFieldError

Extends Error

Custom error class for errors related to bit fields

Parameters

  • error string The error message

IntentsError

Extends Error

Custom error class for errors related to intents

Parameters

  • error string The error message

ParameterError

Extends Error

Custom error class for errors related to function parameters

Parameters

  • error string The error message

ErrorTable

Extends Error

Custom error class for a collection of errors

Parameters

  • error string The error message

ErrorExtension

Extends Error

Custom error class for a collection of errors

Parameters

  • error string The error message

constructor

Creat method Telegram Api

Parameters

  • token string The Telegram Bot API token.
  • intents (string | array | number)? The client intents.
  • parseMode string? The parse mode for message formatting.
  • chatId (string | number)? The default chat ID for sending messages.
  • queryString string? The default query string for API requests.
  • offSetType (string | object)? The type of offset to use for updates.

getMe

Get information about the bot itself.

  • Throws TelegramApiError Throws an error if the response is empty or if there is an error returned by the Telegram API.

Returns Promise<object> Returns a Promise that resolves with an object containing information about the bot.

deleteWebhook

Delete the webhook.

Parameters

  • options object Options to configure the webhook deletion.

    • options.dropPendingUpdates boolean Pass true to drop pending updates while deleting the webhook.

Returns Promise<object> Returns the response object containing the result of the deletion request.

deleteWebhook

Delete the currently set webhook.

  • Throws TelegramApiError Throws an error if the Telegram API returns a response indicating failure.

Returns Promise<boolean> Returns a Promise that resolves with a boolean indicating whether the operation was successful.

getWebhookInfo

Get current webhook status.

Returns Promise<object> An object representing the current webhook status.

sendMessage

Send a message to a chat.

Parameters

  • options object object containing options for the message

    • options.chatId (number | string) Unique identifier for the target chat or username of the target channel (optional, default this.chatId)
    • options.text string Text of the message to be sent.
    • options.replyMarkup (object | string)? Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard, or to force a reply from the user.
    • options.allowReply boolean? Pass true if the message should be sent even if the specified replied-to message is not found
    • options.notification boolean? Sends the message silently. Users will receive a notification with no sound.
    • options.content boolean? Pass true if the message should be encrypted.
    • options.threadId number? Unique identifier for the target message thread.
    • options.replyToMessageId number? If the message is a reply, the ID of the original message.
    • options.parseMode string Send 'Markdown' or 'HTML' if you want Telegram apps to show bold, italic, fixed-width text, or inline URLs in your bot's message. (optional, default this.parseMode)
  • Throws TelegramApiError Throws an error if there is a problem with the Telegram API request.

Returns Promise<object> Returns the sent message.

sendPhoto

Sends a photo to the chat.

Parameters

  • options object The options object.

    • options.chatId number =this.chatId - The ID of the chat where the photo will be sent.
    • options.threadId number? The ID of the thread message.
    • options.photo any The photo to be sent. Can be a string URL or Buffer.
    • options.caption string The photo caption.
    • options.parseMode string? The parse mode of the caption. Can be "MarkdownV2" or "HTML".
    • options.captionEntities Array<object> The special entities of the caption.
    • options.hasSpoiler boolean? If the photo should be marked as a spoiler.
    • options.notification boolean? If notifications should be disabled for the message.
    • options.content boolean? If the message should be protected by the "new forwarded messages privacy mode".
    • options.replyToMessageId number? The ID of the message being replied to.
    • options.allowReply boolean? If the message can be sent without a reply to another message.
    • options.replyMarkup object? The reply markup object.

Returns Promise<object> The sent photo object.

sendAudio

Sends an audio message to the chat.

Parameters

  • options object The options to configure the audio message.

    • options.chatId string The chat ID of the recipient. (optional, default this.chatId)
    • options.threadId string? The message thread ID.
    • options.audio any The audio file to send.
    • options.caption string? The caption of the audio message.
    • options.parseMode string The parsing mode of the caption (optional, default this.parseMode)
    • options.captionEntities Array? The special entities in the caption.
    • options.duration number? The duration of the audio message.
    • options.performer string? The performer of the audio file.
    • options.title string? The title of the audio file.
    • options.thumbnail any? The thumbnail of the audio message.
    • options.notification boolean If true, sends the message silently. (optional, default true)
    • options.content boolean If true, protects the audio file from unauthorized access. (optional, default false)
    • options.replyToMessageId number? The ID of the message to reply to.
    • options.allowReply boolean If true, allows the message to be sent without replying to a message. (optional, default false)
    • options.replyMarkup (object | string)? The reply markup of the message.

Returns Promise<object> The sent audio message object.

sendDocument

Sends a document to the chat.

Parameters

  • options object Options for sending the document.

    • options.chatId number? Unique identifier for the target chat or username of the target channel.
    • options.threadId number? Identifier of the message thread.
    • options.document any File path or Stream for the document to send.
    • options.thumbnail any? File path or Stream for the document's thumbnail.
    • options.caption string? Caption for the document.
    • options.parseMode string? The mode for parsing entities in the document caption. One of "Markdown" or "HTML".
    • options.captionEntities Array? List of special entities to highlight in the document caption.
    • options.disableContentTypeDetection boolean? Disables automatic content type detection for uploaded files.
    • options.notification boolean? Sends the message silently if true.
    • options.content boolean? If the document should be protected by a password.
    • options.replyToMessageId number? Identifier of the message being replied to.
    • options.allowReply boolean? Pass true to enable sending the message without a reply.
    • options.replyMarkup (object | string)? InlineKeyboardMarkup or ReplyKeyboardMarkup for the sent message.

Returns Promise<object> The sent message object.

sendVideo

Sends a video message to a chat.

Parameters

  • options object Options for the video message.

    • options.chatId (string | number) Unique identifier for the target chat or username of the target channel.
    • options.video any Video to send. Can be a string path or a stream.
    • options.duration number? Duration of the video in seconds.
    • options.width number? Width of the video.
    • options.height number? Height of the video.
    • options.thumbnail string? Thumbnail of the video. Can be a string path or a stream.
    • options.caption string? Caption for the video.
    • options.parseMode string? Mode for parsing entities in the video caption.
    • options.captionEntities Array? List of special entities that appear in the video caption.
    • options.hasSpoiler boolean? Pass true, if a spoiler for the media message is needed.
    • options.supportsStreaming boolean? Pass true, if the uploaded video is suitable for streaming.
    • options.notification boolean? Sends the message silently. Users will receive a notification with no sound.
    • options.content boolean? Pass true, if the video should be encrypted.
    • options.replyToMessageId number? The ID of the message to reply to.
    • options.allowReply boolean? Pass true, if the message should be sent even if the specified replied-to message is not found.
    • options.replyMarkup (object | string)? Additional interface options for the message.
  • Throws TelegramApiError Throws an error if the API response returns an error code.

Returns Promise<object> Returns a Promise that resolves to the sent video message object on success.

sendAnimation

Sends an animation message to a specified chat or channel.

Parameters

  • options object The options for sending the animation message.

    • options.chatId string? The chat or channel id to send the animation message to.
    • options.animation string The animation to be sent.
    • options.duration number? The duration of the animation.
    • options.width number? The width of the animation.
    • options.height number? The height of the animation.
    • options.thumbnail string? The thumbnail of the animation.
    • options.caption string? The caption of the animation.
    • options.parseMode string? The parse mode of the animation.
    • options.captionEntities Array? The caption entities of the animation.
    • options.hasSpoiler boolean? Whether the animation has a spoiler.
    • options.notification boolean? Whether the notification for the message should be disabled.
    • options.content boolean? Whether the message content should be protected.
    • options.replyToMessageId number? The message id to reply to.
    • options.allowReply boolean? Whether the message can be sent without a reply.
    • options.replyMarkup (object | string)? The reply markup for the message.
    • options.threadId string? The id of the message thread to send the animation to.
  • Throws TelegramApiError If there was an error while sending the animation message.

Returns Promise<object> The response object from the Telegram API.

sendVoice

Sends a voice message to the specified chat.

Parameters

  • options object Options for sending the voice message.

    • options.voice string The voice file to send.
    • options.chatId (string | number)? The chat ID to send the voice message to. Defaults to the chat ID of the current context if not provided.
    • options.caption string? Caption for the voice message, 0-1024 characters.
    • options.parseMode string? The parse mode of the message caption. Defaults to the parse mode of the current context if not provided.
    • options.captionEntities Array? Additional entities to specify for message caption.
    • options.duration number? Duration of the voice message in seconds.
    • options.notification boolean? Sends the message silently. Users will receive a notification with no sound.
    • options.content boolean? Pass true if the uploaded voice message is a file protected with a password.
    • options.replyToMessageId number? The message ID to reply to.
    • options.allowReply boolean? Pass true if sending the message without reply is allowed.
    • options.replyMarkup (object | string)? InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply. Additional interface options for the message.
    • options.threadId string? Unique identifier for the target chat thread.

Returns Promise<object> On success, the sent Message is returned.

sendVideoNote

Sends a video note message to a chat.

Parameters

  • options object The options object.

    • options.chatId (string | number) The chat ID to send the message to.
    • options.videoNote string The video note file to send. Pass a file ID or a URL to the video note file.
    • options.duration number? Duration of the video note in seconds.
    • options.length number? File size of the video note.
    • options.thumbnail object? Optional thumbnail (image file to use as the thumbnail) for the video note.
    • options.notification boolean? Sends the message silently if true, otherwise with sound (default).
    • options.content boolean? True, if the video note should be protected by a password.
    • options.threadId number? Message thread ID.
    • options.replyToMessageId number? ID of the original message when sending a reply.
    • options.allowReply boolean? Pass true, if the message should be sent even without a reply message.
    • options.replyMarkup (object | string)? Additional interface options (JSON-serialized object).
  • Throws TelegramApiError Throws an error if the response contains an error_code property.

Returns Promise<object> Returns a Promise that resolves to the sent message object.

sendMediaGroup

Sends a media group to the specified chat.

Parameters

  • options object An object containing the options for the media group.

    • options.chatId number =this.chatId - The ID of the chat to send the media group to.
    • options.notification boolean Pass true to disable notification for the message. (optional, default false)
    • options.content boolean Pass true to protect the content of the media group from being forwarded. (optional, default false)
    • options.threadId number? Send message as a reply to a message thread.
    • options.replyToMessageId number? The ID of the message being replied to.
    • options.allowReply boolean Pass true to allow sending the media group without replying to a message. (optional, default false)
    • options.media Array<object> An array of media objects to be sent in the media group.
    • options.media string [].type - Type of the media (photo, video, etc.).
    • options.media (string | any) [].media - The media to send (as a string).
  • string string [].caption] - Caption of the media (0-1024 characters).

  • string string [].parseMode] - The parse mode of the caption (Markdown, HTML).

  • number number [].width] - The width of the media (for videos and photos).

  • number number [].height] - The height of the media (for videos and photos).

  • number number [].duration] - Duration of the video/audio (in seconds).

  • boolean boolean [].supportsStreaming] - Pass true if the uploaded video supports streaming.

  • Throws TelegramApiError Throws an error if the response contains an error code.

Returns Promise<object> Returns a Promise that resolves to the sent media group object on success.

sendLocation

Sends a location message to a chat.

Parameters

  • options object An object containing the options for sending the location message.

    • options.latitude number The latitude of the location.
    • options.longitude number The longitude of the location.
    • options.accuracy number? The horizontal accuracy of the location.
    • options.livePeriod number? The duration in seconds for which the location will be updated.
    • options.heading number? The direction in which the user is moving, in degrees. Must be between 1 and 360.
    • options.proximityRadius number? The radius of the proximity alert for the location, in meters.
    • options.notification boolean Sends the message silently. Users will receive a notification with no sound. (optional, default true)
    • options.content boolean Passes the message content through the Telegram content provider. (optional, default false)
    • options.threadId number? The ID of the message thread.
    • options.replyToMessageId number? The ID of the message to which this message is a reply.
    • options.allowReply boolean Pass true if the message should be sent even if the specified reply_to_message_id is not found. (optional, default true)
    • options.replyMarkup (object | string)? A JSON-serialized object for an inline keyboard or custom reply keyboard.

Returns Promise<object> The sent location message object.

sendVenue

Sends a venue message to the chat.

Parameters

  • options object The options to send the message.

    • options.chatId string? The chat id where to send the message.
    • options.threadId number? Unique identifier for the target chat thread.
    • options.latitude number Latitude of the venue.
    • options.longitude number Longitude of the venue.
    • options.title string Name of the venue.
    • options.address string Address of the venue.
    • options.foursquareId string? Foursquare identifier of the venue.
    • options.foursquareType string? Foursquare type of the venue, if known.
    • options.googlePlaceId string? Google Places identifier of the venue.
    • options.googlePlaceType string? Google Places type of the venue, if known.
    • options.notification boolean? Sends the message silently.
    • options.content boolean? For messages forwarded from channels, sets the channel as protected.
    • options.replyToMessageId number? Id of the message to reply to.
    • options.allowReply boolean? Pass True, if the message should be sent even if the specified replied-to message is not found.
    • options.replyMarkup (object | string)? Additional interface options. An object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.

Returns Promise<object> On success, the sent Message is returned.

forwardMessage

Forward a message to a chat.

Parameters

  • options object The options to use for forwarding the message.

    • options.chatId number =this.chatId - The chat ID of the recipient chat. Required if this.chatId is not set.
    • options.fromChatId number The chat ID of the chat where the message to forward is located.
    • options.messageId number The message ID of the message to forward.
    • options.threadId number The ID of the message thread. Optional.
    • options.notification boolean Pass true to disable notification for the message. Optional.
    • options.content boolean Pass true to protect forwarded message from being copied. Optional.

Returns Promise<object> The forwarded message object.

copyMessage

Copy a message from one chat to another.

Parameters

  • options object The options for copying the message.

    • options.fromChatId string The chat ID of the chat where the original message is located.
    • options.messageId string The message ID of the message to copy.
    • options.threadId string? The message thread ID.
    • options.chatId string The chat ID of the chat where the message will be copied to. If not provided, uses the chat ID set in the constructor. (optional, default this.chatId)
    • options.caption string? The caption of the message to be copied.
    • options.parseMode string The parsing mode of the message caption. If not provided, uses the parse mode set in the constructor. (optional, default this.parseMode)
    • options.captionEntities Array<object>? The entities in the message caption.
    • options.notification boolean? Sends the message silently. Users will receive a notification with no sound.
    • options.content boolean? Pass true to protect the content of the message from being forwarded without permission.
    • options.replyToMessageId string? The message ID being replied to.
    • options.allowSendingWithoutReply boolean? Pass true to allow sending the message without a reply.
    • options.replyMarkup (object | string)? The inline keyboard markup for the message.

Returns Promise<object> Returns the copied message object.

sendContact

Sends a contact to the chat.

Parameters

  • options object Options for sending the contact.

    • options.chatId number =this.chatId - ID of the chat where the contact should be sent.
    • options.phoneNumber string Phone number of the contact.
    • options.firstName string First name of the contact.
    • options.lastName string? Last name of the contact.
    • options.vcard string? Additional vCard data about the contact.
    • options.notification boolean Sends the message silently if true. (optional, default true)
    • options.content boolean Protects the contact's content if true. (optional, default true)
    • options.threadId number? Thread ID for the message.
    • options.replyToMessageId number? ID of the message being replied to.
    • options.allowReply boolean Allows sending the message without a reply if true. (optional, default true)
    • options.replyMarkup (object | string)? Additional options for reply markup.

Returns Promise<object> Result of the sent contact message.

sendPoll

Sends a poll to the chat with the given options.

Parameters

  • options object An object containing the poll options.

    • options.chatId number? The ID of the chat to send the poll to.
    • options.question string The question of the poll.
    • options.options Array<string> An array of strings representing the answer options for the poll.
    • options.isAnonymous boolean Whether the poll is anonymous or not.
    • options.type string The type of the poll. Can be "quiz" or "regular".
    • options.allowsMultipleAnswers boolean Whether the poll allows multiple answers or not.
    • options.correctOptionId number The correct answer option ID for the quiz type poll.
    • options.explanation string The explanation for the correct answer option in the quiz type poll.
    • options.explanationParseMode string The parse mode for the explanation message.
    • options.explanationEntities Array<object> An array of message entities in the explanation message.
    • options.openPeriod number The amount of time in seconds the poll will be open for.
    • options.closeDate number The date when the poll will be automatically closed.
    • options.isClosed boolean Whether the poll is closed or not.
    • options.notification boolean Whether to disable notifications for the message or not.
    • options.content boolean Whether to protect the poll content from being copied or not.
    • options.threadId number The message thread ID.
    • options.replyToMessageId number The ID of the message being replied to.
    • options.allowReply boolean Whether to allow sending the poll without replying to a message or not.
    • options.replyMarkup object The reply markup for the message.

Returns Promise<object> The response from the Telegram API.

sendDice

Sends a dice animation to the chat.

Parameters

  • options object The options for the dice animation.

    • options.chatId number? The ID of the chat where to send the message.
    • options.emoji string The emoji to use for the dice animation.
    • options.notification boolean Sends the message silently. Users will receive a notification with no sound. (optional, default false)
    • options.content boolean Pass True, if the message contains a game. (optional, default false)
    • options.threadId number? Unique identifier for the target chat or username of the target channel (in the format @channelusername) of the thread to send a reply to.
    • options.replyToMessageId number? The ID of the message to reply to.
    • options.allowReply boolean Pass True, if the message should be sent even if the specified replied-to message is not found. (optional, default false)
    • options.replyMarkup (object | string)? Additional interface options for sending the message.
  • Throws TelegramApiError Throws an error when there is an error in the request.

Returns Promise<object> Returns a Promise that resolves to the sent message object on success.

sendChatAction

Sends a chat action to indicate the bot is performing an action (typing, uploading a photo etc.) to the user.

Parameters

  • options object The options object for sending the chat action.

    • options.chatId string The chat ID to send the chat action to. If this.chatId is set, it will be used by default. (optional, default this.chatId)
    • options.action string The type of action to send to the user (typing, upload_photo, record_video, upload_video, record_audio, upload_audio, upload_document, find_location, record_video_note, upload_video_note).
    • options.threadId string Unique identifier for the target chat message thread.
  • Throws TelegramApiError Throws an error if the Telegram API returns an error code.

Returns Promise<object> The response object from the Telegram API containing information about the sent chat action.

getUserProfilePhotos

Returns user profile photos.

Parameters

  • options object The options object.

    • options.userId number Unique identifier of the target user.
    • options.offset number? Sequential number of the first photo to be returned. By default, all photos are returned.
    • options.limit number? Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.

Returns Promise<object> On success, an object containing the user profile photos is returned.

getFile

Get information about a file on the Telegram server

Parameters

  • fileId string ID of the file to fetch information for

Returns Promise<object> An object containing information about the file

downloadFile

Downloads a file from the Telegram servers.

Parameters

  • filePath string The path of the file to download.
  • Throws Error If the HTTP response status code is not 200.

Returns Promise<any> A Promise that resolves with the downloaded file as a Buffer, or rejects with an error.

banChatMember

Ban a chat member in the Telegram chat.

Parameters

  • options object The options for banning a chat member.

    • options.chatId string The ID of the chat where the user is to be banned. (optional, default this.chatId)
    • options.userId number The ID of the user to be banned.
    • options.untilDate number Date when the user will be unbanned, unix time.
    • options.revokeMessages boolean Pass True to delete all messages from the chat for the user that is being removed.

Returns Promise<object> On success, returns True.

unbanChatMember

Unban a previously banned chat member in a Telegram chat.

Parameters

  • options object Options for unbanning a chat member.

    • options.userId (string | number) Unique identifier of the chat member to unban.
    • options.chatId (string | number)? Unique identifier of the target chat. If not specified, defaults to the chat associated with the bot instance.
    • options.onlyIfBanned boolean If true, only unban the chat member if they are currently banned. Otherwise, unban the chat member regardless of their current ban status. (optional, default false)
  • Throws TelegramApiError If the request to the Telegram API fails or returns an error.

Returns Promise<object> Promise which resolves to the result of the Telegram API request.

restrictChatMember

Restricts a chat member's permissions.

Parameters

  • options object The options to restrict the chat member.

    • options.userId number The ID of the chat member to restrict.
    • options.permissions object The new permissions to restrict the chat member to.
    • options.useIndependentChatPermissions boolean? Pass true to use the chat member's own permissions instead of the default permissions.
    • options.untilDate number? The date when the restrictions will be lifted.
  • Throws TelegramApiError Throws an error if the API response contains an error.

Returns Promise<object> The updated ChatMember object.

promoteChatMember

Promotes a user in a chat with additional privileges.

Parameters

  • options object The options object.

    • options.userId number The ID of the user to promote.
    • options.chatId number The ID of the chat where the user will be promoted. Defaults to the chat ID set in the instance. (optional, default this.chatId)
    • options.isAnonymous boolean? Pass true to promote the user anonymously.
    • options.canManageChat boolean? Pass true to allow the user to manage the chat.
    • options.canPostMessages boolean? Pass true to allow the user to post messages in the chat.
    • options.canEditMessages boolean? Pass true to allow the user to edit messages of other users.
    • options.canDeleteMessages boolean? Pass true to allow the user to delete messages of other users.
    • options.canManageVideoChats boolean? Pass true to allow the user to manage voice chats.
    • options.canRestrictMembers boolean? Pass true to allow the user to restrict members in the chat.
    • options.canPromoteMembers boolean? Pass true to allow the user to promote other members in the chat.
    • options.canChangeInfo boolean? Pass true to allow the user to change the chat's title, photo, and other settings.
    • options.canInviteUsers boolean? Pass true to allow the user to invite new users to the chat.
    • options.canPinMessages boolean? Pass true to allow the user to pin messages in the chat.
    • options.canManageTopics boolean? Pass true to allow the user to manage chat topics.
  • Throws TelegramApiError Throws an error with the Telegram API description if the response contains an error.

Returns Promise<object> Returns a Promise that resolves to the promoted user object on success.

setChatAdministratorCustomTitle

Sets a custom title for a chat administrator.

Parameters

  • options object The options object.

    • options.userId number The user ID of the administrator.
    • options.chatId number? The ID of the chat where the administrator's custom title should be set. If not provided, uses the current chat ID from the instance.
    • options.customTitle string The custom title to set for the administrator.

Returns Promise<boolean> A promise that resolves with true if the custom title was set successfully.

banChatSenderChat

Ban a user from sending messages in a chat.

Parameters

  • options object The options to use for banning the user.

    • options.chatId string The ID of the chat where the user is banned. (optional, default this.chatId)
    • options.senderChatId number The ID of the user to be banned.

Returns Promise<object> The result of the request.

unbanChatSenderChat

Unban a previously kicked chat member from the chat and remove any previous ban on their username.

Parameters

  • options object Options for unbanning a chat member.

    • options.senderChatId number Unique identifier of the target user.
    • options.chatId number? Unique identifier of the target chat, required if chatId is not defined in class instance.

Returns Promise<object> On success, the returned object will contain the ok field set to true.

setChatPermissions

Sets chat permissions for a given chat.

Parameters

  • options object The options for setting chat permissions.

    • options.chatId string The ID of the chat to set permissions for. If not provided, defaults to the chat ID saved in the instance. (optional, default this.chatId)
    • options.permissions object The chat permissions to set. This should be an object containing key-value pairs where the keys are the names of the permissions and the values are booleans indicating whether the permission should be allowed or not.
    • options.independentPermissions boolean Whether to use independent chat permissions or not. (optional, default false)

Returns Promise<object> Returns a promise which resolves to the result of the API request.

portChatInviteLink

Exports the invite link to a chat. If chatId is not defined on the instance, it should be provided in options.

Parameters

  • chatId string Unique identifier for the target chat.
  • Throws TelegramApiError If an error occurs while exporting the chat invite link.

Returns Promise<string> The invite link for the chat.

createChatInviteLink

Creates a new chat invite link with the specified options.

Parameters

  • options object The options for the chat invite link.

    • options.chatId string? The ID of the chat where the invite link will be created. If not provided, the ID of the current chat will be used.
    • options.name string? The name of the chat that will be shown in the invite link preview. If not provided, the chat name will be used.
    • options.expireDate Date? The date and time when the invite link will expire.
    • options.memberLimit number? The maximum number of members that can join the chat using the invite link. If not provided, there will be no limit.
    • options.createsJoinRequest boolean? Determines whether the invite link creates a join request instead of adding the user directly to the chat. Defaults to false.

Returns Promise<object> The created chat invite link object.

editChatInviteLink

Edits the specified chat invite link. Returns the edited invite link as a ChatInviteLink object.

Parameters

  • options object Options for editing the chat invite link.

    • options.chatId number? Unique identifier of the target chat.
    • options.inviteLink string The invite link to edit.
    • options.name string? New name for the invite link, 1-64 characters.
    • options.expireDate number? Point in time (Unix timestamp) when the link will expire, in 30-2592000 seconds.
    • options.memberLimit number? Maximum number of chat members that can join the chat through the link.
    • options.createsJoinRequest boolean? True, if the link is a primary link for inviting users to a chat.

Returns Promise<any> The edited chat invite link as a ChatInviteLink object.

revokeChatInviteLink

Revoke a chat invite link.

Parameters

  • options object The options to use for the API call.

    • options.inviteLink string The invite link to revoke.
    • options.chatId number? The ID of the chat where the invite link was generated. If not provided, the ID of the current chat instance will be used.
  • Throws TelegramApiError If the API call fails, an error with the description of the problem.

Returns Promise<object> The API response object.

approveChatJoinRequest

Approve a join request to a chat.

Parameters

  • options object The options to approve the chat join request.

    • options.userId number The user ID for the join request.
    • options.chatId number? The chat ID for the join request. If not provided, it will use the chatId property of the bot instance.

Returns Promise<object> The result of the approveChatJoinRequest method.

declineChatJoinRequest

Declines a chat join request from a user.

Parameters

  • options object Options object.

    • options.userId number The user id of the user who sent the join request.
    • options.chatId number? The chat id where the join request was sent. Required if chatId was not specified during instance creation.
  • Throws TelegramApiError Throws an error if the Telegram API responds with an error.

Returns Promise<object> Returns a Promise that resolves to the API response on success.

setChatPhoto

Sets a new profile photo for the chat. The photo can be a local file path or a URL.

Parameters

  • options object Options for setting the chat photo.

    • options.chatId number =this.chatId - Required if this.chatId is not set. Unique identifier for the target chat.
    • options.photo string The photo to set as the chat's new profile photo.
  • Throws TelegramApiError If the request to the Telegram API fails or if the response contains an error code.

Returns Promise<object> On success, the method returns True.

deleteChatPhoto

Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.

Parameters

  • chatId number =this.chatId - Unique identifier for the target chat or username of the target channel (in the format @channelusername).
  • options string Optional parameters.
  • Throws TelegramApiError If an error is encountered while processing the request.

Returns Promise<boolean> On success, returns True.

setChatTitle

Set a new chat title for a given chat ID.

Parameters

  • options object The options to set a new chat title.

    • options.chatId string Unique identifier for the target chat or username of the target channel. (optional, default this.chatId)
    • options.title string New chat title, 1-255 characters.
  • Throws TelegramApiError If the request to set a new chat title fails, this error is thrown.

Returns Promise<object> On success, the updated chat object is returned.

setChatDescription

Sets the description of a chat.

Parameters

  • options object The options object.

    • options.chatId number =this.chatId - The chat ID to set the description for.
    • options.description string The new description for the chat.
  • Throws TelegramApiError Throws an error if the request to the Telegram API fails or if the response contains an error.

Returns Promise<object> Returns a promise that resolves to the response from the Telegram API.

pinChatMessage

Pins a message in a chat.

Parameters

  • options object The options to pin the message.

    • options.messageId number The ID of the message to pin.
    • options.chatId number? The ID of the chat where the message is located. Uses the chatId property of the instance if not provided.
    • options.notification boolean? Pass true to disable notifications for the message. Defaults to false.
  • Throws TelegramApiError If an error occurs while attempting to pin the message.

Returns Promise<object> On success, the method returns True.

unpinChatMessage

Unpins a message in a chat.

Parameters

  • options object The options for unpinning a message in a chat.

    • options.messageId number The ID of the message to unpin.
    • options.chatId number? The ID of the chat where the message to unpin is located. If not specified, the chat ID of the instance is used.

Returns Promise<object> Returns a Promise that resolves to the result of the API call.

unpinAllChatMessages

Unpins all chat messages in the specified chat.

Parameters

  • chatId number =this.chatId - Unique identifier for the target chat or username of the target channel (in the format @channelusername).

Returns Promise<object> On success, the sent Message is returned.

leaveChat

Leave a chat.

Parameters

  • chatId number =this.chatId - The chat ID of the chat to leave.

Returns Promise<object> On success, the method returns True.

getChat

Returns information about a chat.

Parameters

  • chatId string The ID of the chat to get information about.
  • Throws TelegramApiError Throws an error if the response contains an error code.

Returns Promise<object> Returns an object containing information about the chat.

getChatAdministrators

Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

Parameters

  • chatId (number | string) Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  • Throws TelegramApiError If the request to the Telegram API fails or if the API returns an error

Returns Promise<Array<any>> On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots.

getChatMemberCount

Retrieves the current number of members in a chat.

Parameters

  • chatId number =this.chatId - The identifier of the chat. If not provided, the chatId property of the TelegramBot instance will be used.

Returns Promise<number> The number of members in the chat.

getChatMember

Returns information about a member of a chat.

Parameters

  • options object An object containing chatId and userId.

    • options.chatId (number | string) Unique identifier for the target chat or username of the target channel.
    • options.userId number Unique identifier of the target user.
  • Throws TelegramApiError If the request to the Telegram API fails or if there is an error code in the response.

Returns Promise<object> On success, an object containing information about the member.

setChatStickerSet

Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.

Parameters

  • options object An object containing options to pass.

    • options.chatId number =this.chatId - Unique identifier for the target chat or username of the target channel.
    • options.stickerSetName string Name of the sticker set to be set as the group's sticker set.

Returns Promise<boolean> Returns True on success.

deleteChatStickerSet

Deletes a chat's sticker set.

Parameters

  • chatId number =this.chatId - Unique identifier for the target chat or username of the target channel.
  • Throws TelegramApiError If an error occurs while deleting the chat's sticker set.

Returns Promise<object> On success, the deleted chat's sticker set is returned.

getForumTopicIconStickers

Get a list of stickers corresponding to a forum topic icon

  • Throws TelegramApiError Throws an error if the Telegram API returns an error response

Returns Promise<Array<object>> An array of sticker objects for the corresponding forum topic icon

createForumTopic

Creates a forum topic with the specified options.

Parameters

  • options object The options to use when creating the forum topic.

    • options.chatId number? The chat ID to use for the forum topic. If not provided, this.chatId is used instead.
    • options.name string The name of the forum topic.
    • options.iconColor string The icon color of the forum topic.
    • options.iconCustomEmojiId string The ID of the custom emoji to use as the icon of the forum topic.

Returns Promise<object> The response from the Telegram API.

editForumTopic

Edits a forum topic.

Parameters

  • options object The options for editing the forum topic.

    • options.chatId number =this.chatId - The ID of the chat where the forum topic is located.
    • options.messageThreadId number The ID of the forum topic to edit.
    • options.name string The new name for the forum topic.
    • options.iconCustomEmojiId string The ID of the custom emoji to use as the new icon for the forum topic.

Returns Promise<object> The edited forum topic object.

closeForumTopic

Closes a forum topic in the specified chat.

Parameters

  • options object The options to be passed to the function.

    • options.chatId number =this.chatId - The chat ID.
    • options.messageThreadId number The ID of the message thread to close.

Returns Promise<object> Returns a Promise that resolves to the result of the API call.

reopenForumTopic

Reopens a previously closed discussion thread in a group or a channel.

Parameters

  • options object Options for reopening a discussion thread.

    • options.messageThreadId string The identifier of the thread to be reopened.
    • options.chatId string? Unique identifier of the target chat or username of the target channel.

deleteForumTopic

Delete a forum topic with the given message thread ID from the specified chat or from the default chat ID of the TelegramBot instance.

Parameters

  • options object An object containing the options for deleting a forum topic.

    • options.messageThreadId number The ID of the message thread to delete.
    • options.chatId number? The ID of the chat from which to delete the message thread. If not specified, uses the default chat ID of the TelegramBot instance.

Returns Promise<object> A Promise which resolves to an object representing the deleted forum topic.

unpinAllForumTopicMessages

Unpins all messages in a specific message thread in a Telegram chat.

Parameters

  • options object The options for unpinning messages.

    • options.chatId number =this.chatId - The ID of the chat where the messages are located.
    • options.messageThreadId number The ID of the message thread where the messages are located.

Returns Promise<object> Returns a Promise that resolves to the API response object.

editGeneralForumTopic

Edit a general forum topic.

Parameters

  • options object The options to edit the forum topic.

    • options.chatId number =this.chatId - The chat id of the forum topic.
    • options.name string The new name of the forum topic.

Returns Promise<object> Returns a Promise that resolves to the edited forum topic object on success.

closeGeneralForumTopic

Closes a general forum topic in a Telegram chat.

Parameters

  • chatId number =this.chatId - The ID of the chat where the forum topic is located.

Returns Promise<object> The result of the API call to the Telegram server.

reopenGeneralForumTopic

Reopens a general forum topic on the chat with the specified chat ID.

Parameters

  • chatId string The chat ID of the chat where the topic is located. Optional if chat ID is set in the TelegramBot constructor.
  • Throws TelegramApiError Throws an error if the response from the Telegram API contains an error code.

Returns Promise<object> Returns a Promise that resolves to the result of the Telegram API response.

hideGeneralForumTopic

Hides the general forum topic for the specified chat.

Parameters

  • chatId (string | number) The ID of the chat to hide the general forum topic for.
  • Throws TelegramApiError Throws an error if the response contains an error code.

Returns Promise<boolean> Returns true if the general forum topic was successfully hidden.

unhideGeneralForumTopic

Unhides a previously hidden general forum topic in a Telegram chat.

Parameters

  • chatId (string | number) The ID of the chat where the topic is hidden.
  • Throws TelegramApiError Throws an error if the Telegram API responds with an error.

Returns Promise<boolean> Returns true if the topic was successfully unhidden.

answerCallbackQuery

Sends an answer to a callback query sent from an inline keyboard or an inline button.

Parameters

  • options object The options object.

    • options.callbackQueryId string The unique identifier of the callback query to be answered.
    • options.text string? Text of the notification to be sent, 0-200 characters.
    • options.showAlert boolean? If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
    • options.url string? URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
    • options.cacheTime number? The maximum amount of time in seconds that the result of the callback query may be cached client-side. Defaults to 0.
  • Throws TelegramApiError Throws an error if the response contains an error_code.

Returns Promise<boolean> Returns true on success.

setMyCommands

Sets the list of commands supported by your bot.

Parameters

  • options object Options object.

    • options.commands Array<object> A list of bot commands.
    • options.scope String? A string representing the bot command scope.
    • options.languageCode String? A string representing the language code for the commands.
  • Throws TelegramApiError Throws a TelegramApiError if the API response contains an error code.

Returns Promise<object> Returns a Promise that resolves to the API response on success, or throws a TelegramApiError on failure.

deleteMyCommands

Use this method to delete the list of the bot's commands for the given scope and user language. Returns True on success.

Parameters

  • options object Optional parameters for deleting bot commands.

    • options.scope string A string, which represent the scope of users. Pass "all_private_chats" to delete commands in all private chats and groups, or "all_public_chats" to delete commands in all chats.
    • options.languageCode string A string, which represent the user language for which the commands are relevant.
  • Throws TelegramApiError If an error is encountered while deleting bot commands.

Returns Promise<boolean> On success, returns True.

getMyCommands

Get the list of commands set by the bot for its users.

Parameters

  • options object Additional options for the request.

    • options.scope string? A JSON-serialized object, describing scope of users.
    • options.languageCode string? A two-letter ISO 639-1 language code or an empty string.
  • Throws TelegramApiError Throws an error if there is a problem with the request.

Returns Promise<Array<object>> Returns an array of BotCommand on success.

setMyName

Asynchronously sets the name and language code for a Telegram bot.

Parameters

  • options object An object containing the name and language code to set.

    • options.name string The name to set for the bot.
    • options.languageCode string The language code to set for the bot.
  • Throws TelegramApiError Throws an error if there is an error in the API response.

Returns Promise<string> The result of the API request.

getMyName

Asynchronously retrieves the name of the user associated with the current API authentication token.

Parameters

  • languageCode string An optional parameter to specify the language code in which to retrieve the name.

Returns Promise<string> The name of the user associated with the current API authentication token.

setMyDescription

Set the description of the bot. This is a new field that is not yet widely available.

Parameters

  • options object An object containing the following properties:

    • options.description string The new description of the bot.
    • options.languageCode string? The IETF language tag of the user's language. If not specified, the server will use the default language code 'en'.

Returns Promise<object> Returns a Promise that resolves to the updated User object representing the bot. Throws a TelegramApiError if the bot description could not be set.

getMyDescription

Get the bot's description, as set by the user.

Parameters

  • languageCode string? IETF language tag of the user's language. Defaults to en.

Returns Promise<string> A promise that resolves to a string representing the bot's description.

setMyShortDescription

Sets the bot's short description for the profile.

Parameters

  • options object Options for setting the short description.

    • options.description string The new short description for the bot.
    • options.languageCode string The language code of the new short description.
  • Throws TelegramApiError If the request was unsuccessful, a TelegramApiError will be thrown with the description of the error.

Returns Promise<object> On success, the method returns the bot's updated profile.

getMyShortDescription

Retrieves the bot's short description in the specified language or in English if the language code is not specified.

Parameters

  • languageCode string Optional language code to get the short description in a specific language.

Returns Promise<object> object with the bot's short description.

setChatMenuButton

Sets the menu button for a specific chat.

Parameters

  • options object Options for setting the menu button.

    • options.chatId number =this.chatId - The ID of the chat where the menu button will be set. If chatId is not provided, the instance's chatId property will be used.
    • options.menuButton object The menu button object to be set. This object should conform to the Telegram Bot API's InlineKeyboardButton type.

Returns Promise<object> The result object from the Telegram API response.

getChatMenuButton

Gets the menu button of the chat with the given chat ID or the current chat ID if available.

Parameters

  • chatId (number | string)? The chat ID of the chat to get the menu button for.
  • Throws TelegramApiError Throws an error if the API response contains an error_code.

Returns Promise<object> Returns the menu button of the chat.

setMyDefaultAdministratorRights

Set default administrator rights for the bot in a chat.

Parameters

  • options object The options object.

    • options.rights object New administrator rights of the bot.
    • options.forChannels boolean Pass true if the default rights should be set for all groups and channels.
  • Throws TelegramApiError Throws an error if the response contains an error_code.

Returns Promise<object> Returns a Promise that resolves to the updated rights for the bot.

getMyDefaultAdministratorRights

Returns the default admin rights of the bot in a given channel or all channels.

Parameters

  • forChannels boolean Pass true to return the default admin rights for all channels the bot is an administrator in.
  • Throws TelegramApiError Throws an error if the response contains an error_code.

Returns Promise<object> Returns a Promise that resolves to an object with the default admin rights of the bot in the specified channel(s).

editMessageText

Edits the text of a message sent by the bot or via inline mode.

Parameters

  • options object Options for editing the message text.

    • options.chatId string? Unique identifier for the target chat or username of the target channel.
    • options.messageId number Identifier of the message to edit.
    • options.inlineMessageId string Identifier of the inline message to edit.
    • options.text string New text of the message.
    • options.parseMode string? Format of the new message text.
    • options.entities Array<object>? List of special entities that appear in message text.
    • options.disableWebPagePreview boolean? Disables link previews for links in the message.
    • options.replyMarkup (object | string)? Additional interface options for the message.

Returns Promise<object> Response object with edited message.

editMessageCaption

Edits the caption of a message.

Parameters

  • options object The options for editing the caption.

    • options.messageId number The message ID of the message to edit.
    • options.inlineMessageId string? Required if the message is an inline message. The inline message ID.
    • options.caption string? The new caption of the message.
    • options.parseMode string? The parsing mode of the new caption.
    • options.captionEntities Array? List of special entities that appear in the caption, which can be specified instead of parse_mode.
    • options.replyMarkup (object | string)? The reply markup of the message.

Returns Promise<object> The edited message object.

editMessageMedia

Edits the media of an existing message sent by the bot or via inline mode.

Parameters

  • options object The options for editing the message media.

    • options.messageId number The message ID of the message to edit.
    • options.inlineMessageId string? The inline message ID of the message to edit (if in inline mode).
    • options.media any The new media for the message.
    • options.replyMarkup any? The new reply markup for the message (if any).

Returns Promise<object> The edited message object.

editMessageLiveLocation

Edits the live location of a message sent via the bot (for inline bots) or via the bot in a chat.

Parameters

  • options object The options to edit the live location message.

    • options.chatId string? Required if inlineMessageId is not specified. Unique identifier for the target chat.
    • options.messageId number? Required if inlineMessageId is not specified. Identifier of the message to edit.
    • options.inlineMessageId string? Required if chatId and messageId are not specified. Identifier of the inline message to edit.
    • options.latitude number Latitude of new location.
    • options.longitude number Longitude of new location.
    • options.horizontalAccuracy number? The radius of uncertainty for the location, measured in meters; 0-1500.
    • options.heading number? Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
    • options.proximityAlertRadius number? Maximum distance for proximity alerts about approaching another chat member, in meters.
    • options.replyMarkup (object | string)? Additional interface options. An object of the InlineKeyboardMarkup type.

Returns Promise<object> On success, returns the edited message as a Message object.

stopMessageLiveLocation

Stop updating a live location message sent by the bot or via inline mode.

Parameters

  • options object Options for stopping live location.

    • options.chatId (string | null) Unique identifier for the target chat or username of the target channel. (optional, default this.chatId)
    • options.messageId number Identifier of the sent message.
    • options.inlineMessageId (string | null) Identifier of the inline message.
    • options.replyMarkup (object | null) A reply markup object.

Returns Promise<object> Returns a Promise that resolves to the stopped live location message object.

editMessageReplyMarkup

Edits the reply markup of a message sent by the bot or via inline mode.

Parameters

  • options object The options object.

    • options.chatId string? Required if inlineMessageId is not specified. The unique identifier of the target chat.
    • options.messageId number? Required if inlineMessageId is not specified. Identifier of the message to edit.
    • options.inlineMessageId string? Required if chatId and messageId are not specified. Identifier of the inline message.
    • options.replyMarkup object A new reply markup for the message.
  • Throws TelegramApiError If an error occurs while editing the message, an error object will be thrown.

Returns Promise<object> On success, the edited Message is returned.

stopPoll

Stops a poll in a chat.

Parameters

  • options object The options to use for stopping the poll.

    • options.messageId number Identifier of the original message with the poll.
    • options.replyMarkup (object | string)? A JSON-serialized object for a new message inline keyboard.
    • options.chatId number? Unique identifier for the target chat or username of the target channel.

Returns Promise<object> On success, the stopped poll is returned.

sendSticker

Sends a sticker message.

Parameters

  • options object The options for sending the sticker message.

    • options.chatId (string | number)? The ID of the chat where the message will be sent. Required if this.chatId is not set.
    • options.sticker string The sticker file ID or URL.
    • options.emoji string? The emoji corresponding to the sticker.
    • options.notification boolean? Sends the message silently, without a notification. False by default.
    • options.content boolean? Pass true to send the sticker as a protected content message. False by default.
    • options.replyToMessageId (string | number)? The ID of the message to reply to.
    • options.allowReply boolean? Pass true to allow sending the message without a reply message. False by default.
    • options.replyMarkup (object | string)? Additional interface options for the message.
    • options.threadId (string | number)? The ID of the thread where the message will be sent.
  • Throws TelegramApiError Throws an error if the request to the Telegram API fails.

Returns Promise<object> Returns a Promise that resolves to the sent message object on success.

getStickerSet

Get a sticker set by its name.

Parameters

  • name string Name of the sticker set.

Returns Promise<object> A Promise that returns an object representing the sticker set on success.

getCustomEmojiStickers

Returns a list of sticker sets containing custom emojis

Parameters

  • customEmojiIds Array<string> An array of custom emoji ids to get related sticker sets
  • Throws TelegramApiError Throws an error if the API response contains an error code

Returns Promise<object> Returns an object representing the list of sticker sets containing custom emojis

uploadStickerFile

Uploads a PNG image to create a new sticker file. The file must be less than 512 KB in size.

Parameters

  • options object An object containing the following parameters:

    • options.userId Number Unique identifier for the target user or bot.
    • options.sticker any The PNG image data to be uploaded.
    • options.stickerFormat String The file extension for the sticker (e.g. 'png').

Returns Promise<object> The uploaded sticker file's information.

createNewStickerSet

Creates a new sticker set with the specified options.

Parameters

  • options object The options object containing the following properties:

    • options.userId number The ID of the user who will create the sticker set.
    • options.name string The unique name of the sticker set, 1-64 characters.
    • options.title string The title of the sticker set, 1-64 characters.
    • options.stickers Array<object> An array of sticker objects containing the following properties:* {string} emoji - Emoji corresponding to the sticker.
      • {string} file - File path or URL of the sticker image.
    • options.stickerFormat string The format of the stickers. Supported formats: "png", "webp", "tgs".
    • options.stickerType string The type of the stickers. Supported types: "static" for static stickers, "animated" for animated stickers.
    • options.needsRepainting boolean Whether the sticker set needs to be repainted. Defaults to false.

Returns Promise<object> The created sticker set object.

addStickerToSet

Add a new sticker to a set created by the bot.

Parameters

  • options object The options to add a sticker to a set.

    • options.userId number The user id of the sticker set owner.

    • options.name string The name of the sticker set.

    • options.sticker object The sticker to add to the set.

      • options.sticker.fileId string The file id of the sticker.

      • options.sticker.emoji string The emoji associated with the sticker.

      • options.sticker.maskPosition object? The position where the mask should be placed on faces.

        • options.sticker.maskPosition.point string The part of the face where the mask should be placed.
        • options.sticker.maskPosition.xShift number The horizontal shift in pixels.
        • options.sticker.maskPosition.yShift number The vertical shift in pixels.
        • options.sticker.maskPosition.scale number The scale of the mask.

Returns Promise<object> On success, the added Sticker object is returned.

setStickerPositionInSet

Set the position of a sticker in its set. Returns True on success.

Parameters

  • options object Options for setting the sticker position.

    • options.sticker string File identifier of the sticker.
    • options.position number New position of the sticker in the set (zero-based).
  • Throws TelegramApiError If an error occurs while setting the sticker position.

Returns Promise<boolean> A Promise that resolves to true on success.

deleteStickerFromSet

Use this method to delete a sticker from a set created by the bot. Returns True on success.

Parameters

  • sticker string File identifier of the sticker to be deleted

Returns Promise<boolean> On success, True is returned

setStickerEmoji

Set the emoji associated with a sticker.

Parameters

  • options

Returns Promise<object> On success, the updated sticker object is returned.

setStickerKeywords

Set the keywords associated with a sticker.

Parameters

  • options object Options for setting sticker keywords.

    • options.sticker string File identifier of the sticker.
    • options.keywords Array<string> An array of strings describing the sticker.

Returns Promise<object> Result of the API call.

setStickerKeywords

Sets the keywords for a sticker.

Parameters

  • options object The options object.

    • options.sticker string The file identifier of the sticker.
    • options.keywords Array<string> New list of keywords for the sticker.
  • Throws TelegramApiError If an error occurs while setting the sticker keywords.

Returns Promise<object> On success, the updated Sticker object is returned.

setStickerMaskPosition

Sets the position of a sticker in the mask position for subsequent operation mask() calls.

Parameters

  • options object The options to set the sticker mask position.

    • options.sticker string File identifier of the sticker.

    • options.maskPosition object New mask position for the sticker.

      • options.maskPosition.point_x number The x position where the mask should be placed on the sticker.
      • options.maskPosition.point_y number The y position where the mask should be placed on the sticker.
      • options.maskPosition.scale number The scale of the mask, should be between 0 and 1.
  • Throws TelegramApiError If an error occurs while setting the sticker mask position.

Returns Promise<object> On success, the edited sticker is returned.

setStickerMaskPosition

Set the position of a sticker in a mask.

Parameters

  • options object The options for setting the sticker mask position

    • options.sticker string File identifier of the sticker

    • options.maskPosition object Position where the mask should be placed on the sticker

      • options.maskPosition.point_x number The x position where the mask should be placed on the sticker, from 0 to 100.
      • options.maskPosition.point_y number The y position where the mask should be placed on the sticker, from 0 to 100.
      • options.maskPosition.scale number The scale of the mask, from 0 to 100.
  • Throws TelegramApiError If an error occurs while setting the sticker mask position.

Returns Promise<object> On success, the returned Promise will resolve with the updated Sticker object.

setStickerSetTitle

Sets the title of a sticker set.

Parameters

  • options object Options for setting the sticker set title.

    • options.name string Name of the sticker set.
    • options.title string New title for the sticker set.

Returns Promise<object> On success, the updated sticker set is returned.

setStickerSetThumbnail

Set the thumbnail of a sticker set.

Parameters

  • options object Options object.

    • options.name string Name of the sticker set.
    • options.userId number Unique identifier of the target user.
    • options.thumbnail any New PNG image of the sticker set as a stream or a string URL-encoded file URL.
  • Throws TelegramApiError If an error occurs while executing the method, an error with a description is thrown.

Returns Promise<object> On success, the updated sticker set is returned.

setCustomEmojiStickerSetThumbnail

Set the thumbnail of a sticker set created with a custom emoji.

Parameters

  • options object The options to set the custom emoji sticker set thumbnail.

    • options.name string The name of the sticker set.
    • options.customEmojiId string The ID of the custom emoji.

Returns Promise<object> The response from the Telegram API containing the result.

deleteStickerSet

Use this method to delete a sticker set. Use the bot's username and the name of the sticker set.

Parameters

  • name string object containing the following required parameters
  • Throws TelegramApiError When the request to the Telegram API fails or when the response contains an error.

Returns Promise<object> On success, returns True.

answerInlineQuery

Answer an inline query.

Parameters

  • options object The options for answering the inline query.

    • options.inlineQueryId string Identifier of the inline query.
    • options.results Array<object> An array of results for the inline query.
    • options.cacheTime number The maximum amount of time in seconds that the result of the inline query may be cached. (optional, default 300)
    • options.isPersonal boolean Pass true, if the results of the inline query should be kept on the server side. (optional, default false)
    • options.nextOffset string The offset that a client should send in the next query with the same text to receive more results. (optional, default '')
    • options.switchPmText string? If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter.
    • options.switchPmParameter string? The parameter for the start message sent to the bot when user presses the switch button.

Returns Promise<object> A Promise that resolves to the result of the request.

answerWebAppQuery

Use this method to answer a callback query sent from a web app.

Parameters

  • options object An object containing the parameters for the method.

    • options.queryId string Unique identifier for the query to be answered.
    • options.inlineQueryResult any An array of results for the inline query.
  • Throws TelegramApiError On error, an error object with an error code and description.

Returns Promise<object> On success, the method returns the updated message object.

sendInvoice

Sends an invoice to the specified chat.

Parameters

  • options object Options for sending the invoice.

    • options.chatId number =this.chatId - Unique identifier for the target chat.
    • options.messageThreadId number Identifier of the message thread.
    • options.title string Product name for the invoice.
    • options.description string Product description for the invoice.
    • options.payload string Bot-defined invoice payload, 1-128 bytes.
    • options.providerToken string Payments provider token.
    • options.currency string Three-letter ISO 4217 currency code.
    • options.prices Array Array of price portions.
    • options.maxTipAmount number Maximum accepted amount for tips.
    • options.suggestedTipAmounts Array Suggested tip amounts.
    • options.startParameter string Bot-defined identifier for the invoice.
    • options.providerData string JSON-encoded data about the invoice, which will be shared with the payment provider.
    • options.photoUrl string URL of the product photo for the invoice.
    • options.photoSize number Size of the product photo for the invoice.
    • options.photoWidth number Width of the product photo for the invoice.
    • options.photoHeight number Height of the product photo for the invoice.
    • options.needName boolean Pass true if the customer's full name should be collected.
    • options.needPhoneNumber boolean Pass true if the customer's phone number should be collected.
    • options.needEmail boolean Pass true if the customer's email address should be collected.
    • options.needShippingAddress boolean Pass true if the customer's shipping address should be collected.
    • options.sendPhoneNumberToProvider boolean Pass true if the customer's phone number should be sent to the payment provider.
    • options.sendEmailToProvider boolean Pass true if the customer's email address should be sent to the payment provider.
    • options.isFlexible boolean Pass true if the final price depends on the shipping method.
    • options.disableNotification boolean Pass true if a notification for the invoice message should not be sent.
    • options.protectContent boolean Pass true if the invoice message content should be encrypted.
    • options.replyToMessageId number Identifier of the message to reply to.
    • options.allowSendingWithoutReply boolean Pass true if the message can be sent without a reply.
    • options.replyMarkup object Inline keyboard markup object.

Returns Promise<object> Result object containing information about the sent invoice.

createInvoiceLink

Creates a payment invoice link for a Telegram bot user.

Parameters

  • options object The options for creating the payment link.

    • options.title string The title of the product or service being purchased.
    • options.description string The description of the product or service being purchased.
    • options.payload string A developer-defined payload, which will be included in the payment notification.
    • options.providerToken string The authentication token provided by the payment provider.
    • options.currency string The currency of the payment, in ISO 4217 format.
    • options.prices Array<object> An array of price components for the product or service being purchased.
    • options.maxTipAmount number The maximum tip amount allowed for the payment.
    • options.suggestedTipAmounts Array<number> An array of suggested tip amounts for the payment.
    • options.providerData string Additional data to pass to the payment provider, in JSON format.
    • options.photoUrl string The URL of a photo for the product or service being purchased.
    • options.photoSize number The size of the photo in bytes.
    • options.photoWidth number The width of the photo in pixels.
    • options.photoHeight number The height of the photo in pixels.
    • options.needName boolean Whether the user's name is needed for the payment.
    • options.needPhoneNumber boolean Whether the user's phone number is needed for the payment.
    • options.needEmail boolean Whether the user's email address is needed for the payment.
    • options.needShippingAddress boolean Whether the user's shipping address is needed for the payment.
    • options.sendPhoneNumberToProvider boolean Whether to send the user's phone number to the payment provider.
    • options.sendEmailToProvider boolean Whether to send the user's email address to the payment provider.
    • options.isFlexible boolean Whether the final payment amount can be changed by the user.

Returns Promise<object> The response object, which contains the URL of the payment invoice link.

answerShippingQuery

Sends a shipping query answer to the user.

Parameters

  • options object The options object.

    • options.queryId string The ID of the shipping query.
    • options.isDeliveryPossible boolean Specify true if delivery to the specified address is possible.
    • options.shippingOptions Array? List of available shipping options.
    • options.errorMessage string? Error message to display to the user if delivery to the specified address is not possible.
  • Throws TelegramApiError Throws an error if the response contains an error code.

Returns Promise<object> Returns a Promise that resolves to the result object upon successful execution of the method.

answerPreCheckoutQuery

Use this method to respond to such pre-checkout queries. On success, True is returned.

Parameters

  • options object An object containing the response parameters.

    • options.preCheckoutQueryId string Unique identifier for the query to be answered.
    • options.ok boolean Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Specify False if there are any problems.
    • options.errorMessage string? Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout.

Returns Promise<boolean> On success, True is returned.

setPassportDataErrors

Set errors in user Passport and revoke the verification of the data.

Parameters

  • options object The options to pass.

    • options.userId number Required. Unique identifier of the target user.

    • options.errors Array<object> Required. An array describing the errors.

      • options.errors.source string Required. The section of the user's Telegram Passport which has the error, one of "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration".
      • options.errors.type string Required. Type of element of the Telegram Passport which has the error, one of "personal_details", "passport", "driver_license", "identity_card", "internal_passport", "address", "utility_bill", "bank_statement", "rental_agreement", "passport_registration", "temporary_registration".
      • options.errors.message string Required. Error message.

Returns Promise<object> On success, returns an object with the success status.

sendGame

Sends a game to the chat.

Parameters

  • options object Options for sending the game.

    • options.chatId number =this.chatId - ID of the chat where the game should be sent.
    • options.gameShortName string Short name of the game to be sent.
    • options.disableNotification boolean Pass true to disable notification for the message. (optional, default false)
    • options.protectContent boolean Pass true to protect the content of the message from screenshots. (optional, default false)
    • options.messageThreadId number? Identifier of the message thread.
    • options.replyToMessageId number? Identifier of the message to reply to.
    • options.allowSendingWithoutReply boolean Pass true to allow sending the message without a reply. (optional, default false)
    • options.replyMarkup (object | string)? Additional interface options for the message.

Returns Promise<object> A Promise that resolves to the sent game object on success.

deleteMessage

Delete a message on Telegram.

Parameters

  • options object Options object.

    • options.chatId number =this.chatId - Chat ID where the message to be deleted is located.
    • options.messageId number Message ID to be deleted.
    • options.revoke boolean Pass true to delete the message for all chat members. Only used for channels.
  • Throws TelegramApiError Throws an error if the API response contains an error_code.

Returns object Returns a Promise which will resolve to a message object if the message was deleted successfully.

createChat

Creates a new chat with the specified options.

Parameters

  • options object The options for creating the chat.

    • options.type string The type of the chat to create ('private', 'group', or 'supergroup').
    • options.title string The title of the chat.

Returns Promise<object> Returns a Promise that resolves to an object representing the created chat.

get

Retrieves the database object from the specified directory, table, and extension.

Parameters

  • dir string The directory where the storage is located.
  • table string The name of the table.
  • extname string The extension of the storage file.

Returns any The retrieved database object.

set

Sets the database object in the specified directory, table, and extension.

Parameters

  • dir string The directory where the storage is located.
  • table string The name of the table.
  • db any The database object to set.
  • extname string The extension of the storage file.

SimpleStorage

Class representing a simple storage.

Parameters

  • options Object The options for configuring the simple storage. (optional, default {})

get

Retrieves the value associated with the given key from the specified table.

Parameters

  • table string The name of the table.
  • key any The key to retrieve the value for.
  • Throws ErrorTable Throws an error if the table name is invalid.

Returns any The value associated with the key.

set

Sets the value for the given key in the specified table.

Parameters

  • table string The name of the table.
  • key any The key to set the value for.
  • value any The value to set.
  • Throws ErrorTable Throws an error if the table name is invalid.

delete

Deletes the value associated with the given key from the specified table.

Parameters

  • table string The name of the table.
  • key any The key to delete.
  • Throws ErrorTable Throws an error if the table name is invalid.

has

Checks if the specified table has a value associated with the given key.

Parameters

  • table string The name of the table.
  • key any The key to check.
  • Throws ErrorTable Throws an error if the table name is invalid.

Returns boolean true if the table has the key, false otherwise.

filter

Filters the values in the specified table based on the provided callback function.

Parameters

  • table string The name of the table.
  • callback function The filter function.
  • Throws ErrorTable Throws an error if the table name is invalid.

Returns object An object containing the filtered key-value pairs.

all

Retrieves all the key-value pairs from the specified table.

Parameters

  • table string The name of the table.
  • Throws ErrorTable Throws an error if the table name is invalid.

Returns object An object containing all the key-value pairs.

SessionTypes

Types of sessions.

Type: string

SimpleSession

Simple session type.

AutoSession

Auto session type.

TimeSession

Time session type.

Request

Extends EventEmitter

Represents a request object for making requests to the Telegram Bot API.

Parameters

  • token string? The API token for the bot.
  • intents (string | array | number)? The types of updates the bot is interested in.
  • queryString string? The type of query string to use for requests.
  • offSetType (string | boolean | object)? The type of offset to use for updates.
  • parseMode

getUpdates

Gets the updates from the Telegram Bot API.

Returns Promise<Array<object>> An array of updates.

request

Makes a request to the Telegram Bot API.

Parameters

  • method string The API method to call.
  • params Object The parameters to include in the API call.

Returns Promise<object> The response from the API call.

uptime

Gets the uptime of the bot.

Returns number The uptime in milliseconds.

ping

Gets the ping latency of the bot.

Returns Promise<number> The ping latency in milliseconds.

updateId

Gets the last update ID received.

Returns (number | null) The last update ID, or null if not available.

lastObject

Gets the last object received.

Returns object The last received object.

setToken

Set the token for the bot.

Parameters

  • token string The token to set.

Returns boolean Returns true if the token was set successfully.

setIntents

Set the intents for the bot.

Parameters

Returns boolean Returns true if the intents were set successfully.

setParseMode

Set the parse mode for the bot.

Parameters

  • parseMode string The parse mode to set.

Returns boolean Returns true if the parse mode was set successfully.

setChatId

Set the chat ID for the bot.

Parameters

Returns (string | number) Returns the chat ID that was set.

setQueryString

Set the query string for the bot.

Parameters

  • queryString string The query string to set.

Returns boolean Returns true if the query string was set successfully.

setOffSetType

Set the offset type for the bot.

Parameters

  • offSetType string The offset type to set.

Returns string Returns the offset type that was set.

Markup

Class representing a markup in the Telegram Bot API.

Parameters

  • options Object Button settings. (optional, default {})

setType

Sets the markup action type.

Parameters

  • type string Button action type.

Returns Markup Returns an instance of the Markup object for method chaining.

setAction

Sets the markup action.

Parameters

  • action string Button action to be passed to the event handler.

Returns Markup Returns an instance of the Markup object for method chaining.

setText

Sets the text on the markup.

Parameters

  • text string Text on the markup.

Returns Markup Returns an instance of the Markup object for method chaining.

setWebApp

Sets the URL for the web app.

Parameters

Returns Markup Returns the current object instance for chaining.

setForceReply

Sets the force_reply option for the reply keyboard.

Parameters

  • forceReply boolean Indicates whether to enable the force reply feature.

Returns Markup Returns the modified instance of the object.

toJSON

Returns the markup object in the format expected by Telegram Bot API.

Returns object Returns the markup object in the format expected by Telegram Bot API.

toString

Returns the text representation of the markup object in the format expected by Telegram Bot API.

Returns string Returns the text representation of the markup object in the format expected by Telegram Bot API.

setRemove

Set the remove_keyboard option to remove the keyboard after the user presses a markup.

Parameters

  • remove boolean Whether the keyboard should be removed after the user presses a markup. (optional, default false)

Returns string Returns a JSON string with the remove_keyboard option set to true.

fromJSON

Creates a new Button object from a markup object in the format expected by Telegram Bot API.

Parameters

  • markupObj object Button object in the format expected by Telegram Bot API.

Returns Markup Returns an instance of the Markup object.

inlineKeyboard

Returns the inline keyboard object in the format expected by Telegram Bot API.

Parameters

  • markups Array A 2-dimensional array of Markup objects representing the markups on the keyboard.

Returns object Returns the inline keyboard object in the format expected by Telegram Bot API.

addMarkupArray

Generates a JSON string representing a reply markup object with an inline keyboard.

Parameters

  • arrayMarkup Array An array containing elements of the markup.
  • arrayLength number The desired length of the markup array. Defaults to 10. (optional, default 10)

Returns string Returns a JSON string representing the reply markup object.

constructor

Creates a new Keyboard object.

Parameters

  • markups Array A 2-dimensional array of Button objects representing the markups on the keyboard.

  • options Object Additional options for the keyboard. (optional, default {})

    • options.inline boolean Whether the keyboard is an inline keyboard. (optional, default false)
    • options.resize boolean Whether the keyboard should be resized to fit the user's screen. (optional, default false)
    • options.oneTime boolean Whether the keyboard should disappear after the user presses a markup. (optional, default false)
    • options.selective boolean Whether the keyboard should be shown only to specific users. (optional, default false)

toJSON

Returns the keyboard object in the format expected by Telegram Bot API.

Returns object Returns the keyboard object in the format expected by Telegram Bot API.

setInline

Sets the inline option of the keyboard.

Parameters

  • inline boolean Whether the keyboard should be displayed inline with the message.

Returns Keyboard Returns the updated Keyboard object.

setResize

Sets the resize option for the keyboard.

Parameters

  • resize boolean Whether the keyboard should be resized to fit the user's screen.

Returns Keyboard Returns the current Keyboard object for chaining.

setOneTime

Sets whether the keyboard should disappear after the user presses a markup.

Parameters

  • oneTime boolean Whether the keyboard should disappear after the user presses a markup.

Returns Keyboard Returns the Keyboard object.

setSelective

Set the selective option for the keyboard.

Parameters

  • selective boolean Whether the keyboard should be shown only to specific users.

Returns Keyboard Returns the Keyboard object with the selective option set.

addKeyboard

Adds markups to the keyboard markups array.

Parameters

  • markupRows ...any One or more markup rows to add to the keyboard.
  • defaults boolean Specifies whether to use default values for the markups. (optional, default false)

Returns Keyboard Returns the updated Keyboard object.

MessageCollector

Extends EventEmitter

Represents a message collector.

Parameters

  • options Object The options for the collector.

handleMessage

Handles a new message received by the collector.

Parameters

  • message Object The message object.

collected

Returns the collected messages.

Returns Array The collected messages.

count

Returns the count of collected messages.

Returns number The count of collected messages.

clear

Clears the collected messages.

Returns boolean true if the collected messages are cleared successfully, false otherwise.

setFilter

Sets a new filter function for the collector.

Parameters

  • filter Function The new filter function.

Returns boolean true if the filter function is set successfully, false otherwise.

setTime

Sets a new duration for the collector to run.

Parameters

  • time number The new duration in milliseconds.

Returns boolean true if the duration is set successfully, false otherwise.

setMax

Sets a new maximum number of messages to collect.

Parameters

  • max number The new maximum number of messages.

Returns boolean true if the maximum number is set successfully, false otherwise.

isRunning

Returns whether the collector is currently running.

Returns boolean true if the collector is running, false otherwise.

stop

Stops the message collector.

Events

Events object with predefined event types.

Type: Object

Properties

  • Message string Represents the 'message' event.
  • EditedMessage string Represents the 'edited_message' event.
  • ChannelPost string Represents the 'channel_post' event.
  • EditedChannelPost string Represents the 'edited_channel_post' event.
  • InlineQuery string Represents the 'inline_query' event.
  • ChosenInlineResult string Represents the 'chosen_inline_result' event.
  • CallbackQuery string Represents the 'callback_query' event.
  • ShippingQuery string Represents the 'shipping_query' event.
  • PreCheckoutQuery string Represents the 'pre_checkout_query' event.
  • Poll string Represents the 'poll' event.
  • PollAnswer string Represents the 'poll_answer' event.
  • ChatMember string Represents the 'chat_member' event.
  • MyChatMember string Represents the 'my_chat_member' event.
  • ChatJoinRequest string Represents the 'chat_join_request' event.
  • ReplyMessage string Represents the 'reply_message' event.

ChatActionType

An object representing the available chat action types.

Type: object

Properties

  • Typing string Represents a typing action.
  • UploadPhoto string Represents an action for uploading a photo.
  • RecordVideo string Represents an action for recording a video.
  • UploadVideo string Represents an action for uploading a video.
  • RecordVoice string Represents an action for recording a voice message.
  • UploadVoice string Represents an action for uploading a voice message.
  • UploadDocument string Represents an action for uploading a document.
  • ChooseSticker string Represents an action for choosing a sticker.
  • FindLocation string Represents an action for finding a location.
  • RecordVideoNote string Represents an action for recording a video note.
  • UploadVideoNote string Represents an action for uploading a video note.

EntityType

Object representing types of Telegram message entities.

Type: string

Properties

  • Mention string A @username mention.
  • Hashtag string A #hashtag mention.
  • Cashtag string A $cashtag mention.
  • BotCommand string A bot command mention.
  • URL string A URL link.
  • Email string An email link.
  • PhoneNumber string A phone number link.
  • Bold string Bold text.
  • Italic string Italic text.
  • Underline string Underlined text.
  • Strikethrough string Strikethrough text.
  • Spoiler string Spoiler text.
  • Code string Monospace code text.
  • Pre string Preformatted code block.
  • TextLink string A clickable text URL link.
  • TextMention string A mention of a user by their username.
  • CustomEmoji string A custom emoji.

ChatPermission

An object containing chat permissions.

Type: Object

Properties

  • CanSendOtherMessages string Specifies if users can send other kinds of messages.
  • CanAddWebPagePreviews string Specifies if users can add web page previews to their messages.
  • CanSendMessages string Specifies if users can send text messages.
  • CanSendAudios string Specifies if users can send audio messages.
  • CanSendDocuments string Specifies if users can send document messages.
  • CanSendPhotos string Specifies if users can send photo messages.
  • CanSendVideos string Specifies if users can send video messages.
  • CanSendVideoNotes string Specifies if users can send video note messages.
  • CanSendVoiceNotes string Specifies if users can send voice note messages.
  • CanSendPolls string Specifies if users can send polls.

GroupPermission

An object containing group permissions.

Type: Object

Properties

  • CanManageChat string Specifies if users can manage the group.
  • CanChangeInfo string Specifies if users can change group information.
  • CanDeleteMessages string Specifies if users can delete messages.
  • CanInviteUsers string Specifies if users can invite other users to the group.
  • CanRestrictMembers string Specifies if users can restrict group members.
  • CanPinMessages string Specifies if users can pin messages.
  • CanManageTopics string Specifies if users can manage group topics.
  • CanPromoteMembers string Specifies if users can promote members.
  • CanManageVideoChats string Specifies if users can manage video groups.
  • CanManageVoiceChats string Specifies if users can manage voice groups.

GroupStatus

Enum representing the status of a group member.

Type: string

Administrator

The user is an administrator of the group.

Left

The user has left the group.

Member

The user is a regular member of the group.

Creator

The user is the creator of the group.

DocumentTypes

Constants for document types.

Type: string

Properties

  • PersonalDetails string Personal details.
  • Passport string Passport.
  • DriverLicense string Driver's license.
  • IdentityCard string Identity card.
  • InternalPassport string Internal passport.
  • Address string Address.
  • UtilityBill string Utility bill.
  • BankStatement string Bank statement.
  • RentalAgreement string Rental agreement.
  • PassportRegistration string Passport registration.
  • TemporaryRegistration string Temporary registration.
  • PhoneNumber string Phone number.
  • Email string Email.

IntentsBitField

add

Adds one or more bits to the bit field.

Parameters

  • ints ...number The bits to add to the bit field.

Returns IntentsBitField The updated IntentsBitField instance.

remove

Removes one or more Telegram intents from the bitfield.

Parameters

  • ints ...number The bits that represent the Telegram intents to be removed.

Returns IntentsBitField The IntentsBitField instance.

serialize

Returns the bitfield as a number.

Returns number The bitfield.

toArray

Returns an array of intent strings based on the current bit value

Returns Array<string> Array of intent strings

has

Checks if the bit field has a specific bit set

Parameters

Returns boolean True if the bit is set, false otherwise

decodeIntents

Decodes a bit field instance and returns an array of intent strings

Parameters

Returns Array<string> Array of intent strings

IntentBits

Type: Object

Properties

  • Message number Represents a bit flag for Telegram messages.
  • EditedMessage number Represents a bit flag for edited Telegram messages.
  • ChannelPost number Represents a bit flag for posts in Telegram channels.
  • EditedChannelPost number Represents a bit flag for edited posts in Telegram channels.
  • InlineQuery number Represents a bit flag for inline queries from users.
  • ChosenInlineResult number Represents a bit flag for chosen inline query results.
  • CallbackQuery number Represents a bit flag for callback queries from users.
  • ShippingQuery number Represents a bit flag for shipping queries from users.
  • PreCheckoutQuery number Represents a bit flag for pre-checkout queries from users.
  • Poll number Represents a bit flag for polls from users.
  • PollAnswer number Represents a bit flag for answers to polls from users.
  • MyChatMember number Represents a bit flag for a user's chat membership status in their own chat.
  • ChatMember number Represents a bit flag for a user's chat membership status in a chat they are a member of.
  • ChatJoinRequest number Represents a bit flag for a user's request to join a chat.

TelegramIntentBits

Type: Object

Properties

  • Message string Represents a Telegram message.
  • EditedMessage string Represents an edited Telegram message.
  • ChannelPost string Represents a post in a Telegram channel.
  • EditedChannelPost string Represents an edited post in a Telegram channel.
  • InlineQuery string Represents an inline query from a user.
  • ChosenInlineResult string Represents a chosen inline query result.
  • CallbackQuery string Represents a callback query from a user.
  • ShippingQuery string Represents a shipping query from a user.
  • PreCheckoutQuery string Represents a pre-checkout query from a user.
  • Poll string Represents a poll from a user.
  • PollAnswer string Represents an answer to a poll from a user.
  • MyChatMember string Represents a user's chat membership status in their own chat.
  • ChatMember string Represents a user's chat membership status in a chat they are a member of.
  • ChatJoinRequest string Represents a user's request to join a chat.

checkMessageLinks

Checks if a message contains any links.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains links, otherwise false.

extractUserMentions

Extracts user mentions from a message.

Parameters

  • message string The message to extract mentions from.

Returns Array<string> An array of user mentions found in the message.

extractHashtags

Extracts hashtags from a message.

Parameters

  • message string The message to extract hashtags from.

Returns Array<string> An array of hashtags found in the message.

checkLocation

Checks if a location object is valid.

Parameters

  • location object The location object to check.

    • location.latitude (string | number) The latitude of the location.
    • location.longitude (string | number) The longitude of the location.

Returns boolean Returns true if the location object is valid, otherwise false.

checkUserMentions

Checks if a message contains any user mentions.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains user mentions, otherwise false.

checkHashtags

Checks if a message contains any hashtags.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains hashtags, otherwise false.

checkPhoneNumber

Checks if a phone number is valid.

Parameters

  • phoneNumber string The phone number to check.

Returns boolean Returns true if the phone number is valid, otherwise false.

extractUserIdFromLink

Extracts the user ID from a Telegram link.

Parameters

  • link string The Telegram link to extract the user ID from.

Returns (string | null) The extracted user ID, or null if not found.

checkGroupOrChannel

Checks if a message contains a Telegram group or channel link.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains a group or channel link, otherwise false.

checkEmoji

Checks if a message contains only emoji characters.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains only emoji characters, otherwise false.

checkSticker

Checks if a message contains only a Telegram sticker.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains only a Telegram sticker, otherwise false.

extractUsernameFromLink

Extracts the username from a Telegram link.

Parameters

  • link string The Telegram link to extract the username from.

Returns (string | null) The extracted username, or null if not found.

checkBot

Checks if a message contains a Telegram bot username.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains a Telegram bot username, otherwise false.

checkChannel

Checks if a message contains a Telegram channel link (excluding usernames).

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains a Telegram channel link, otherwise false.

checkLink

Checks if a message contains a Telegram link.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains a Telegram link, otherwise false.

checkGroup

Checks if a message contains a Telegram group link.

Parameters

  • message string The message to check.

Returns boolean Returns true if the message contains a Telegram group link, otherwise false.

checkUsername

Checks if a username is valid.

Parameters

  • username string The username to check.

Returns boolean Returns true if the username is valid, otherwise false.

extractUsername

Extracts the username from a Telegram link.

Parameters

  • link string The Telegram link to extract the username from.

Returns (string | null) The extracted username, or null if not found.