action_bot 0.1.18 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4fee1cf1e875eff32a689bbbba69e79e653afa4e2c11185c5bcb8eac71ec509
|
4
|
+
data.tar.gz: 1d52c3adb32c9481cd8083e74afd85a2b35d135ec7a0458c585226b793c1ac3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 525ec5f179ee015e4e738df3e05c733bb4fca4b7f35ae3ee496e6a56141d709d3c91b4b565c6c084724c76ac856b340ced04211ccc60def839c0d2acae50b287
|
7
|
+
data.tar.gz: 1286a395b3e1ca839fbc66eefe3f448862bd30d6470e2705488fbb5ec3e7daad07a5fc474238f9b25d30dd98ab4d04b4421fe853bc9412278d2ab657b0e562fc
|
data/lib/action_bot/base.rb
CHANGED
@@ -9,6 +9,7 @@ module ActionBot
|
|
9
9
|
controller, action = kwargs.first
|
10
10
|
controller_object = "#{controller.to_s.camelize}Controller".constantize.new
|
11
11
|
raise "No such method: #{action} for #{controller}" unless controller_object.respond_to?(action)
|
12
|
+
|
12
13
|
controller_object.params = ActionController::Parameters.new params
|
13
14
|
controller_object.public_send(action)
|
14
15
|
throw(:done)
|
@@ -17,12 +17,17 @@ class ExampleLongPollingBot < ActionBot::Base
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
20
|
-
|
20
|
+
return unless message_legal?
|
21
|
+
|
22
|
+
on @message.text == 'hello_world', hello: :world, params: {
|
21
23
|
tg_chat_id: tg_chat_id
|
22
24
|
}
|
23
25
|
end
|
24
26
|
|
25
27
|
private
|
28
|
+
|
29
|
+
def message_legal?
|
30
|
+
@message.respond_to?(:text) && @message.text
|
26
31
|
|
27
32
|
def tg_chat_id
|
28
33
|
@message.chat.id
|