kanal 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/kanal/core/helpers/parameter_finder_with_method_missing_mixin.rb +16 -4
- data/lib/kanal/plugins/batteries/attachments/attachment.rb +9 -60
- data/lib/kanal/plugins/batteries/batteries_plugin.rb +108 -2
- data/lib/kanal/version.rb +1 -1
- data/lib/kanal.rb +1 -0
- data/lib/shortcuts.rb +9 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a793b05b3b6a5848b173907c41e64b0fd40c1a68b7b992c784923dbd34c1df
|
4
|
+
data.tar.gz: 01cab2e1b68b1c0d7559208a47883caccfd7a7c1019f4e740c12bdb28129e329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca772528cfca7d06de8f48c2a3da90fc99615d1ad06b2dd0b6d6254e68e989937fb22b884aef9219a3a9d139dc2dc7a8d8e786e999dd52e81209739fc6d2d28
|
7
|
+
data.tar.gz: 7d8c3a80d26ceb6245154b694cafc8ca08fd742468cbf3fb6c332a3f064eee84ec20539a973d77494483f2a716d768a0c25fd80d06d9afba27d6d529f1d87882
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.3] 2023-03-30
|
4
|
+
- New condition for button pressed
|
5
|
+
- Input property button_pressed
|
6
|
+
|
3
7
|
## [0.4.2] 2023-03-22
|
4
8
|
- Adding any number of loggers can be now done with core.add_logger(l) - where l is logger that have same methods as default ruby logger (debug, warn, fatal, etc)
|
5
9
|
- To get logger into your class you can include Kanal::Core::Logging::Logger - this will give you method .logger to get logger
|
data/Gemfile.lock
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "../logging/composite_logger"
|
4
|
+
|
3
5
|
module Kanal
|
4
6
|
module Core
|
5
7
|
module Helpers
|
@@ -8,22 +10,32 @@ module Kanal
|
|
8
10
|
# get(name)
|
9
11
|
# transforms unknown methods to setters/getters for parameters
|
10
12
|
module ParameterFinderWithMethodMissingMixin
|
11
|
-
|
13
|
+
include Logging::Logger
|
14
|
+
|
15
|
+
def method_missing(symbol, *args, &block)
|
16
|
+
if block && !args.first.nil?
|
17
|
+
logger.error "Block and arg given simultaneously. Parameter name: '#{symbol.to_s}, arg: #{args.first}'"
|
18
|
+
|
19
|
+
raise "Block and arg given simultaneously for parameter #{symbol.to_s}"
|
20
|
+
end
|
21
|
+
|
12
22
|
parameter_name = symbol.to_s
|
13
23
|
parameter_name.sub! "=", ""
|
14
24
|
|
15
25
|
parameter_name = parameter_name.to_sym
|
16
26
|
|
27
|
+
value = block_given? ? block : args.first
|
28
|
+
|
17
29
|
# standard workflow with settings properties with
|
18
30
|
# input.prop = 123
|
19
31
|
if symbol.to_s.include? "="
|
20
|
-
@parameter_bag.set parameter_name,
|
21
|
-
elsif !args.empty?
|
32
|
+
@parameter_bag.set parameter_name, value
|
33
|
+
elsif !args.empty? || block_given?
|
22
34
|
# this approach can be used also in dsl
|
23
35
|
# like that
|
24
36
|
# setters: prop value
|
25
37
|
# getters: prop
|
26
|
-
@parameter_bag.set parameter_name,
|
38
|
+
@parameter_bag.set parameter_name, value
|
27
39
|
# means it is used as setter in dsl,
|
28
40
|
# method call with argument
|
29
41
|
else
|
@@ -15,76 +15,25 @@ module Kanal
|
|
15
15
|
@url = url
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def mp3?
|
23
|
-
extension == "mp3"
|
24
|
-
end
|
25
|
-
|
26
|
-
def wav?
|
27
|
-
extension == "wav"
|
28
|
-
end
|
29
|
-
|
30
|
-
def ogg?
|
31
|
-
extension == "ogg"
|
32
|
-
end
|
33
|
-
|
34
|
-
def document?
|
35
|
-
doc? || docx? || odf?
|
36
|
-
end
|
37
|
-
|
38
|
-
def doc?
|
39
|
-
extension == "doc"
|
40
|
-
end
|
41
|
-
|
42
|
-
def docx?
|
43
|
-
extension == "docx"
|
44
|
-
end
|
45
|
-
|
46
|
-
def odf?
|
47
|
-
extension == "odf"
|
18
|
+
# Extension checks like jpg?, mp3?, mp4?, doc? etc. fall here
|
19
|
+
def method_missing(method)
|
20
|
+
extension == method.to_s.delete("?")
|
48
21
|
end
|
49
22
|
|
50
23
|
def image?
|
51
|
-
jpg
|
52
|
-
end
|
53
|
-
|
54
|
-
def jpg?
|
55
|
-
extension == "jpg"
|
56
|
-
end
|
57
|
-
|
58
|
-
def jpeg?
|
59
|
-
extension == "jpeg"
|
60
|
-
end
|
61
|
-
|
62
|
-
def png?
|
63
|
-
extension == "png"
|
24
|
+
[jpg?, jpeg?, png?, bmp?, gif?].any?
|
64
25
|
end
|
65
26
|
|
66
|
-
def
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
def gif?
|
71
|
-
extension == "gif"
|
27
|
+
def audio?
|
28
|
+
[mp3?, wav?, ogg?].any?
|
72
29
|
end
|
73
30
|
|
74
31
|
def video?
|
75
|
-
mp4
|
76
|
-
end
|
77
|
-
|
78
|
-
def mp4?
|
79
|
-
extension == "mp4"
|
32
|
+
[mp4?, mov?, mkv?].any?
|
80
33
|
end
|
81
34
|
|
82
|
-
def
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
def mkv?
|
87
|
-
extension == "mkv"
|
35
|
+
def document?
|
36
|
+
[doc?, docx?, odf?].any?
|
88
37
|
end
|
89
38
|
|
90
39
|
#
|
@@ -9,6 +9,8 @@ module Kanal
|
|
9
9
|
module Batteries
|
10
10
|
# Plugin with some batteries like .body property etc
|
11
11
|
class BatteriesPlugin < Core::Plugins::Plugin
|
12
|
+
|
13
|
+
|
12
14
|
def name
|
13
15
|
:batteries
|
14
16
|
end
|
@@ -19,6 +21,8 @@ module Kanal
|
|
19
21
|
flow_batteries core
|
20
22
|
attachments_batteries core
|
21
23
|
keyboard_batteries core
|
24
|
+
username_batteries core
|
25
|
+
button_batteries core
|
22
26
|
end
|
23
27
|
|
24
28
|
def flow_batteries(core)
|
@@ -117,11 +121,95 @@ module Kanal
|
|
117
121
|
def attachments_batteries(core)
|
118
122
|
core.register_input_parameter :image
|
119
123
|
core.register_input_parameter :audio
|
120
|
-
core.register_input_parameter :
|
124
|
+
core.register_input_parameter :video
|
125
|
+
core.register_input_parameter :document
|
121
126
|
|
122
127
|
core.register_output_parameter :image
|
123
128
|
core.register_output_parameter :audio
|
124
|
-
core.register_output_parameter :
|
129
|
+
core.register_output_parameter :video
|
130
|
+
core.register_output_parameter :document
|
131
|
+
|
132
|
+
_this = self
|
133
|
+
|
134
|
+
core.add_condition_pack :image do
|
135
|
+
add_condition :exists do
|
136
|
+
met? do |input, _core, _argument|
|
137
|
+
!input.image.nil?
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
add_condition :is do
|
142
|
+
with_argument
|
143
|
+
|
144
|
+
met? do |input, _, argument|
|
145
|
+
if input.image.image? && input.image.send((argument.to_s + "?").to_sym)
|
146
|
+
true
|
147
|
+
else
|
148
|
+
false
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
core.add_condition_pack :audio do
|
155
|
+
add_condition :exists do
|
156
|
+
met? do |input, _core, _argument|
|
157
|
+
!input.audio.nil?
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
add_condition :is do
|
162
|
+
with_argument
|
163
|
+
|
164
|
+
met? do |input, _, argument|
|
165
|
+
if input.audio.audio? && input.audio.send((argument.to_s + "?").to_sym)
|
166
|
+
true
|
167
|
+
else
|
168
|
+
false
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
core.add_condition_pack :video do
|
175
|
+
add_condition :exists do
|
176
|
+
met? do |input, _core, _argument|
|
177
|
+
!input.video.nil?
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
add_condition :is do
|
182
|
+
with_argument
|
183
|
+
|
184
|
+
met? do |input, _, argument|
|
185
|
+
if input.video.video? && input.video.send((argument.to_s + "?").to_sym)
|
186
|
+
true
|
187
|
+
else
|
188
|
+
false
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
core.add_condition_pack :document do
|
195
|
+
add_condition :exists do
|
196
|
+
met? do |input, _core, _argument|
|
197
|
+
!input.document.nil?
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
add_condition :is do
|
202
|
+
with_argument
|
203
|
+
|
204
|
+
met? do |input, _, argument|
|
205
|
+
if input.document.document? && input.document.send((argument.to_s + "?").to_sym)
|
206
|
+
true
|
207
|
+
else
|
208
|
+
false
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
125
213
|
end
|
126
214
|
|
127
215
|
def keyboard_batteries(core)
|
@@ -131,6 +219,24 @@ module Kanal
|
|
131
219
|
output.keyboard = Keyboard.new
|
132
220
|
end
|
133
221
|
end
|
222
|
+
|
223
|
+
def username_batteries(core)
|
224
|
+
core.register_input_parameter :username
|
225
|
+
end
|
226
|
+
|
227
|
+
def button_batteries(core)
|
228
|
+
core.register_input_parameter :button_pressed
|
229
|
+
|
230
|
+
core.add_condition_pack :button do
|
231
|
+
add_condition :pressed do
|
232
|
+
with_argument
|
233
|
+
|
234
|
+
met? do |input, _, argument|
|
235
|
+
input.button_pressed == argument
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
134
240
|
end
|
135
241
|
end
|
136
242
|
end
|
data/lib/kanal/version.rb
CHANGED
data/lib/kanal.rb
CHANGED
data/lib/shortcuts.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- idchlife
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Thanks to the core library, ecosystem of Kanal tools can be extendted
|
14
14
|
to use with input-output bot-like behaviour, with routing
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/kanal/plugins/batteries/batteries_plugin.rb
|
64
64
|
- lib/kanal/plugins/batteries/keyboard.rb
|
65
65
|
- lib/kanal/version.rb
|
66
|
+
- lib/shortcuts.rb
|
66
67
|
- sig/kanal.rbs
|
67
68
|
- sig/kanal/core/conditions/condition_pack.rbs
|
68
69
|
- sig/kanal/core/conditions/condition_storage.rbs
|