kanal-interfaces-telegram 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +22 -27
- data/lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb +10 -1
- data/lib/kanal/interfaces/telegram/telegram_interface.rb +32 -1
- data/lib/kanal/interfaces/telegram/version.rb +1 -1
- metadata +1 -2
- data/pep.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0443fcd3d0798e1f0d9765f25790852ec5f99635b88d78dd51b30a4c1491166
|
4
|
+
data.tar.gz: a0c4f6a617e075a62e2d2a15802d25267eb297b0cf85991c4ffd7c2908a470bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 541a8cdc495e3def560db1209f9a0274b476b528d2887d1686de7557dae3d8e3cb24447ddedb763b0a11d64baf040d02cb888c4d01037a3df54e2c3714501c07
|
7
|
+
data.tar.gz: a6d4e89bda323eff32315cbc0acaf47e6bdd5f87c685c2e7a499f5f955d44b905373e477ec0a6e02e4464015adea1b59154966436fc14f77c4b4603411f5c1a8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.0] - 2023-01-30
|
4
|
+
|
5
|
+
- Library now can send images via .tg_image_path
|
6
|
+
- Populating separate field in input
|
7
|
+
- Using output.tg_chat_id and not the one inside interface, this is preparations for future sending outputs in separate methods... Probably
|
8
|
+
|
3
9
|
## [0.1.0] - 2022-11-21
|
4
10
|
|
5
11
|
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git@github.com:idchlife/kanal.git
|
3
|
-
revision: 5dbc20a3480337192d1193b0e569dba9d665d4c9
|
4
|
-
specs:
|
5
|
-
kanal (0.3.0)
|
6
|
-
|
7
1
|
PATH
|
8
2
|
remote: .
|
9
3
|
specs:
|
10
|
-
kanal-interfaces-telegram (0.
|
4
|
+
kanal-interfaces-telegram (0.2.0)
|
11
5
|
telegram-bot-ruby
|
12
6
|
|
13
7
|
GEM
|
@@ -19,7 +13,7 @@ GEM
|
|
19
13
|
ice_nine (~> 0.11.0)
|
20
14
|
thread_safe (~> 0.3, >= 0.3.1)
|
21
15
|
backport (1.2.0)
|
22
|
-
benchmark (0.2.
|
16
|
+
benchmark (0.2.1)
|
23
17
|
coercible (1.0.0)
|
24
18
|
descendants_tracker (~> 0.0.1)
|
25
19
|
descendants_tracker (0.0.4)
|
@@ -28,7 +22,7 @@ GEM
|
|
28
22
|
docile (1.4.0)
|
29
23
|
dry-inflector (1.0.0)
|
30
24
|
e2mmap (0.1.0)
|
31
|
-
faraday (2.7.
|
25
|
+
faraday (2.7.4)
|
32
26
|
faraday-net_http (>= 2.0, < 3.1)
|
33
27
|
ruby2_keywords (>= 0.0.4)
|
34
28
|
faraday-multipart (1.0.4)
|
@@ -36,21 +30,22 @@ GEM
|
|
36
30
|
faraday-net_http (3.0.2)
|
37
31
|
ice_nine (0.11.2)
|
38
32
|
jaro_winkler (1.5.4)
|
39
|
-
json (2.6.
|
33
|
+
json (2.6.3)
|
34
|
+
kanal (0.3.0)
|
40
35
|
kramdown (2.4.0)
|
41
36
|
rexml
|
42
37
|
kramdown-parser-gfm (1.1.0)
|
43
38
|
kramdown (~> 2.0)
|
44
|
-
multipart-post (2.
|
45
|
-
nokogiri (1.
|
39
|
+
multipart-post (2.3.0)
|
40
|
+
nokogiri (1.14.0-x86_64-darwin)
|
46
41
|
racc (~> 1.4)
|
47
42
|
parallel (1.22.1)
|
48
|
-
parser (3.
|
43
|
+
parser (3.2.0.0)
|
49
44
|
ast (~> 2.4.1)
|
50
|
-
racc (1.6.
|
45
|
+
racc (1.6.2)
|
51
46
|
rainbow (3.1.1)
|
52
47
|
rake (13.0.6)
|
53
|
-
regexp_parser (2.6.
|
48
|
+
regexp_parser (2.6.2)
|
54
49
|
reverse_markdown (2.1.1)
|
55
50
|
nokogiri
|
56
51
|
rexml (3.2.5)
|
@@ -60,36 +55,36 @@ GEM
|
|
60
55
|
rspec-mocks (~> 3.12.0)
|
61
56
|
rspec-core (3.12.0)
|
62
57
|
rspec-support (~> 3.12.0)
|
63
|
-
rspec-expectations (3.12.
|
58
|
+
rspec-expectations (3.12.2)
|
64
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
60
|
rspec-support (~> 3.12.0)
|
66
|
-
rspec-mocks (3.12.
|
61
|
+
rspec-mocks (3.12.3)
|
67
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
63
|
rspec-support (~> 3.12.0)
|
69
64
|
rspec-support (3.12.0)
|
70
|
-
rubocop (1.
|
65
|
+
rubocop (1.44.1)
|
71
66
|
json (~> 2.3)
|
72
67
|
parallel (~> 1.10)
|
73
|
-
parser (>= 3.
|
68
|
+
parser (>= 3.2.0.0)
|
74
69
|
rainbow (>= 2.2.2, < 4.0)
|
75
70
|
regexp_parser (>= 1.8, < 3.0)
|
76
71
|
rexml (>= 3.2.5, < 4.0)
|
77
|
-
rubocop-ast (>= 1.
|
72
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
78
73
|
ruby-progressbar (~> 1.7)
|
79
|
-
unicode-display_width (>=
|
80
|
-
rubocop-ast (1.24.
|
74
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
75
|
+
rubocop-ast (1.24.1)
|
81
76
|
parser (>= 3.1.1.0)
|
82
77
|
ruby-debug-ide (0.7.3)
|
83
78
|
rake (>= 0.8.1)
|
84
79
|
ruby-progressbar (1.11.0)
|
85
80
|
ruby2_keywords (0.0.5)
|
86
|
-
simplecov (0.
|
81
|
+
simplecov (0.22.0)
|
87
82
|
docile (~> 1.1)
|
88
83
|
simplecov-html (~> 0.11)
|
89
84
|
simplecov_json_formatter (~> 0.1)
|
90
85
|
simplecov-html (0.12.3)
|
91
86
|
simplecov_json_formatter (0.1.4)
|
92
|
-
solargraph (0.
|
87
|
+
solargraph (0.48.0)
|
93
88
|
backport (~> 1.2)
|
94
89
|
benchmark
|
95
90
|
bundler (>= 1.17.2)
|
@@ -104,7 +99,7 @@ GEM
|
|
104
99
|
thor (~> 1.0)
|
105
100
|
tilt (~> 2.0)
|
106
101
|
yard (~> 0.9, >= 0.9.24)
|
107
|
-
telegram-bot-ruby (0.
|
102
|
+
telegram-bot-ruby (0.23.0)
|
108
103
|
dry-inflector
|
109
104
|
faraday (~> 2.0)
|
110
105
|
faraday-multipart (~> 1.0)
|
@@ -112,7 +107,7 @@ GEM
|
|
112
107
|
thor (1.2.1)
|
113
108
|
thread_safe (0.3.6)
|
114
109
|
tilt (2.0.11)
|
115
|
-
unicode-display_width (2.
|
110
|
+
unicode-display_width (2.4.2)
|
116
111
|
virtus (2.0.0)
|
117
112
|
axiom-types (~> 0.1)
|
118
113
|
coercible (~> 1.0)
|
@@ -125,7 +120,7 @@ PLATFORMS
|
|
125
120
|
x86_64-darwin-21
|
126
121
|
|
127
122
|
DEPENDENCIES
|
128
|
-
kanal
|
123
|
+
kanal
|
129
124
|
kanal-interfaces-telegram!
|
130
125
|
rake (~> 13.0)
|
131
126
|
rspec (~> 3.0)
|
@@ -17,8 +17,16 @@ module Kanal
|
|
17
17
|
|
18
18
|
def register_parameters(core)
|
19
19
|
core.register_input_parameter :tg_message, readonly: true
|
20
|
+
core.register_input_parameter :tg_text, readonly: true
|
21
|
+
core.register_input_parameter :tg_chat_id, readonly: true
|
22
|
+
core.register_input_parameter :tg_username, readonly: true
|
23
|
+
|
24
|
+
core.register_output_parameter :tg_chat_id
|
20
25
|
core.register_output_parameter :tg_text
|
21
26
|
core.register_output_parameter :tg_reply_markup
|
27
|
+
core.register_output_parameter :tg_image_path
|
28
|
+
core.register_output_parameter :tg_audio_path
|
29
|
+
core.register_output_parameter :tg_document_path
|
22
30
|
end
|
23
31
|
|
24
32
|
def register_hooks(core)
|
@@ -27,11 +35,12 @@ module Kanal
|
|
27
35
|
end
|
28
36
|
|
29
37
|
core.hooks.attach :input_before_router do |input|
|
30
|
-
input.body = input.
|
38
|
+
input.body = input.tg_text
|
31
39
|
end
|
32
40
|
|
33
41
|
core.hooks.attach :output_before_returned do |input, output|
|
34
42
|
output.tg_text = output.body
|
43
|
+
output.tg_chat_id = input.tg_chat_id
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
@@ -26,17 +26,48 @@ module Kanal
|
|
26
26
|
input = @core.create_input
|
27
27
|
|
28
28
|
input.tg_message = message
|
29
|
+
input.tg_text = message.text
|
30
|
+
input.tg_chat_id = message.chat.id
|
31
|
+
input.tg_username = message.try(:chat).try(:username) || input.tg_message.try(:from).try(:username)
|
29
32
|
|
30
33
|
output = router.create_output_for_input input
|
31
34
|
|
32
35
|
bot.api.send_message(
|
33
|
-
chat_id:
|
36
|
+
chat_id: output.tg_chat_id,
|
34
37
|
text: output.tg_text,
|
35
38
|
reply_markup: output.tg_reply_markup
|
36
39
|
)
|
40
|
+
|
41
|
+
image_path = output.tg_image_path
|
42
|
+
|
43
|
+
if image_path && File.exist?(image_path)
|
44
|
+
bot.api.send_photo(
|
45
|
+
chat_id: message.chat.id,
|
46
|
+
photo: Faraday::UploadIO.new(image_path, guess_mimetype(image_path))
|
47
|
+
)
|
48
|
+
end
|
37
49
|
end
|
38
50
|
end
|
39
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def guess_mimetype(filename)
|
56
|
+
images = {
|
57
|
+
"image/jpeg" => %w[jpg jpeg],
|
58
|
+
"image/png" => ["png"],
|
59
|
+
"image/bmp" => ["bmp"]
|
60
|
+
}
|
61
|
+
|
62
|
+
# TODO: rewrite with .find or .each
|
63
|
+
for mime, types in [images] do
|
64
|
+
for type in types do
|
65
|
+
return mime if filename.include? type
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
"application/octet-stream"
|
70
|
+
end
|
40
71
|
end
|
41
72
|
end
|
42
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanal-interfaces-telegram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- idchlife
|
@@ -47,7 +47,6 @@ files:
|
|
47
47
|
- lib/kanal/interfaces/telegram/plugins/telegram_integration_plugin.rb
|
48
48
|
- lib/kanal/interfaces/telegram/telegram_interface.rb
|
49
49
|
- lib/kanal/interfaces/telegram/version.rb
|
50
|
-
- pep.rb
|
51
50
|
- sig/kanal/interfaces/telegram.rbs
|
52
51
|
homepage: https://github.com/idchlife/kanal-interfaces-telegram
|
53
52
|
licenses:
|