telegram-bot-ruby
telegram-bot-ruby copied to clipboard
Get input from user and the input to be a variable to execute
for example if i type 'Roby", this word would be an variable to display again like : hello Roby
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 ...
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.