action_bot 0.1.19 → 0.1.23

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802cec2057aa409c4b36ec18635cda38a33bce66bcbfeba7fd3d6cb4f4f4a992
4
- data.tar.gz: d78cffe09c272f262700ee7c21fd6dd9708584cebd7d375a5528fed166928a7a
3
+ metadata.gz: d066c37aafa1ccaadb7b2b94a9f9e32d1a8d3b3f26b8f1f7e2e79751f7fc97ed
4
+ data.tar.gz: 9818c87ffe443616bc2b14f1270dfe1fb35a79db27cbf5289aff5f358d97456a
5
5
  SHA512:
6
- metadata.gz: 0e6155339bfee95e3f73d282498d2089c975c8f0c444f572848645620bb48b39bdda40dff0cda32cfa68bdb5b6d8aead3a5f7260b26f9f1e6bdd37b9f62c34dc
7
- data.tar.gz: a50600a07b806be3ff5c86ff64cf8edb412d9734466cffd46eef44c48178eeb5290aaa31d06f97278d0c578380390facdc9b2a84fa53bd9ded2c91ae81d4586e
6
+ metadata.gz: ebae715f8994d78860aad03cb0fc0949f0ac5c98042aa101bf9118a0bfd69b385075481f1d5bf52fe898ea0f177071d41749bc293093de4ab53048d0c046108c
7
+ data.tar.gz: 9c90ef6a5d8504a199a44d46b1d85c9f10b1e30402af692c84c5bb6d83eb1c701b45d6b201623d349d0c38e097b37d47c2ac266ff34279b78e4c68f004f7da8d
@@ -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)
@@ -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
 
@@ -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
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.19
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Barseek