Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question