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 +4 -4
- data/README.md +19 -14
- data/lib/telegram/bot/types/base.rb +10 -1
- data/lib/telegram/bot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7298e9dd9e093d7de1356822438209c04d1bfdff
|
4
|
+
data.tar.gz: 753d71fec2e945d3b3d7b415770f27e512940aae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
data/lib/telegram/bot/version.rb
CHANGED