telegram-bot-ruby 0.5.0.beta2 → 0.5.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21c521862fb67cf5de03a54c65f4b459350ad9d2
4
- data.tar.gz: fd0095bc8c4815329289f92af0fbf3ec292ea830
3
+ metadata.gz: 7298e9dd9e093d7de1356822438209c04d1bfdff
4
+ data.tar.gz: 753d71fec2e945d3b3d7b415770f27e512940aae
5
5
  SHA512:
6
- metadata.gz: 55b5682ccc05202ff57ff36d12f4d762c5083253a1b074e1b330294a7fe0918e5929c7e2aed7f902e66c45ffe7cfd092915cf66071d7fe56d016c5033eae4b15
7
- data.tar.gz: 7c2468fbe973b32ceb7f144f3c886122dc35ff79950c86b95477b7f3f8cafb0bb094cd757e819aa37e73c41b1e630f29c0c1f3baabf8cf2026b2c68dac3f8022
6
+ metadata.gz: 447fa08cffcd7a987afaf9a5bc92c1449fbddbaa63ad5a5726d4157ccf243309d713cb95a67f2defee5792b5e190a27b665e081c3db27d7e58727dce1ad825e2
7
+ data.tar.gz: 61787d09c34c01c47e152891e9af89163f3694287f95334c8567d25d9ea18b4577ae76637f16adde4aff18b2562c773ee12ba1c5198a1c816e6449f6d2ea7d26
data/README.md CHANGED
@@ -11,7 +11,7 @@ Ruby wrapper for [Telegram's Bot API](https://core.telegram.org/bots/api).
11
11
  Add following line to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'telegram-bot-ruby'
14
+ gem 'telegram-bot-ruby', '~> 0.5.0.beta3'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -23,7 +23,7 @@ $ bundle
23
23
  Or install it system-wide:
24
24
 
25
25
  ```shell
26
- $ gem install telegram-bot-ruby
26
+ $ gem install telegram-bot-ruby --pre
27
27
  ```
28
28
 
29
29
  ## Usage
@@ -81,13 +81,13 @@ Furthermore, you can ask user to share location or phone number using `KeyboardB
81
81
 
82
82
  ```ruby
83
83
  bot.listen do |message|
84
- kb = [
85
- Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true),
86
- Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true)
87
- ]
88
- markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb)
89
- bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup)
90
- end
84
+ kb = [
85
+ Telegram::Bot::Types::KeyboardButton.new(text: 'Give me your phone number', request_contact: true),
86
+ Telegram::Bot::Types::KeyboardButton.new(text: 'Show me your location', request_location: true)
87
+ ]
88
+ markup = Telegram::Bot::Types::ReplyKeyboardMarkup.new(keyboard: kb)
89
+ bot.api.send_message(chat_id: message.chat.id, text: 'Hey!', reply_markup: markup)
90
+ end
91
91
  ```
92
92
 
93
93
  ## Inline keyboards
@@ -123,11 +123,16 @@ bot.listen do |message|
123
123
  case message
124
124
  when Telegram::Bot::Types::InlineQuery
125
125
  results = [
126
- Telegram::Bot::Types::InlineQueryResultArticle
127
- .new(id: 1, title: 'First article', message_text: 'Very interesting text goes here.'),
128
- Telegram::Bot::Types::InlineQueryResultArticle
129
- .new(id: 2, title: 'Second article', message_text: 'Another interesting text here.')
130
- ]
126
+ [1, 'First article', 'Very interesting text goes here.'],
127
+ [2, 'Second article', 'Another interesting text here.']
128
+ ].map do |arr|
129
+ Telegram::Bot::Types::InlineQueryResultArticle.new(
130
+ id: arr[0],
131
+ title: arr[1],
132
+ input_message_content: Telegram::Bot::Types::InputTextMessageContent.new(message_text: arr[2])
133
+ )
134
+ end
135
+
131
136
  bot.api.answer_inline_query(inline_query_id: message.id, results: results)
132
137
  when Telegram::Bot::Types::Message
133
138
  bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}!")
@@ -5,7 +5,16 @@ module Telegram
5
5
  include Virtus.model
6
6
 
7
7
  def to_compact_hash
8
- attributes.dup.delete_if { |_, v| v.nil? }
8
+ Hash[attributes.dup.delete_if { |_, v| v.nil? }.map do |key, value|
9
+ value =
10
+ if value.class.ancestors.include?(Telegram::Bot::Types::Base)
11
+ value.to_compact_hash
12
+ else
13
+ value
14
+ end
15
+
16
+ [key, value]
17
+ end]
9
18
  end
10
19
  end
11
20
  end
@@ -1,5 +1,5 @@
1
1
  module Telegram
2
2
  module Bot
3
- VERSION = '0.5.0.beta2'.freeze
3
+ VERSION = '0.5.0.beta3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegram-bot-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta2
4
+ version: 0.5.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tipugin