Closed anton-kachan-dev closed 3 years ago
Probably InputMediaPhoto and InputMediaVideo types are missed in '/lib/telegram/bot/api.rb' file, in the INLINE_QUERY_RESULT_TYPES constant. When I added there Telegram::Bot::Types::InputMediaPhoto my code has worked. Resolve this problem please
OMG this is still happening, is this gem abandoned @atipugin? do you want help in maintaining?
@KachanAnton350504 this issue also happens if using Faraday::UploadIO
and isn't fixed by @krelly's patch
using Firaday::UploadIO
you have to use attach://
as in https://github.com/php-telegram-bot/core/issues/811, then @krelly patch works
OMG this is still happening, is this gem abandoned @atipugin? do you want help in maintaining?
@brauliobo Gem is maintained as you can see by releases and changelog. PR #215 wasn't merged because it adds InputMedia*
types to list of InlineQueryResult*
which is not correct.
Anyway i've added some changes to master
, following code should work now:
bot.api.send_media_group(
chat_id: message.chat.id,
media: [
Telegram::Bot::Types::InputMediaPhoto.new(media: 'attach://file1'),
Telegram::Bot::Types::InputMediaPhoto.new(media: 'attach://file2')
],
file1: Faraday::UploadIO.new('/path/to/file1.png', 'image/png'),
file2: Faraday::UploadIO.new('/path/to/file2.png', 'image/png')
)
Please check if everything's ok.
The below code don't work! Your code also doesnt work. Possible to help me?
photos = [
Telegram::Bot::Types::InputMediaPhoto.new(media: "https://example1.png"),
Telegram::Bot::Types::InputMediaPhoto.new(media: "https://example2.png")
]
Telegram::Bot::Client.run(@token) do |bot|
bot.api.send_media_group(chat_id: message.chat.id, media: photos)
end
@antondgx Found the solution, can you try this one:
photos = [
Telegram::Bot::Types::InputMediaPhoto.new(
type: 'photo',
media: 'https://images.unsplash.com/photo-1453728013993-6d66e9c9123a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80',
caption: 'MyCaption',
parse_mode: ''
),
Telegram::Bot::Types::InputMediaPhoto.new(
type: 'photo',
media: 'https://images.unsplash.com/photo-1453728013993-6d66e9c9123a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80',
caption: 'MyCaption',
parse_mode: ''
)
]
Telegram::Bot::Client.run('token') do |bot|
bot.api.send_media_group(
chat_id: 'chat_id',
media: photos,
caption: 'MyCaption'
)
end
It works too for me (you can try to open the file or try the code above instead of sending a request as in my case):
Telegram::Bot::Client.run('token') do |bot|
bot.api.send_media_group(
chat_id: 'chat_id',
media: [
Telegram::Bot::Types::InputMediaPhoto.new(media: 'attach://file1', caption: '123', parse_mode: ''),
Telegram::Bot::Types::InputMediaPhoto.new(media: 'attach://file2', caption: '123', parse_mode: ''),
Telegram::Bot::Types::InputMediaPhoto.new(media: 'attach://file3', caption: '123', parse_mode: '')
],
file1: Faraday::FilePart.new(StringIO.new(send_request("/api/v1/cameras/1/snapshot", :get)), 'image/jpeg'),
file2: Faraday::FilePart.new(StringIO.new(send_request("/api/v1/cameras/2/snapshot", :get)), 'image/jpeg'),
file3: Faraday::FilePart.new(StringIO.new(send_request("/api/v1/cameras/3/snapshot", :get)), 'image/jpeg'),
caption: 'My capture'
)
end
Actually had a problem, just added caption: '123', parse_mode: ''
to the Telegram::Bot::Types::InputMediaPhoto
and it started work
I'm using latest version of gem 0.8.6.1. This error when I try to set 2 photos in my channel. I Use this code:
And I get this error:
telegram-bot-ruby-0.8.6.1/lib/telegram/bot/api.rb:76:in
call': Telegram API has returned the error. (ok: "false", error_code: "400", description: "Bad Request: media to send are not specified") (Telegram::Bot::Exceptions::ResponseError) from /Users/antonkachan/.rvm/gems/ruby-2.4.2/gems/telegram-bot-ruby-0.8.6.1/lib/telegram/bot/api.rb:60:in
method_missing'