V
V
Vladislav Bukach2021-12-27 01:21:18
ruby
Vladislav Bukach, 2021-12-27 01:21:18

How to send audio files to telegram bot in ruby?

Tell me how files drop out when you click on the button

require 'telegram/bot'

token = 'my_token'

Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    case message
       when Telegram::Bot::Types::CallbackQuery
           case message.data
           when 'touch'
 bot.api.send_audio(chat_id: message.from.id, document: "CQACAgIAAxkBAAEPi7hhyONlERbiM4fCkO5VgGPJI1ipJgAC_hAAAtRFYEueXRPeGwlJriME")


             bot.api.answer_callback_query(callback_query_id: message.id)
           when 'test'
               bot.api.send_message(chat_id: message.from.id, text: "Don't test me!")
           end
       when Telegram::Bot::Types::Message
           case message.text
           when '/start'
               kb = [
                   Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Test', callback_data: 'test'),
                   Telegram::Bot::Types::InlineKeyboardButton.new(text: 'Touch me', callback_data: 'touch'),
               ]
               markup = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: kb)
               bot.api.send_message(chat_id: message.chat.id, text: 'Make a choice', reply_markup: markup)
           end
       end
   end
end


Tell me what's wrong here?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question