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

Get input from user and the input to be a variable to execute

Open myugan opened this issue 8 years ago • 1 comments

for example if i type 'Roby", this word would be an variable to display again like : hello Roby

myugan avatar Sep 18 '17 15:09 myugan

hmmm you can write it in different ways: with this example when you type like this: !test and bot will say You typed test

require 'telegram/bot'

token = 'YOUR_TELEGRAM_BOT_API_TOKEN'

Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    case message.text
    when /!(.+)/i
     bot.api.send_message(chat_id: message.chat.id, text: "You typed #{$1}")
    end
  end
end

and in this example bot will reply whatever you said

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"
    else 
       bot.api.send_message(chat_id: message.chat.id, text: "You typed #{message.text}")
    end
  end
end

i hope you find the solution ...

eVanilla avatar Oct 29 '17 11:10 eVanilla

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]