Skip to content

sendText

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

Sends text message.

sendText(chat_id, reply_to_message_id, text, parse_mode, disable_web_page_preview, clear_draft, disable_notification, from_background, reply_markup)
Field Type Description
chat_id int53 Chat to send message
reply_to_message_id int53 Identifier of a message to reply to
text string Formatted text to be sent. Only Bold, Italic, Code, Pre, PreCode and TextUrl entities are allowed to be specified manually.
parse_mode TextParseMode Text parse mode, nullable. Can't be used along with enitities.
disable_web_page_preview Bool Pass true if rich web page previews for URLs in the message text should be disabled.
clear_draft Bool Pass true if a chat message draft should be deleted.
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

  • Sends HTML formatted text message into chat 1234567890.

    sendText(1234567890, msg.id, '<b>Bold</b>, <i>italic</i>, <code>monospace</code> and <a href="https://github.com/rizaumami/tdbot.lua">link</a>', 'html', 1)

    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"] = "messageText",
        text = {
          ["@type"] = "formattedText",
          entities = {
            {
              ["@type"] = "textEntity",
              length = 4,
              offset = 0,
              type = {
                ["@type"] = "textEntityTypeBold"
              }
            },
            {
              ["@type"] = "textEntity",
              length = 6,
              offset = 6,
              type = {
                ["@type"] = "textEntityTypeItalic"
              }
            },
            {
              ["@type"] = "textEntity",
              length = 9,
              offset = 14,
              type = {
                ["@type"] = "textEntityTypeCode"
              }
            },
            {
              ["@type"] = "textEntity",
              length = 4,
              offset = 28,
              type = {
                ["@type"] = "textEntityTypeTextUrl",
                url = "https://github.com/rizaumami/tdbot.lua"
              }
            }
          },
          text = "Bold, italic, monospace and link"
        }
      },
      date = 1528822338,
      edit_date = 0,
      id = "15953035273",
      is_channel_post = false,
      is_outgoing = true,
      media_album_id = "0",
      reply_to_message_id = "15953035264",
      sender_user_id = 456786051,
      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