telegram-bot-ruby
telegram-bot-ruby copied to clipboard
reply message
how to reply a simple message
for sample i want reply /start or other string
require 'telegram/bot'
token = 'YOUR_TELEGRAM_BOT_API_TOKEN'
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message.text
when '/start'
bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}")
when '/stop'
bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}")
end
end
end
Using reply_to_message_id
like I did in the example below should work (didn't test it though)
require 'telegram/bot'
token = 'YOUR_TELEGRAM_BOT_API_TOKEN'
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message.text
when '/start'
bot.api.send_message(chat_id: message.chat.id, reply_to_message_id: message.message_id, text: "Hello, #{message.from.first_name}")
when '/stop'
bot.api.send_message(chat_id: message.chat.id, reply_to_message_id: message.message_id, text: "Bye, #{message.from.first_name}")
end
end
end
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.