Method: Telegrammer::Bot#send_message

Defined in:
lib/telegrammer/bot.rb

#send_message(params) ⇒ Telegrammer::DataTypes::Message

Send text messages to a user or group chat.

Examples:

bot = Telegrammer::Bot.new('[YOUR TELEGRAM TOKEN]')

bot.send_message(
  chat_id: 123456789,
  text: "Hello World!"
)

Parameters:

  • params (Hash)

    hash of paramers to send to the sendMessage API operation.

Options Hash (params):

  • :chat_id (Integer, String)

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

  • :text (String)

    Required. Text of the message to be sent

  • :parse_mode (String)

    Optional. Send Markdown, if you want Telegram apps to show bold, italic and inline URLs in your bot’s message.

  • :disable_web_page_preview (Boolean)

    Optional. Disables link previews for links in this message

  • :reply_to_message_id (Integer)

    Optional. If the message is a reply, ID of the original message

  • :reply_markup (Telegrammer::DataTypes::ReplyKeyboardMarkup, Telegrammer::DataTypes::ReplyKeyboardHide, Telegrammer::DataTypes::ForceReply)

    Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.

Returns:

Raises:



136
137
138
139
140
141
142
143
144
# File 'lib/telegrammer/bot.rb', line 136

def send_message(params)
  extra_params_validation = {
    text: { required: true, class: [String] },
    parse_mode: { required: false, class: [String] },
    disable_web_page_preview: { required: false, class: [TrueClass, FalseClass] }
  }

  send_something(:message, params, extra_params_validation)
end