atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 217 forks source link

Forward message with images #258

Closed ALEKSEYR554 closed 2 years ago

ALEKSEYR554 commented 2 years ago

I'm trying to forward one message containing multiple images/videos but as result i get multiple forwarded messages containing only one image from original message. How to forward whole message? My code

require 'telegram/bot'

token = "token"

Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    case message
    when Telegram::Bot::Types::CallbackQuery
      #
    when Telegram::Bot::Types::Message
      case message.text
      when '/start'
        bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}")
      when '/test'
          bot.api.send_message(
            parse_mode: 'html',
            chat_id: message.chat.id,
            text: "test_reply",
            reply_markup: Telegram::Bot::Types::ForceReply.new(
              force_reply: true,
              selective: true
            )
          )
      else
        unless message.reply_to_message.nil?
          case message.reply_to_message.text
          when "test_reply"
            bot.api.forward_message(
              chat_id:"-1001572333539",
              from_chat_id:message.chat.id,
              message_id: message.message_id,
              disable_notification:true,
            )
          end
        end
      end
    end
  end
end

Images: изображение изображение

ALEKSEYR554 commented 2 years ago

I fixed it by just copying all images file_id and sending new message containing all images