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: f267e3093741e98e9812f5a8e43871e3fe03a0634d58972cb86dd5cc3834230b
4
- data.tar.gz: 01767005c9771cf1395453ec27ae3f7cd6525a8db0a5413668bf3322e717de97
3
+ metadata.gz: e4fee1cf1e875eff32a689bbbba69e79e653afa4e2c11185c5bcb8eac71ec509
4
+ data.tar.gz: 1d52c3adb32c9481cd8083e74afd85a2b35d135ec7a0458c585226b793c1ac3c
5
5
  SHA512:
6
- metadata.gz: 8b403d696bc7d517a88137f65ebde2c11207eadc0b38296a1b35b3f4629a87134751806c75e2421f1df6df21b26c4399fef5f40b030e4f5cfbef5d6d7d273973
7
- data.tar.gz: fc9f146bbec3739c4c7f7967a797d50722e45acefca89dc73e6763f9ccf23ceaae41b86e5f0224a071190e32eb3f5d8fd04316f1af2ee0b7354214ed11429872
6
+ metadata.gz: 525ec5f179ee015e4e738df3e05c733bb4fca4b7f35ae3ee496e6a56141d709d3c91b4b565c6c084724c76ac856b340ced04211ccc60def839c0d2acae50b287
7
+ data.tar.gz: 1286a395b3e1ca839fbc66eefe3f448862bd30d6470e2705488fbb5ec3e7daad07a5fc474238f9b25d30dd98ab4d04b4421fe853bc9412278d2ab657b0e562fc
@@ -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)
@@ -16,7 +16,7 @@ module ActionBot
16
16
  end
17
17
 
18
18
  def t(*args)
19
- I18n.locale = load_chat.locale
19
+ I18n.locale = load_chat.locale if respond_to?(:load_chat)
20
20
  I18n.t(*args)
21
21
  end
22
22
 
@@ -17,12 +17,17 @@ class ExampleLongPollingBot < ActionBot::Base
17
17
  end
18
18
 
19
19
  def run
20
- on @message == 'hello_world', hello: :world, params: {
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
@@ -1,4 +1,4 @@
1
- class HelloController
1
+ class HelloController < BotsController
2
2
  def world
3
3
  notify(params[:tg_chat_id], t('hello_world'))
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Barseek