Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • TelegramClient

Index

Constructors

constructor

Properties

Readonly accessToken

accessToken: string

The access token used by the client.

Readonly axios

axios: AxiosInstance

The underlying axios instance.

Methods

addStickerToSet

  • addStickerToSet(userId: number, name: string, pngSticker: string, emojis: string, options?: AddStickerToSetOption): Promise<boolean>
  • Use this method to add a new sticker to a set created by the bot.

    see

    https://core.telegram.org/bots/api#addstickertoset

    example
    
    

    Parameters

    • userId: number

      User identifier of sticker set owner

    • name: string

      Sticker set name

    • pngSticker: string

      Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. Upload file is not supported yet.

    • emojis: string

      One or more emoji corresponding to the sticker

    • Optional options: AddStickerToSetOption

      Options for other optional parameters.

    Returns Promise<boolean>

    Returns True on success.

answerCallbackQuery

  • Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.

    Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

    see

    https://core.telegram.org/bots/api#answercallbackquery

    example
    
    

    Parameters

    • callbackQueryId: string

      Unique identifier for the query to be answered

    • options: AnswerCallbackQueryOption

      Optional parameters for other parameters.

    Returns Promise<boolean>

answerInlineQuery

  • Use this method to send answers to an inline query. No more than 50 results per query are allowed.

    see

    https://core.telegram.org/bots/api#answerinlinequery

    example
    await client.answerInlineQuery(
    'INLINE_QUERY_ID',
    [
    {
    type: 'photo',
    id: 'UNIQUE_ID',
    photoFileId: 'FILE_ID',
    title: 'PHOTO_TITLE',
    },
    {
    type: 'audio',
    id: 'UNIQUE_ID',
    audioFileId: 'FILE_ID',
    caption: 'AUDIO_TITLE',
    },
    ],
    {
    cacheTime: 1000,
    }
    );

    Parameters

    • inlineQueryId: string

      Unique identifier for the answered query

    • results: InlineQueryResult[]

      A JSON-serialized array of results for the inline query

    • Optional options: AnswerInlineQueryOption

      Optional parameters for other parameters.

    Returns Promise<boolean>

    On success, True is returned.

answerPreCheckoutQuery

  • Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

    see

    https://core.telegram.org/bots/api#answerprecheckoutquery

    example
    await client.answerPreCheckoutQuery('UNIQUE_ID', true);
    

    Parameters

    • preCheckoutQueryId: string

      Unique identifier for the query to be answered

    • ok: boolean

      Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.

    • Optional options: AnswerPreCheckoutQueryOption

      Optional parameters for other parameters.

    Returns Promise<boolean>

    On success, True is returned.

answerShippingQuery

  • If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.

    see

    https://core.telegram.org/bots/api#answershippingquery

    example
    await client.answerShippingQuery('UNIQUE_ID', true);
    

    Parameters

    • shippingQueryId: string

      Unique identifier for the query to be answered

    • ok: boolean

      Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)

    • Optional options: AnswerShippingQueryOption

      Options for other optional parameters.

    Returns Promise<boolean>

createNewStickerSet

  • createNewStickerSet(userId: number, name: string, title: string, pngSticker: string, emojis: string, options?: CreateNewStickerSetOption): Promise<boolean>
  • Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set.

    see

    https://core.telegram.org/bots/api#createnewstickerset

    example
    
    

    Parameters

    • userId: number

      User identifier of created sticker set owner

    • name: string

      Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in _by_<bot username>. <bot_username> is case insensitive. 1-64 characters.

    • title: string

      Sticker set title, 1-64 characters

    • pngSticker: string

      Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet. Upload file is not supported yet.

    • emojis: string
    • Optional options: CreateNewStickerSetOption

    Returns Promise<boolean>

    Returns True on success.

deleteChatPhoto

  • deleteChatPhoto(chatId: string | number): Promise<boolean>
  • 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.

    Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.

    see

    https://core.telegram.org/bots/api#deletechatphoto

    example
    await client.deleteChatPhoto(CHAT_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    Returns Promise<boolean>

    Returns True on success.

deleteChatStickerSet

  • deleteChatStickerSet(chatId: string | number): Promise<boolean>
  • Use this method to delete a group sticker set from 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 canSetStickerSet optionally returned in getChat requests to check if the bot can use this method.

    see

    https://core.telegram.org/bots/api#deletechatstickerset

    example
    await client.deleteChatStickerSet(CHAT_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

    Returns Promise<boolean>

    Returns True on success.

deleteMessage

  • deleteMessage(chatId: string | number, messageId: number): Promise<boolean>
  • Use this method to delete a message, including service messages, with the following limitations:

    • A message can only be deleted if it was sent less than 48 hours ago.
    • Bots can delete outgoing messages in private chats, groups, and supergroups.
    • Bots can delete incoming messages in private chats.
    • Bots granted can_post_messages permissions can delete outgoing messages in channels.
    • If the bot is an administrator of a group, it can delete any message there.
    • If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
    see

    https://core.telegram.org/bots/api#deletemessage

    example
    await client.deleteMessage(CHAT_ID, MESSAGE_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: number

      Identifier of the message to delete

    Returns Promise<boolean>

    True on success.

deleteStickerFromSet

  • deleteStickerFromSet(sticker: string): Promise<boolean>

deleteWebhook

  • deleteWebhook(): Promise<boolean>

editMessageCaption

editMessageLiveLocation

  • Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.

    see

    https://core.telegram.org/bots/api#editmessagelivelocation

    example
    await client.editMessageLiveLocation(
    {
    latitude: 30,
    longitude: 45,
    },
    {
    messageId: MESSAGE_ID,
    }
    );

    Parameters

    • location: { latitude: number; longitude: number }

      Object contains new latitude and longitude.

      • latitude: number

        Latitude of new location

      • longitude: number

        Longitude of new location

    • options: EditMessageLiveLocationOption

      One of chatId, messageId or inlineMessageId is required.

    Returns Promise<boolean | Message>

editMessageMedia

  • Use this method to edit animation, audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.

    see

    https://core.telegram.org/bots/api#editmessagemedia

    example
    
    

    Parameters

    Returns Promise<boolean | Message>

editMessageReplyMarkup

  • Use this method to edit only the reply markup of messages.

    see

    https://core.telegram.org/bots/api#editmessagereplymarkup

    example
    await client.editMessageReplyMarkup(
    {
    keyboard: [[{ text: 'new_button_1' }, { text: 'new_button_2' }]],
    resizeKeyboard: true,
    oneTimeKeyboard: true,
    },
    { messageId: MESSAGE_ID }
    );

    Parameters

    • replyMarkup: InlineKeyboardMarkup

      A JSON-serialized object for an inline keyboard.

    • Optional options: EditOption

      Options for other optional parameters. One of chatId, messageId or inlineMessageId is required.

    Returns Promise<boolean | Message>

    On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.

editMessageText

exportChatInviteLink

  • exportChatInviteLink(chatId: string | number): Promise<string>
  • Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

    Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink – after this the link will become available to the bot via the getChat method. If your bot needs to generate a new invite link replacing its previous one, use exportChatInviteLink again.

    see

    https://core.telegram.org/bots/api#exportchatinvitelink

    example
    await client.exportChatInviteLink(CHAT_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    Returns Promise<string>

    Returns the new invite link as String on success.

forwardMessage

  • forwardMessage(chatId: string | number, fromChatId: string | number, messageId: number, options?: ForwardMessageOption): Promise<Message>
  • Use this method to forward messages of any kind.

    see

    https://core.telegram.org/bots/api#forwardmessage

    example
    await client.forwardMessage(CHAT_ID, USER_ID, MESSAGE_ID, {
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • fromChatId: string | number

      Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)

    • messageId: number

      Message identifier in the chat specified in fromChatId

    • Optional options: ForwardMessageOption

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

getChat

  • getChat(chatId: string | number): Promise<Chat>
  • Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).

    see

    https://core.telegram.org/bots/api#getchat

    example
    await client.getChat(CHAT_ID);
    // {
    // id: 313534466,
    // firstName: 'first',
    // lastName: 'last',
    // username: 'username',
    // type: 'private',
    // }

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    Returns Promise<Chat>

    Returns a Chat object on success.

getChatAdministrators

  • getChatAdministrators(chatId: string | number): Promise<any[]>
  • Use this method to get a list of administrators in a chat.

    see

    https://core.telegram.org/bots/api#getchatmemberscount

    example
    await client.getChatAdministrators(CHAT_ID);
    // [
    // {
    // user: {
    // id: 313534466,
    // firstName: 'first',
    // lastName: 'last',
    // username: 'username',
    // languangeCode: 'zh-TW',
    // },
    // status: 'creator',
    // },
    // ]

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    Returns Promise<any[]>

    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.

getChatMember

  • getChatMember(chatId: string | number, userId: number): Promise<any>
  • Use this method to get information about a member of a chat.

    see

    https://core.telegram.org/bots/api#getchatmember

    example
    await client.getChatMember(CHAT_ID, USER_ID);
    // {
    // user: {
    // id: 313534466,
    // firstName: 'first',
    // lastName: 'last',
    // username: 'username',
    // languangeCode: 'zh-TW',
    // },
    // status: 'creator',
    // }

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

    • userId: number

      Unique identifier of the target user

    Returns Promise<any>

    Returns a ChatMember object on success.

getChatMembersCount

  • getChatMembersCount(chatId: string | number): Promise<number>

getFile

  • getFile(fileId: string): Promise<File>
  • Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size.

    see

    https://core.telegram.org/bots/api#getfile

    example
    await client.getFile('UtAqweADGTo4Gz8cZAeR-ouu4XBx78EeqRkABPL_pM4A1UpI0koD65K2')
    // {
    // fileId: 'UtAqweADGTo4Gz8cZAeR-ouu4XBx78EeqRkABPL_pM4A1UpI0koD65K2',
    // fileSize: 106356,
    // filePath: 'photos/1068230105874016297.jpg',
    // }

    Parameters

    • fileId: string

      File identifier to get info about

    Returns Promise<File>

    On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.

getFileLink

  • getFileLink(fileId: string): Promise<string>
  • Get link for file. This is an extension method of getFile()

    see

    https://core.telegram.org/bots/api#getfile

    example
    await client.getFileLink('UtAqweADGTo4Gz8cZAeR-ouu4XBx78EeqRkABPL_pM4A1UpI0koD65K2')
    // 'https://api.telegram.org/file/bot<ACCESS_TOKEN>/photos/1068230105874016297.jpg'

    Parameters

    • fileId: string

      File identifier to get info about

    Returns Promise<string>

    On success, a File URL is returned.

getGameHighScores

  • Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.

    This method will currently return scores for the target user, plus two of his closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.

    see

    https://core.telegram.org/bots/api#getgamehighscores

    example
    await client.getGameHighScores(USER_ID);
    // [
    // {
    // position: 1,
    // user: {
    // id: 427770117,
    // isBot: false,
    // firstName: 'first',
    // },
    // score: 999,
    // },
    // ]

    Parameters

    • userId: number

      Target user id

    • Optional options: EditOption

      Optional parameters for other parameters.

    Returns Promise<GameHighScore[]>

    Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.

getMe

  • getMe(): Promise<User>

getStickerSet

getUpdates

  • Use this method to receive incoming updates using long polling.

    • This method will not work if an outgoing webhook is set up.
    • In order to avoid getting duplicate updates, recalculate offset after each server response.
    see

    https://core.telegram.org/bots/api#getupdates

    example
    await client.getUpdates({ limit: 10 });
    // [
    // {
    // updateId: 513400512,
    // message: {
    // messageId: 3,
    // from: {
    // id: 313534466,
    // firstName: 'first',
    // lastName: 'last',
    // username: 'username',
    // },
    // chat: {
    // id: 313534466,
    // firstName: 'first',
    // lastName: 'last',
    // username: 'username',
    // type: 'private',
    // },
    // date: 1499402829,
    // text: 'hi',
    // },
    // },
    // ...
    // ]

    Parameters

    Returns Promise<Update[]>

    An array of Update objects is returned.

getUserProfilePhotos

  • Use this method to get a list of profile pictures for a user.

    see

    https://core.telegram.org/bots/api#getuserprofilephotos

    example
    await client.getUserProfilePhotos(USER_ID, { limit: 1 });
    // {
    // totalCount: 3,
    // photos: [
    // [
    // {
    // fileId:
    // 'AgADBAADGTo4Gz8cZAeR-ouu4XBx78EeqRkABHahi76pN-aO0UoDA050',
    // fileSize: 14650,
    // width: 160,
    // height: 160,
    // },
    // {
    // fileId:
    // 'AgADBAADGTo4Gz8cZAeR-ouu4XBx78EeqRkABKCfooqTgFUX0EoD5B1C',
    // fileSize: 39019,
    // width: 320,
    // height: 320,
    // },
    // {
    // fileId:
    // 'AgADBAADGTo4Gz8cZAeR-ouu4XBx78EeqRkABPL_pC9K3UpI0koD1B1C',
    // fileSize: 132470,
    // width: 640,
    // height: 640,
    // },
    // ],
    // ],
    // }

    Parameters

    • userId: number

      Unique identifier of the target user

    • Optional options: GetUserProfilePhotosOption

      Options for other optional parameters.

    Returns Promise<UserProfilePhotos>

    Returns a UserProfilePhotos object.

getWebhookInfo

kickChatMember

  • kickChatMember(chatId: string | number, userId: number, options?: KickChatMemberOption): Promise<boolean>
  • Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

    Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group. Otherwise members may only be removed by the group's creator or by the member that added them.

    see

    https://core.telegram.org/bots/api#kickchatmember

    example
    await client.kickChatMember(CHAT_ID, USER_ID, { untilDate: UNIX_TIME });
    

    Parameters

    • chatId: string | number

      Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)

    • userId: number

      Unique identifier of the target user

    • Optional options: KickChatMemberOption

    Returns Promise<boolean>

    Returns True on success.

leaveChat

  • leaveChat(chatId: string | number): Promise<boolean>

pinChatMessage

  • pinChatMessage(chatId: string | number, messageId: number, options?: PinChatMessageOption): Promise<boolean>
  • Use this method to pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel.

    see

    https://core.telegram.org/bots/api#pinchatmessage

    example
    await client.pinChatMessage(CHAT_ID, MESSAGE_ID, { disableNotification: true });
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • messageId: number

      Identifier of a message to pin

    • Optional options: PinChatMessageOption

      Options for other optional parameters.

    Returns Promise<boolean>

    Returns True on success.

promoteChatMember

  • Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.

    see

    https://core.telegram.org/bots/api#promotechatmember

    example
    await client.promoteChatMember(CHAT_ID, USER_ID, {
    canChangeInfo: true,
    canInviteUsers: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • userId: number

      Unique identifier of the target user

    • Optional options: PromoteChatMemberOption

      Options for other optional parameters

    Returns Promise<boolean>

    Returns True on success.

restrictChatMember

  • Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user.

    see

    https://core.telegram.org/bots/api#restrictchatmember

    example
    await client.restrictChatMember(CHAT_ID, USER_ID, { canSendMessages: true });
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

    • userId: number

      Unique identifier of the target user

    • permissions: ChatPermissions

      New user permissions

    • Optional options: RestrictChatMemberOption

      Other optional parameters.

    Returns Promise<boolean>

    Returns True on success.

sendAnimation

  • Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

    see

    https://core.telegram.org/bots/api#sendanimation

    example
    
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • animation: string

      Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended) or pass an HTTP URL as a String for Telegram to get an animation from the Internet. Upload file is not supported yet.

    • options: SendAnimationOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendAudio

  • Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

    For sending voice messages, use the sendVoice method instead.

    see

    https://core.telegram.org/bots/api#sendaudio

    example
    await client.sendAudio(CHAT_ID, 'https://example.com/audio.mp3', {
    caption: 'gooooooodAudio',
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • audio: string

      -Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended) or pass an HTTP URL as a String for Telegram to get an audio file from the Internet. Upload file is not supported yet.

    • options: SendAudioOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendChatAction

  • sendChatAction(chatId: string | number, action: ChatAction): Promise<boolean>
  • Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

    Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.

    see

    https://core.telegram.org/bots/api#sendchataction

    example
    await client.sendChatAction(CHAT_ID, 'typing');
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • action: ChatAction

      Types of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_audio or upload_audio for audio files, upload_document for general files, find_location for location data, record_video_note or upload_video_note for video notes.

    Returns Promise<boolean>

sendContact

sendDocument

  • Use this method to send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

    see

    https://core.telegram.org/bots/api#senddocument

    example
    await client.sendDocument(CHAT_ID, 'https://example.com/doc.gif', {
    caption: 'gooooooodDocument',
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • document: string

      File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet. Upload file is not supported yet.

    • options: SendDocumentOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendGame

sendInvoice

  • Use this method to send invoices.

    see

    https://core.telegram.org/bots/api#sendinvoice

    example
    await client.sendInvoice(CHAT_ID, {
    title: 'product name',
    description: 'product description',
    payload: 'bot-defined invoice payload',
    providerToken: 'PROVIDER_TOKEN',
    startParameter: 'pay',
    currency: 'USD',
    prices: [
    { label: 'product', amount: 11000 },
    { label: 'tax', amount: 11000 },
    ],
    });

    Parameters

    • chatId: number

      Unique identifier for the target private chat

    • product: Product
    • Optional options: SendInvoiceOption

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendLocation

  • sendLocation(chatId: string | number, location: { latitude: number; longitude: number }, options?: SendLocationOption): Promise<Message>
  • Use this method to send point on the map.

    see

    https://core.telegram.org/bots/api#sendlocation

    example
    await client.sendLocation(
    CHAT_ID,
    {
    latitude: 30,
    longitude: 45,
    },
    {
    disableNotification: true,
    }
    );

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • location: { latitude: number; longitude: number }

      Object contains latitude and longitude.

      • latitude: number

        Latitude of the location.

      • longitude: number

        Longitude of the location.

    • Optional options: SendLocationOption

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendMediaGroup

sendMessage

sendPhoto

  • Use this method to send photos.

    see

    https://core.telegram.org/bots/api#sendphoto

    example
    await client.sendPhoto(CHAT_ID, 'https://example.com/image.png', {
    caption: 'gooooooodPhoto',
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • photo: string

      Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended) or pass an HTTP URL as a String for Telegram to get a photo from the Internet. Upload file is not supported yet.

    • options: SendPhotoOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendPoll

  • sendPoll(chatId: string | number, question: string, options: string[], otherOptions?: SendPollOption): Promise<Message>
  • Use this method to send a native poll. A native poll can't be sent to a private chat.

    see

    https://core.telegram.org/bots/api#sendpoll

    example
    
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername). A native poll can't be sent to a private chat.

    • question: string

      Poll question, 1-255 characters

    • options: string[]

      List of answer options, 2-10 strings 1-100 characters each

    • Optional otherOptions: SendPollOption

      Optional parameters for other parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendSticker

  • Use this method to send static .WEBP or animated .TGS stickers.

    see

    https://core.telegram.org/bots/api#sendsticker

    example
    await client.sendSticker(CHAT_ID, 'CAADAgADQAADyIsGAAE7MpzFPFQX5QI', {
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • sticker: string

      Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), or pass an HTTP URL as a String for Telegram to get a .webp file from the Internet. Upload file is not supported yet.

    • Optional options: SendStickerOption

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendVenue

  • Use this method to send information about a venue.

    see

    https://core.telegram.org/bots/api#sendvenue

    example
    await client.sendVenue(
    CHAT_ID,
    {
    latitude: 30,
    longitude: 45,
    title: 'a_title',
    address: 'an_address',
    },
    {
    disableNotification: true,
    }
    );

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • venue: Venue

      Object contains information of the venue.

    • Optional options: SendVenueOption

      Optional parameters for other parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendVideo

  • Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

    see

    https://core.telegram.org/bots/api#sendvideo

    example
    await client.sendVideo(CHAT_ID, 'https://example.com/video.mp4', {
    caption: 'gooooooodVideo',
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • video: string

      Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended) or pass an HTTP URL as a String for Telegram to get a video from the Internet. Upload file is not supported yet.

    • options: SendVideoOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendVideoNote

  • As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages.

    see

    https://core.telegram.org/bots/api#sendvideonote

    example
    await client.sendVideoNote(CHAT_ID, 'https://example.com/video_note.mp4', {
    duration: 40,
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • videoNote: string

      Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers. Sending video notes by a URL is currently unsupported. Upload file is not supported yet.

    • options: SendVideoNoteOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

sendVoice

  • Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

    see

    https://core.telegram.org/bots/api#sendvoice

    example
    await client.sendVoice(CHAT_ID, 'https://example.com/voice.ogg', {
    caption: 'gooooooodVoice',
    disableNotification: true,
    });

    Parameters

    • chatId: string | number

      identifier for the target chat or username of the target channel (in the format @channelusername)

    • voice: string

      Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL as a String for Telegram to get a file from the Internet. Upload file is not supported yet.

    • options: SendVoiceOption = {}

      Options for other optional parameters.

    Returns Promise<Message>

    On success, the sent Message is returned.

setChatDescription

  • setChatDescription(chatId: string | number, description: string): Promise<boolean>
  • Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

    see

    https://core.telegram.org/bots/api#setchatdescription

    example
    await client.setChatDescription(CHAT_ID, 'New Description');
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • description: string

      New chat description, 0-255 characters

    Returns Promise<boolean>

    Returns True on success.

setChatPermissions

  • setChatPermissions(chatId: string | number, permissions: ChatPermissions): Promise<boolean>

setChatStickerSet

  • setChatStickerSet(chatId: string | number, stickerSetName: string): Promise<boolean>
  • 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 canSetStickerSet optionally returned in getChat requests to check if the bot can use this method.

    see

    https://core.telegram.org/bots/api#setchatstickerset

    example
    await client.setChatStickerSet(CHAT_ID, 'Sticker Set Name');
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)

    • stickerSetName: string

      Name of the sticker set to be set as the group sticker set

    Returns Promise<boolean>

    Returns True on success.

setChatTitle

  • setChatTitle(chatId: string | number, title: string): Promise<boolean>
  • Use this method to change the title of a chat. Titles 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.

    Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.

    see

    https://core.telegram.org/bots/api#setchattitle

    example
    await client.setChatTitle(CHAT_ID, 'New Title');
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    • title: string

      New chat title, 1-255 characters

    Returns Promise<boolean>

    Returns True on success.

setGameScore

  • Use this method to set the score of the specified user in a game.

    see

    https://core.telegram.org/bots/api#setgamescore

    example
    await client.setGameScore(USER_ID, 999);
    

    Parameters

    • userId: number

      User identifier

    • score: number

      New score, must be non-negative

    • Optional options: SetGameScoreOption

      Options for other optional parameters.

    Returns Promise<boolean | Message>

    On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

setStickerPositionInSet

  • setStickerPositionInSet(sticker: string, position: number): Promise<boolean>

setWebhook

  • Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.

    If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.

    see

    https://core.telegram.org/bots/api#setwebhook

    example
    await client.setWebhook('https://4a16faff.ngrok.io/');
    

    Parameters

    • url: string

      HTTPS url to send updates to. Use an empty string to remove webhook integration.

    • options: SetWebhookOption = {}

      Optional parameters.

    Returns Promise<boolean>

    True on success.

stopMessageLiveLocation

stopPoll

  • stopPoll(chatId: string | number, messageId: number, options?: StopPollOption): Promise<Poll>

unbanChatMember

  • unbanChatMember(chatId: string | number, userId: number): Promise<boolean>
  • Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work.

    see

    https://core.telegram.org/bots/api#unbanchatmember

    example
    await client.unbanChatMember(CHAT_ID, USER_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target group or username of the target supergroup or channel (in the format @username)

    • userId: number

      Unique identifier of the target user

    Returns Promise<boolean>

    Returns True on success.

unpinChatMessage

  • unpinChatMessage(chatId: string | number): Promise<boolean>
  • Use this method to unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel.

    see

    https://core.telegram.org/bots/api#unpinchatmessage

    example
    await client.unpinChatMessage(CHAT_ID);
    

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel (in the format @channelusername)

    Returns Promise<boolean>

    Returns True on success.

Static connect

Generated using TypeDoc