README.md in telegram-bot-ruby-0.5.0.beta2 vs README.md in telegram-bot-ruby-0.5.0.beta3

- old
+ new

@@ -9,11 +9,11 @@ ## Installation Add following line to your Gemfile: ```ruby -gem 'telegram-bot-ruby' +gem 'telegram-bot-ruby', '~> 0.5.0.beta3' ``` And then execute: ```shell @@ -21,11 +21,11 @@ ``` Or install it system-wide: ```shell -$ gem install telegram-bot-ruby +$ gem install telegram-bot-ruby --pre ``` ## Usage First things first, you need to [obtain a token](https://core.telegram.org/bots#botfather) for your bot. Then create your Telegram bot like this: @@ -79,17 +79,17 @@ Furthermore, you can ask user to share location or phone number using `KeyboardButton`: ```ruby bot.listen do |message| - kb = [ - Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true), - Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true) - ] - markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb) - bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup) - end + kb = [ + Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true), + Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true) + ] + markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb) + bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup) +end ``` ## Inline keyboards [Bot API 2.0](https://core.telegram.org/bots/2-0-intro) brought us new inline keyboards. Example: @@ -121,14 +121,19 @@ ```ruby bot.listen do |message| case message when Telegram::Bot::Types::InlineQuery results = [ - Telegram::Bot::Types::InlineQueryResultArticle - .new(id: 1, title: 'First article', message_text: 'Very interesting text goes here.'), - Telegram::Bot::Types::InlineQueryResultArticle - .new(id: 2, title: 'Second article', message_text: 'Another interesting text here.') - ] + [1, 'First article', 'Very interesting text goes here.'], + [2, 'Second article', 'Another interesting text here.'] + ].map do |arr| + Telegram::Bot::Types::InlineQueryResultArticle.new( + id: arr[0], + title: arr[1], + input_message_content: Telegram::Bot::Types::InputTextMessageContent.new(message_text: arr[2]) + ) + end + bot.api.answer_inline_query(inline_query_id: message.id, results: results) when Telegram::Bot::Types::Message bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}!") end end