Skip to content

sendDocument

Sahri Riza Umami edited this page Jun 12, 2018 · 3 revisions

Sends a document (general file) message.

sendDocument(chat_id, reply_to_message_id, document, caption, parse_mode, thumbnail, thumb_width, thumb_height, disable_notification, from_background, reply_markup, callback, data)
Field Type Description
chat_id int53 Chat to send message.
reply_to_message_id int53 Identifier of a message to reply to.
document inputFile Document to be sent. The file can be defined by its unique ids, remote ids, local path or generated by client.
caption string Document caption; 0-200 characters.
parse_mode string Text parse mode.
thumbnail inputThumb Document thumbnail, if available.
thumb_width int32 Thumbnail width, usually shouldn't exceed 90. Use 0 if unknown.
thumb_height int32 Thumbnail height, usually shouldn't exceed 90. Use 0 if unknown.
disable_notification Bool Pass true, to disable notification about the message, doesn't works in secret chats
from_background Bool Pass true, if the message is sent from background
reply_markup ReplyMarkup Bots only. Markup for replying to message

Example

  • Send a document from local path into chat 1234567890. And add "Important" string in bold as its caption.

    sendDocument(1234567890, msg.id, '/tmp/script.lua', '*Important*', 'md')

    Response:

    {
      ["@type"] = "message",
      author_signature = "",
      can_be_deleted_for_all_users = true,
      can_be_deleted_only_for_self = false,
      can_be_edited = false,
      can_be_forwarded = true,
      chat_id = "1234567890",
      contains_unread_mention = false,
      content = {
        ["@type"] = "messageDocument",
        caption = {
          ["@type"] = "formattedText",
          entities = {
            {
              ["@type"] = "textEntity",
              length = 9,
              offset = 0,
              type = {
                ["@type"] = "textEntityTypeBold"
              }
            }
          },
          text = "Important"
        },
        document = {
          ["@type"] = "document",
          document = {
            ["@type"] = "file",
            expected_size = 3310,
            id = 6,
            ["local"] = {
              ["@type"] = "localFile",
              can_be_deleted = false,
              can_be_downloaded = false,
              downloaded_prefix_size = 3310,
              downloaded_size = 3310,
              is_downloading_active = false,
              is_downloading_completed = true,
              path = "/tmp/script.lua"
            },
            remote = {
              ["@type"] = "remoteFile",
              id = "",
              is_uploading_active = true,
              is_uploading_completed = false,
              uploaded_size = 0
            },
            size = 3310
          },
          file_name = "script.lua",
          mime_type = ""
        }
      },
      date = 1528825619,
      edit_date = 0,
      id = "15961423881",
      is_channel_post = false,
      is_outgoing = true,
      media_album_id = "0",
      reply_to_message_id = "15961423872",
      sender_user_id = 111112251,
      sending_state = {
        ["@type"] = "messageSendingStatePending"
      },
      ttl = 0,
      ttl_expires_in = 0,
      via_bot_user_id = 0,
      views = 0
    }  

Frequently Asked Questions
The Functions

Clone this wiki locally