Skip to content

Commit

Permalink
Check for message type in example/bot.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
atipugin committed Oct 28, 2022
1 parent 3a6d619 commit 81d98a5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions examples/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

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 '/end'
bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}!")
else
bot.api.send_message(chat_id: message.chat.id, text: "I don't understand you :(")
case message
when Telegram::Bot::Types::Message
case message.text
when '/start'
bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}!")
when '/end'
bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}!")
else
bot.api.send_message(chat_id: message.chat.id, text: "I don't understand you :(")
end
end
end
end

0 comments on commit 81d98a5

Please sign in to comment.