telegram-bot-ruby 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/lib/telegram/bot.rb +0 -1
- data/lib/telegram/bot/api.rb +6 -38
- data/lib/telegram/bot/types.rb +1 -0
- data/lib/telegram/bot/types/base.rb +1 -0
- data/lib/telegram/bot/types/chat.rb +1 -0
- data/lib/telegram/bot/types/compactable.rb +5 -1
- data/lib/telegram/bot/types/pattern_matching.rb +11 -0
- data/lib/telegram/bot/version.rb +1 -1
- data/telegram-bot-ruby.gemspec +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6227a7eff23e7037a7e07e021a4f2925681c952a449b99a38cd5c23b3f331c5c
|
4
|
+
data.tar.gz: a1bc35c582ff1ba5fe4627613e6c71454be8c11877a5a1fdca7ca300a1a1fead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ff75cc41a8fcfa5558a28cedb8e9f3b4be72e40fca71a4f8a9a1493bcd67850c6598e84882b2db7edee2c46202b72756d1612f477909fc1097211d7a95f1da
|
7
|
+
data.tar.gz: fb29319e282a3b851689503657f1877511555b10be4135bc9c99ad192093c3ea7f96e352a32bb2cb50bedc5dd206944f2604d135b15a9375a678186c244c385b
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/telegram/bot.rb
CHANGED
data/lib/telegram/bot/api.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Telegram
|
2
2
|
module Bot
|
3
|
-
class Api
|
3
|
+
class Api
|
4
4
|
ENDPOINTS = %w[
|
5
5
|
getUpdates setWebhook deleteWebhook getWebhookInfo getMe sendMessage
|
6
6
|
forwardMessage sendPhoto sendAudio sendDocument sendVideo sendVoice
|
@@ -22,34 +22,6 @@ module Telegram
|
|
22
22
|
setStickerSetThumb logOut close copyMessage createChatInviteLink
|
23
23
|
editChatInviteLink revokeChatInviteLink
|
24
24
|
].freeze
|
25
|
-
REPLY_MARKUP_TYPES = [
|
26
|
-
Telegram::Bot::Types::ReplyKeyboardMarkup,
|
27
|
-
Telegram::Bot::Types::ReplyKeyboardRemove,
|
28
|
-
Telegram::Bot::Types::ForceReply,
|
29
|
-
Telegram::Bot::Types::InlineKeyboardMarkup
|
30
|
-
].freeze
|
31
|
-
INLINE_QUERY_RESULT_TYPES = [
|
32
|
-
Telegram::Bot::Types::InlineQueryResultArticle,
|
33
|
-
Telegram::Bot::Types::InlineQueryResultPhoto,
|
34
|
-
Telegram::Bot::Types::InlineQueryResultGif,
|
35
|
-
Telegram::Bot::Types::InlineQueryResultMpeg4Gif,
|
36
|
-
Telegram::Bot::Types::InlineQueryResultVideo,
|
37
|
-
Telegram::Bot::Types::InlineQueryResultAudio,
|
38
|
-
Telegram::Bot::Types::InlineQueryResultVoice,
|
39
|
-
Telegram::Bot::Types::InlineQueryResultDocument,
|
40
|
-
Telegram::Bot::Types::InlineQueryResultLocation,
|
41
|
-
Telegram::Bot::Types::InlineQueryResultVenue,
|
42
|
-
Telegram::Bot::Types::InlineQueryResultContact,
|
43
|
-
Telegram::Bot::Types::InlineQueryResultGame,
|
44
|
-
Telegram::Bot::Types::InlineQueryResultCachedPhoto,
|
45
|
-
Telegram::Bot::Types::InlineQueryResultCachedGif,
|
46
|
-
Telegram::Bot::Types::InlineQueryResultCachedMpeg4Gif,
|
47
|
-
Telegram::Bot::Types::InlineQueryResultCachedSticker,
|
48
|
-
Telegram::Bot::Types::InlineQueryResultCachedDocument,
|
49
|
-
Telegram::Bot::Types::InlineQueryResultCachedVideo,
|
50
|
-
Telegram::Bot::Types::InlineQueryResultCachedVoice,
|
51
|
-
Telegram::Bot::Types::InlineQueryResultCachedAudio
|
52
|
-
].freeze
|
53
25
|
|
54
26
|
attr_reader :token, :url
|
55
27
|
|
@@ -92,19 +64,15 @@ module Telegram
|
|
92
64
|
end
|
93
65
|
|
94
66
|
def sanitize_value(value)
|
95
|
-
|
67
|
+
jsonify_value(value)
|
96
68
|
end
|
97
69
|
|
98
|
-
def
|
99
|
-
|
100
|
-
value.to_compact_hash.to_json
|
70
|
+
def jsonify_value(value)
|
71
|
+
jsonify_value?(value) ? value.to_json : value
|
101
72
|
end
|
102
73
|
|
103
|
-
def
|
104
|
-
|
105
|
-
value.is_a?(Array) &&
|
106
|
-
value.all? { |i| INLINE_QUERY_RESULT_TYPES.any? { |t| i.is_a?(t) } }
|
107
|
-
value.map { |i| i.to_compact_hash.select { |_, v| v } }.to_json
|
74
|
+
def jsonify_value?(value)
|
75
|
+
value.respond_to?(:to_compact_hash) || value.is_a?(Array)
|
108
76
|
end
|
109
77
|
|
110
78
|
def camelize(method_name)
|
data/lib/telegram/bot/types.rb
CHANGED
@@ -5,7 +5,7 @@ module Telegram
|
|
5
5
|
def to_compact_hash
|
6
6
|
Hash[attributes.dup.delete_if { |_, v| v.nil? }.map do |key, value|
|
7
7
|
value =
|
8
|
-
if value.
|
8
|
+
if value.respond_to?(:to_compact_hash)
|
9
9
|
value.to_compact_hash
|
10
10
|
else
|
11
11
|
value
|
@@ -14,6 +14,10 @@ module Telegram
|
|
14
14
|
[key, value]
|
15
15
|
end]
|
16
16
|
end
|
17
|
+
|
18
|
+
def to_json(*args)
|
19
|
+
to_compact_hash.select { |_, v| v }.to_json(*args)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/telegram/bot/version.rb
CHANGED
data/telegram-bot-ruby.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_dependency 'faraday'
|
21
|
-
spec.add_dependency 'virtus'
|
22
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'virtus', '~> 2.0'
|
22
|
+
spec.add_dependency 'dry-inflector'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'rake', '~> 13.0'
|
25
25
|
spec.add_development_dependency 'pry'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram-bot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Tipugin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -28,18 +28,18 @@ dependencies:
|
|
28
28
|
name: virtus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: dry-inflector
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/telegram/bot/types/passport_element_error_translation_files.rb
|
229
229
|
- lib/telegram/bot/types/passport_element_error_unspecified.rb
|
230
230
|
- lib/telegram/bot/types/passport_file.rb
|
231
|
+
- lib/telegram/bot/types/pattern_matching.rb
|
231
232
|
- lib/telegram/bot/types/photo_size.rb
|
232
233
|
- lib/telegram/bot/types/poll.rb
|
233
234
|
- lib/telegram/bot/types/poll_answer.rb
|
@@ -273,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
274
|
- !ruby/object:Gem::Version
|
274
275
|
version: '0'
|
275
276
|
requirements: []
|
276
|
-
rubygems_version: 3.2.
|
277
|
+
rubygems_version: 3.2.15
|
277
278
|
signing_key:
|
278
279
|
specification_version: 4
|
279
280
|
summary: Ruby wrapper for Telegram's Bot API
|