action_bot 0.1.19 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/action_bot/base.rb +0 -3
- data/lib/action_bot/controller.rb +1 -1
- data/scaffolds/bots/example_long_polling_bot.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d066c37aafa1ccaadb7b2b94a9f9e32d1a8d3b3f26b8f1f7e2e79751f7fc97ed
|
4
|
+
data.tar.gz: 9818c87ffe443616bc2b14f1270dfe1fb35a79db27cbf5289aff5f358d97456a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebae715f8994d78860aad03cb0fc0949f0ac5c98042aa101bf9118a0bfd69b385075481f1d5bf52fe898ea0f177071d41749bc293093de4ab53048d0c046108c
|
7
|
+
data.tar.gz: 9c90ef6a5d8504a199a44d46b1d85c9f10b1e30402af692c84c5bb6d83eb1c701b45d6b201623d349d0c38e097b37d47c2ac266ff34279b78e4c68f004f7da8d
|
data/lib/action_bot/base.rb
CHANGED
@@ -3,16 +3,13 @@ module ActionBot
|
|
3
3
|
include Configurable.with(:api, :bot)
|
4
4
|
|
5
5
|
def on(condition, **kwargs)
|
6
|
-
puts "#{Time.now}: Received:- #{kwargs}"
|
7
6
|
return unless condition
|
8
7
|
|
9
8
|
params = kwargs.delete(:params) || {}
|
10
9
|
controller, action = kwargs.first
|
11
10
|
controller_object = "#{controller.to_s.camelize}Controller".constantize.new
|
12
|
-
puts "controller: #{controller.to_s.camelize}Controller, action: #{action}"
|
13
11
|
raise "No such method: #{action} for #{controller}" unless controller_object.respond_to?(action)
|
14
12
|
|
15
|
-
puts "Receiving..."
|
16
13
|
controller_object.params = ActionController::Parameters.new params
|
17
14
|
controller_object.public_send(action)
|
18
15
|
throw(:done)
|
@@ -19,7 +19,7 @@ class ExampleLongPollingBot < ActionBot::Base
|
|
19
19
|
def run
|
20
20
|
return unless message_legal?
|
21
21
|
|
22
|
-
on @message == 'hello_world', hello: :world, params: {
|
22
|
+
on @message.text == 'hello_world', hello: :world, params: {
|
23
23
|
tg_chat_id: tg_chat_id
|
24
24
|
}
|
25
25
|
end
|
@@ -28,6 +28,7 @@ class ExampleLongPollingBot < ActionBot::Base
|
|
28
28
|
|
29
29
|
def message_legal?
|
30
30
|
@message.respond_to?(:text) && @message.text
|
31
|
+
end
|
31
32
|
|
32
33
|
def tg_chat_id
|
33
34
|
@message.chat.id
|