Skip to content

sendText

Sahri Riza Umami edited this page Jun 15, 2017 · 6 revisions

Sends a text message.

sendText(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, text, disable_web_page_preview, parse_mode)  

Returns sent message.
UpdateChatTopMessage will not be sent, so returned message should be used to update chat top message.

Option Description
chat_id Chat to send message.
reply_to_message_id Identifier of a message to reply to or 0.
disable_notification Pass true, to disable notification about the message.
from_background Pass true, if the message is sent from background.
reply_markup Bots only. Markup for replying to message.
text Text to send.
disable_web_page_preview Pass true to disable rich preview for link in the message text.
clear_draft Pass true if chat draft message should be deleted.
entities Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. Non-bot users can't use TextUrl entities. Can't be used with non-null parse_mode.
parse_mode Text parse mode, nullable. Can't be used along with entities.

Example

  • Send HTML formatted text message.

    sendText(-1001120734798, 0, 0, 1, nil, '<b>bold</b>\n<i>italic</i>\n<code>monospace</code>', 1, 'html')  

    Returns:

    {
      ID = "Message",
      can_be_deleted_ = true,
      can_be_edited_ = false,
      chat_id_ = "-1001120734798",
      content_ = {
        ID = "MessageText",
        entities_ = {
          {
            ID = "MessageEntityItalic",
            length_ = 6,
            offset_ = 5
          },
          {
            ID = "MessageEntityCode",
            length_ = 9,
            offset_ = 12
          },
          [0] = {
            ID = "MessageEntityBold",
            length_ = 4,
            offset_ = 0
          }
        },
        text_ = "bold\nitalic\nmonospace",
        web_page_ = false
      },
      date_ = 1497539303,
      edit_date_ = 0,
      forward_info_ = false,
      id_ = "1572864000000001",
      is_post_ = false,
      reply_markup_ = false,
      reply_to_message_id_ = 0,
      send_state_ = {
        ID = "MessageIsBeingSent"
      },
      sender_user_id_ = 194211431,
      ttl_ = 0,
      ttl_expires_in_ = 0,
      via_bot_user_id_ = 0,
      views_ = 0
    }
  • Send Markdown formatted text message.

    sendText(-1001120734798, 0, 0, 1, nil, '*bold*\n_italic_\n`monospace`', 1, 'md')  

    Returns:

    {
      ID = "Message",
      can_be_deleted_ = true,
      can_be_edited_ = false,
      chat_id_ = "-1001120734798",
      content_ = {
        ID = "MessageText",
        entities_ = {
          {
            ID = "MessageEntityItalic",
            length_ = 6,
            offset_ = 5
          },
          {
            ID = "MessageEntityCode",
            length_ = 9,
            offset_ = 12
          },
          [0] = {
            ID = "MessageEntityBold",
            length_ = 4,
            offset_ = 0
          }
        },
        text_ = "bold\nitalic\nmonospace",
        web_page_ = false
      },
      date_ = 1497539339,
      edit_date_ = 0,
      forward_info_ = false,
      id_ = "1572864001048577",
      is_post_ = false,
      reply_markup_ = false,
      reply_to_message_id_ = 0,
      send_state_ = {
        ID = "MessageIsBeingSent"
      },
      sender_user_id_ = 194211431,
      ttl_ = 0,
      ttl_expires_in_ = 0,
      via_bot_user_id_ = 0,
      views_ = 0
    }
  • Reply message 28311552.

    sendText(-1001120734798, 28311552, 0, 1, nil, 'Replied this message', 1, 'md')  

    Returns:

    {
      ID = "Message",
      can_be_deleted_ = true,
      can_be_edited_ = false,
      chat_id_ = "-1001120734798",
      content_ = {
        ID = "MessageText",
        entities_ = {},
        text_ = "Replied this message",
        web_page_ = false
      },
      date_ = 1497539452,
      edit_date_ = 0,
      forward_info_ = false,
      id_ = "1572864000000001",
      is_post_ = false,
      reply_markup_ = false,
      reply_to_message_id_ = 28311552,
      send_state_ = {
        ID = "MessageIsBeingSent"
      },
      sender_user_id_ = 194211431,
      ttl_ = 0,
      ttl_expires_in_ = 0,
      via_bot_user_id_ = 0,
      views_ = 0
    }

Test script
Frequently Asked Questions
The Functions

Clone this wiki locally