telegram-bot 0.15.6 → 0.15.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/telegram/bot/client/request_body_formatter.rb +21 -8
- data/lib/telegram/bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2a7c11af116803bbd1e7538a63541064137f750f9ebde05afb172a52520aa69
|
4
|
+
data.tar.gz: ce49c1049a55d229e8ffcc502bf77f49a558c30941a3a0a474e7f756d0b06c68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5820f8eda88f3a61102bb39cf394f7dbbed8f2c9f2336de8d2eee8fc26370f997e7ab67d244404ff5e64042ba72ee03c9418837318efb5b5fd0ef2630a606b3
|
7
|
+
data.tar.gz: d4aa425592ca34e7291406948fc35d07f5cb33b78a9be09fd7ebed2b03b4ec9d583aef9cc002ee4a56f4a7b5fe6eea2b4403700c76d9abdf04be5623ff5501af
|
data/CHANGELOG.md
CHANGED
@@ -11,8 +11,14 @@ module Telegram
|
|
11
11
|
|
12
12
|
def format(body, action)
|
13
13
|
body = body.dup
|
14
|
-
|
15
|
-
|
14
|
+
case action.to_s
|
15
|
+
when 'sendMediaGroup'
|
16
|
+
extract_files_from_array!(body, :media)
|
17
|
+
when 'editMessageMedia'
|
18
|
+
replace_field(body, :media) do |value|
|
19
|
+
files = {}
|
20
|
+
extract_files_from_hash(value, files).tap { body.merge!(files) }
|
21
|
+
end
|
16
22
|
end
|
17
23
|
body.each do |key, val|
|
18
24
|
body[key] = val.to_json if val.is_a?(Hash) || val.is_a?(Array)
|
@@ -21,12 +27,19 @@ module Telegram
|
|
21
27
|
|
22
28
|
private
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
# Detects field by symbol or string name and replaces it with mapped value.
|
31
|
+
def replace_field(hash, field_name)
|
32
|
+
field_name = [field_name.to_sym, field_name.to_s].find { |x| hash.key?(x) }
|
33
|
+
hash[field_name] = yield hash[field_name] if field_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def extract_files_from_array!(hash, field_name)
|
37
|
+
replace_field(hash, field_name) do |value|
|
38
|
+
break value unless value.is_a?(Array)
|
39
|
+
files = {}
|
40
|
+
value.map { |x| extract_files_from_hash(x, files) }.
|
41
|
+
tap { hash.merge!(files) }
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
# Replace File objects with `attach` URIs. File objects are added into `files` hash.
|
data/lib/telegram/bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Melentiev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|