From 81d98a56f03fc7cef38ff541da32f97da1eb19d5 Mon Sep 17 00:00:00 2001 From: Alexander Tipugin Date: Fri, 28 Oct 2022 13:11:36 +0600 Subject: [PATCH] Check for message type in `example/bot.rb` --- examples/bot.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/bot.rb b/examples/bot.rb index 7111c5a..8b4fecb 100644 --- a/examples/bot.rb +++ b/examples/bot.rb @@ -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