Closed maxutor closed 1 year ago
Not sure about Faraday::UploadIO, haven't used it. In my case it were URLs and this worked:
media: {
'type': 'photo',
'media': '<url>'
}.to_json
Not sure about Faraday::UploadIO, haven't used it. In my case it were URLs and this worked:
media: { 'type': 'photo', 'media': '<url>' }.to_json
Thank you, but I knew about that option. I'm just looking for a way to do tht without url.
Hey from future! I figured out :)
The trick is giving one more param named exactly as you set in "attach://
photo = Telegram::Bot::Types::InputMediaPhoto.new
photo.media = "attach://image"
photo.type = 'photo'
photo.caption = 'some text description'
photo.parse_mode = 'html'
bot.api.edit_message_media(
chat_id: 13213131,
message_id: 21313131,
media: photo.to_json,
image: Faraday::UploadIO.new( SomeImageFile, 'image', "image.jpg")
)
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
I sending photo:
photo = Faraday::UploadIO.new('app/first_image.jpeg', 'image/jpeg') bot.api.send_photo(chat_id: message.chat.id, photo: photo, caption: "Main menu")
and then I`m trying to change that photo:
photo = Telegram::Bot::Types::InputMediaPhoto.new photo.media = Faraday::UploadIO.new('app/images.jpeg', 'image/jpeg') bot.api.edit_message_media( chat_id: message.from.id, message_id: message.message.message_id, media: { type: 'photo', media: photo }.to_json
And that didn`t work I have such error:
Telegram API has returned the error. (ok: "false", error_code: "400", description: "Bad Request: can't parse InputMedia: Can't parse media JSON object") (Telegram::Bot::Exceptions::ResponseError)
I`m doing smth wrong or what?