telegram-bot-ruby icon indicating copy to clipboard operation
telegram-bot-ruby copied to clipboard

reply message

Open mm580486 opened this issue 7 years ago • 1 comments

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

mm580486 avatar Jul 12 '17 12:07 mm580486

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

cippaciong avatar Jul 12 '17 12:07 cippaciong

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.

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]