Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TelegramAPI

Hierarchy

  • TelegramAPI

Index

Constructors

Properties

_token: string

Telegram API token

emitter: EventEmitter<string | symbol, any>

The event emitter for the telegram events

endpoint: string

Method endpoint

offset: undefined | number

Updates offset

onCallbackQueryCallback: undefined | TCallbackQueryCallback

Callback for the "callback_query" event

onChannelPostCallback: undefined | TMessageCallback

Callback for the "channel_post" event

onChosenInlineResultCallback: undefined | TChosenInlineResultCallback

Callback for the "chosen_inline_result" event

onEditedChannelPostCallback: undefined | TMessageCallback

Callback for the "edited_channel_post" event

onEditedMessageCallback: undefined | TMessageCallback

Callback for the "edited_message" event

onInlineQueryCallback: undefined | TInlineQueryCallback

Callback for the "inline_query" event

onMessageCallback: undefined | TMessageCallback

Callback for the "message" event

onPollAnswerCallback: undefined | TPollAnswerCallback

Callback for the "poll_answer" event

onPollCallback: undefined | TPollCallback

Callback for the "poll" event

onPreCheckoutQueryCallback: undefined | TPreCheckoutQueryCallback

Callback for the "pre_checkout_query" event

onShippingQueryCallback: undefined | TShippingQueryCallback

Callback for the "shipping_query" event

timeout: any

Timeout for the polling

Methods

  • 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.

    Parameters

    • callback_query_id: string

      Unique identifier for the query to be answered

    • Optional options: answerCallbackQueryOptions

      answerCallbackQueryOptions

    Returns Promise<boolean>

  • approveChatJoinRequest(chat_id: string | number, user_id: number): Promise<boolean>
  • Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    Returns Promise<boolean>

    boolean

  • banChatMember(chat_id: string | number, user_id: number, options?: banChatMemberOptions): Promise<boolean>
  • Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat 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 administrator rights. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    • Optional options: banChatMemberOptions

      banChatMemberOptions

    Returns Promise<boolean>

    boolean

  • banChatSenderChat(chat_id: string | number, sender_chat_id: number): Promise<boolean>
  • Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • sender_chat_id: number

      Unique identifier of the target sender chat

    Returns Promise<boolean>

    boolean

  • Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • from_chat_id: string | number

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

    • message_id: number

      Message identifier in the chat specified in from_chat_id

    • Optional options: copyMessageOptions

      copyMessageOptions

    Returns Promise<IMessageId>

    MessageId

    // this method works just like forwardMessage with the exception not to link the new message to the original message.
    await TelegramAPI.copyMessage(message.chat.id, message.chat.id, message.message_id);
    // => will forward the message you sent in the chat back to you. chat_id is the target chat or username and from_chat_id is the id of the channel the message was sent in.
  • Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.

    Parameters

    • chat_id: string | number

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

    • Optional options: createChatInviteLinkOptions

      createChatInviteLinkOptions

    Returns Promise<IChatInviteLink>

    IChatInviteLink

  • declineChatJoinRequest(chat_id: string | number, user_id: number): Promise<boolean>
  • Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    Returns Promise<boolean>

    boolean

  • deleteChatPhoto(chat_id: 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 administrator rights. Returns True on success.

    Parameters

    • chat_id: string | number

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

    Returns Promise<boolean>

    boolean

  • deleteChatStickerSet(chat_id: 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 administrator 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

    • chat_id: string | number

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

    Returns Promise<boolean>

    boolean

  • Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.

    Parameters

    Returns Promise<boolean>

    boolean

  • Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.

    Parameters

    • chat_id: string | number

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

    • invite_link: string

      The invite link to edit

    • Optional options: editChatInviteLinkOptions

      editChatInviteLinkOptions

    Returns Promise<IChatInviteLink>

    IChatInviteLink

  • Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

    Parameters

    • caption: string

      New caption of the message, 0-1024 characters after entities parsing

    • Optional options: editMessageCaptionOptions

      editMessageCaptionOptions

    Returns Promise<boolean | IMessage>

    IMessage | boolean

  • 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 is not an inline message, the edited Message is returned, otherwise True is returned.

    Parameters

    • latitude: number

      Latitude of new location

    • longitude: number

      Longitude of new location

    • Optional options: editMessageLiveLocationOptions

      editMessageLiveLocationOptions

    Returns Promise<boolean | IMessage>

    IMessage | boolean

  • Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

    Parameters

    • text: string

      New text of the message, 1-4096 characters after entities parsing

    • Optional options: editMessageTextOptions

      editMessageTextOptions

    Returns Promise<boolean | IMessage>

    boolean | IMessage

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

    Parameters

    • chat_id: string | number

    Returns Promise<boolean>

    boolean

  • Use this method to forward messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • from_chat_id: string | number

      Unique identifier for the chat where the original message was sent or channel username.

    • message_id: number

      Message identifier in the chat specified in from_chat_id

    • Optional options: forwardMessageOptions

      forwardMessageOptions

    Returns Promise<IMessage>

    IMessage

    await TelegramAPI.forwardMessage(message.chat.id, message.chat.id, message.message_id);
    // => will forward the message you sent in the chat back to you. chat_id is the target chat or username and from_chat_id is the id of the channel the message was sent in.
  • getChat(chat_id: string | number): Promise<IChat>
  • 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.). Returns a Chat object on success.

    Parameters

    • chat_id: string | number

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

    Returns Promise<IChat>

    IChat

  • getChatAdministrators(chat_id: string | number): Promise<IChatMember[]>
  • 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

    • chat_id: string | number

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

    Returns Promise<IChatMember[]>

    IChatMember[]

  • getChatMember(chat_id: string | number, user_id: number): Promise<IChatMember>
  • Use this method to get information about a member of a chat. Returns a ChatMember object on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    Returns Promise<IChatMember>

    IChatMember

  • getChatMemberCount(chat_id: string | number): Promise<number>
  • Use this method to get the number of members in a chat. Returns Int on success.

    Parameters

    • chat_id: string | number

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

    Returns Promise<number>

    number

  • getFile(file_id: string): Promise<IFile>
  • 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. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where 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

    Parameters

    • file_id: string

      File identifier to get info about

    Returns Promise<IFile>

    IFile

  • A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.

    Returns Promise<IUser>

    IUser

  • leaveChat(chat_id: string | number): Promise<boolean>
  • Use this method for your bot to leave a group, supergroup or channel. Returns True on success.

    Parameters

    • chat_id: string | number

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

    Returns Promise<boolean>

    boolean

  • on<E>(event: E, listener: (...callbacks: TelegramEvents[E]) => void): void
  • once<E>(event: E, listener: (...callbacks: TelegramEvents[E]) => void): void
  • pinChatMessage(chat_id: string | number, message_id: number, disable_notification?: boolean): Promise<boolean>
  • Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • message_id: number

      Identifier of a message to pin

    • Optional disable_notification: boolean

      Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.

    Returns Promise<boolean>

    boolean

  • processUpdates(updates: IUpdate[]): void
  • 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 administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    • Optional options: promoteChatMemberOptions

      promoteChatMemberOptions

    Returns Promise<boolean>

    boolean

  • 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 administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.

    Parameters

    • chat_id: string | number

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

    • user_id: number

      Unique identifier of the target user

    • Optional options: restrictChatMemberOptions

      restrictChatMemberOptions

    Returns Promise<boolean>

    boolean

  • revokeChatInviteLink(chat_id: string | number, invite_link: string): Promise<IChatInviteLink>
  • Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.

    Parameters

    • chat_id: string | number

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

    • invite_link: string

      The invite link to edit

    Returns Promise<IChatInviteLink>

    IChatInviteLink

  • Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • animation: string | LocalFile

      Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data.

    • Optional options: sendAnimationOptions

      sendAnimationOptions

    Returns Promise<IMessage>

    IMessage

    // => using file_id
    await TelegramAPI.sendAnimation(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

    // => using http URL
    await Telegram.sendAnimation(message.chat.id, "gif link from the internet")

    // => using local file
    await TelegramAPI.sendAnimation(message.chat.id, {file: "./cute_kitty.gif", content_type: "image/gif"})
    // content_type is optional
  • 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 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • audio: string | LocalFile

      Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data.

    • Optional options: sendAudioOptions

      sendAudioOptions

    Returns Promise<IMessage>

    IMessage

    // => using file_id
    await TelegramAPI.sendAudio(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

    // => using http URL
    await Telegram.sendAudio(message.chat.id, "audio link from the internet")

    // => using local file
    await TelegramAPI.sendAudio(message.chat.id, {file: "./nice_song.mp3", content_type: "audio/mpeg"})
    // content_type is optional
  • sendChatAction(chat_id: string | number, action: ActionType): 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). Returns True on success.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel

    • action: ActionType

      ActionType

    Returns Promise<boolean>

    boolean

  • Use this method to send phone contacts. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel

    • phone_number: string

      Contact's phone number

    • first_name: string

      Contact's first name

    • Optional options: sendContactOptions

      sendContactOptions

    Returns Promise<IMessage>

    IMessage

     // this will send a phone contact in the specified chat.
    await TelegramAPI.sendContact(message.chat.id, "3216513215", "Bob")
  • Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel

    • Optional options: sendDiceOptions

      sendDiceOptions

    Returns Promise<IMessage>

    IMessage

  • Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • document: string | LocalFile

      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, or upload a new one using multipart/form-data.

    • Optional options: sendDocumentOptions

      sendDocumentOptions

    Returns Promise<IMessage>

    IMessage

    // => using file_id
    await TelegramAPI.sendDocument(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

    // => using http URL
    await Telegram.sendDocument(message.chat.id, "pdf file link from the internet")

    // => using local file
    await TelegramAPI.sendDocument(message.chat.id, {file: "./invoide.pdf", content_type: "application/pdf"})
    // content_type is optional
  • Use this method to send point on the map. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel

    • latitude: number

      Latitude of the location

    • longitude: number

      Longitude of the location

    • Optional options: sendLocationOptions

      sendLocationOptions

    Returns Promise<IMessage>

    IMessage[]

    await TelegramAPI.sendLocation(message, chat_id, 40.712776, -74.005974, options);
    // will send a location card in the chat.
  • Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.

    Parameters

    Returns Promise<IMessage>

    IMessage

  • Use this method to send text messages. On success, the sent Message is returned.

    Parameters

    • chatId: string | number

      Unique identifier for the target chat or username of the target channel.

    • text: string

      Text of the message to be sent, 1-4096 characters after entities parsing

    • Optional options: sendMessageOptions

      sendMessageOptions

    Returns Promise<IMessage>

    IMessage

    await TelegramAPI.sendMessage(message.chat.id, "Hey there!") // => returns IMessage Object
    // With options
    await TelegramAPI.sendMessage(message.chat.id, "Hey from the bot!", { disable_notification: true})
    // => will send the message with no notification
  • Use this method to send photos. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • photo: string | LocalFile

      Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More info on Sending Files »

    • Optional options: sendPhotoOptions

      sendPhotoOptions

    Returns Promise<IMessage>

    IMessage

    // => using file_id
    await TelegramAPI.sendPhoto(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

    // => using http URL
    await Telegram.sendPhoto(message.chat.id, "https://cdn.discordapp.com/attachments/658790463595347968/950469680445919272/bc517a2af06ebeed02591cbff6349d3e.png")

    // => using local file
    await TelegramAPI.sendPhoto(message.chat.id, {file: "./nice.png", content_type: "image/png"})
    // content_type is optional
  • sendPoll(chat_id: string | number, question: string, answer_options: string[], options?: sendPollOptions): Promise<IMessage>
  • Use this method to send a native poll. On success, the sent Message is returned.

    Parameters

    • chat_id: string | number

      Unique identifier for the target chat or username of the target channel.

    • question: string

      Poll question, 1-300 characters

    • answer_options: string[]

      A JSON-serialized list of answer options, 2-10 strings 1-100 characters each

    • Optional options: sendPollOptions

      sendPollOptions

    Returns Promise<IMessage>

    IMessage

    await TelegramAPI.sendPoll(message.chat.id, "How are you doing today sir?", [ "Good", "not so bad", "fine"]);
    // => returns the IMessage object

    // With options
    await TelegramAPI.sendPoll(message.chat.id, "How are you doing today sir?", [ "Good", "not so bad", "fine"], {allows_multiple_answers: true, is_anonymous: true});
    // => this will send an anonymous poll to the chat with the ability to select multiple answers. returns IMessage
  • sendRequest(apiMethod: NeedleHttpVerbs, url: string, data: {}, options?: NeedleOptions): Promise<any>
  • Private Method for sending post requests to the Telegram Bot API

    Parameters

    • apiMethod: NeedleHttpVerbs

      Request Method

    • url: string

      API Endpoint

    • data: {}

      the data object if the request method is "POST"

      • Optional options: NeedleOptions

        NeedleOptions

      Returns Promise<any>

    • sendVenue(chat_id: string | number, latitude: number, longitude: number, title: string, address: string, options?: sendVenueOptions): Promise<IMessage>
    • Use this method to send information about a venue. On success, the sent Message is returned.

      Parameters

      • chat_id: string | number

        Unique identifier for the target chat or username of the target channel

      • latitude: number

        Latitude of the venue

      • longitude: number

        Longitude of the venue

      • title: string

        Name of the venue

      • address: string

        Address of the venue

      • Optional options: sendVenueOptions

        sendVenueOptions

      Returns Promise<IMessage>

      IMessage

      await TelegramAPI.sendVenue(message.chat.id, 40.712776, -74.005974, "New York","651 Fountain Ave, Brooklyn, NY 11208, USA");
      // Will send A location venue. Returns IMessage
    • Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

      Parameters

      • chat_id: string | number

        Unique identifier for the target chat or username of the target channel.

      • video: string | LocalFile

        Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data.

      • Optional options: sendVideoOptions

        sendVideoOptions

      Returns Promise<IMessage>

      IMessage

      // => using file_id
      await TelegramAPI.sendVideo(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

      // => using http URL
      await Telegram.sendVideo(message.chat.id, "video link from the internet")

      // => using local file
      await TelegramAPI.sendVideo(message.chat.id, {file: "./nice_video.mp4", content_type: "video/mp4"})
      // content_type is optional
    • 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. On success, the sent Message is returned.

      Parameters

      • chat_id: string | number

        Unique identifier for the target chat or username of the target channel.

      • videoNote: string | LocalFile

        Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported

      • Optional options: sendVideoNoteOptions

      Returns Promise<IMessage>

      sendVideoNoteOptions

      // => using file_id
      await TelegramAPI.sendVideoNote(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

      // => using local file
      await TelegramAPI.sendVideoNote(message.chat.id, {file: "./someVideo.mp4", content_type: "video/mp4"})
      // content_type is optional
    • 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). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size.

      Parameters

      • chat_id: string | number

        Unique identifier for the target chat or username of the target channel.

      • voice: string | LocalFile

        Audio 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, or upload a new one using multipart/form-data.

      • Optional options: sendVoiceOptions

      Returns Promise<IMessage>

      IMessage

      // => using file_id
      await TelegramAPI.sendVoice(message.chat.id, "AgACAgIAAxkDAAIGaGImV3d8t0uoWQvwIX7WxtDhqxikAAL0ujEb75EwSVj2k_EZ0-26AQADAgADbQADIwQ")

      // => using http URL
      await Telegram.sendVoice(message.chat.id, "ogg audio link from the internet")

      // => using local file
      await TelegramAPI.sendVoice(message.chat.id, {file: "./voice.ogg", content_type: "audio/ogg"})
      // content_type is optional
    • setChatAdministratorCustomTitle(chat_id: string | number, user_id: number, custom_title: string): Promise<boolean>
    • Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • user_id: number

        Unique identifier of the target user

      • custom_title: string

        New custom title for the administrator; 0-16 characters, emoji are not allowed

      Returns Promise<boolean>

      boolean

    • setChatDescription(chat_id: 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 administrator rights. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • Optional description: string

        Optional. New chat description, 0-255 characters

      Returns Promise<boolean>

      boolean

    • setChatPermissions(chat_id: string | number, permissions: IChatPermissions): Promise<boolean>
    • Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • permissions: IChatPermissions

        Object for new default chat permissions

      Returns Promise<boolean>

      boolean

    • setChatPhoto(chat_id: string | number, photo: LocalFile): Promise<boolean>
    • Use this method to set a new profile photo for the chat. 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 administrator rights. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • photo: LocalFile

        New chat photo. Must be local

      Returns Promise<boolean>

      boolean

    • setChatStickerSet(chat_id: string | number, sticker_set_name: 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 administrator 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

      • chat_id: string | number

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

      • sticker_set_name: string

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

      Returns Promise<boolean>

      boolean

    • setChatTitle(chat_id: 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 administrator rights. Returns True on success.

      Parameters

      • chat_id: 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>

      boolean

    • startPolling(): void
    • Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.

      Parameters

      Returns Promise<boolean | IMessage>

      IMessage | boolean

    • stopPolling(): void
    • unbanChatMember(chat_id: string | number, user_id: number, only_if_banned?: boolean): Promise<boolean>
    • Use this method to unban a previously banned 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. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • user_id: number

        Unique identifier of the target user

      • Optional only_if_banned: boolean

        Do nothing if the user is not banned

      Returns Promise<boolean>

      boolean

    • unbanChatSenderChat(chat_id: string | number, sender_chat_id: number): Promise<boolean>
    • Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • sender_chat_id: number

        Unique identifier of the target sender chat

      Returns Promise<boolean>

      boolean

    • unpinAllChatMessages(chat_id: string | number): Promise<boolean>
    • Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

      Parameters

      • chat_id: string | number

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

      Returns Promise<boolean>

      boolean

    • unpinChatMessage(chat_id: string | number, message_id?: number): Promise<boolean>
    • Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

      Parameters

      • chat_id: string | number

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

      • Optional message_id: number

        Optional. Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.

      Returns Promise<boolean>

      boolean

    Generated using TypeDoc