Method: Telegrammer::Bot#send_photo

Defined in:
lib/telegrammer/bot.rb

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

Sends a photo to a user or group chat.

Examples:

bot = Telegrammer::Bot.new('[YOUR TELEGRAM TOKEN]')
image_file = File.open("foo.jpg")
bot.send_photo(chat_id: 123456789, photo: image_file)

Parameters:

  • params (Hash)

    hash of paramers to send to the sendPhoto 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).

  • :photo (File, String)

    Required. Photo to send. You can either pass a file_id as String to resend a photo that is already on the Telegram servers, or upload a new photo using multipart/form-data.

  • :caption (String)

    Optional. Photo caption (may also be used when resending photos by file_id).

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

See Also:



197
198
199
200
201
202
203
204
# File 'lib/telegrammer/bot.rb', line 197

def send_photo(params)
  extra_params_validation = {
    photo: { required: true, class: [File, String] },
    caption: { required: false, class: [String] }
  }

  send_something(:photo, params, extra_params_validation)
end