stealth 0.9.1 → 0.9.2

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
  SHA1:
3
- metadata.gz: 332b23102210b0b6af8adc0cb6be1c75691b75c8
4
- data.tar.gz: b9b7c50fb2079e58f4de2f5d22ca3303f1a3fc1f
3
+ metadata.gz: 7afe514bbdd62d9e4da0b6c5307986c04d885cc6
4
+ data.tar.gz: f3f79181dfa0dfd103466f02b39f220e0eeab107
5
5
  SHA512:
6
- metadata.gz: 918dcf4f5bd781979b3f805625e75c829071523a15c1264e48e7b96aecc221cc3fb6ed3dfc182b079ecdb21b7ef667f8ebbae1fe8ee92ca32c128ba5b49e3abc
7
- data.tar.gz: 8d2fdb480e79890dd88bc8b77f25459dd9bf1a65b53b2099c579c5b506b55d21abd6da30ee74092c6d9241ab458848430b3474c918395896d9a154ab8b8cf005
6
+ metadata.gz: 4635e842cafd7f888e1f3c90588231ac9ec938a6a7d58bc88a61aa10a55396103175715c302d32ee160d1eabb7deb31b6bdcaec63eee03d452f1542e623be126
7
+ data.tar.gz: 78455052bce5e7cd23a19058f4c56eef60e7349653170e25342dd3dca512a83f8bc686b31e6743472a3c3d30b2698ba6a6ea1301f9c72f6017130abe4cc2f9b4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
data/lib/stealth/base.rb CHANGED
@@ -15,6 +15,7 @@ require 'stealth/jobs'
15
15
  require 'stealth/dispatcher'
16
16
  require 'stealth/server'
17
17
  require 'stealth/reply'
18
+ require 'stealth/scheduled_reply'
18
19
  require 'stealth/service_reply'
19
20
  require 'stealth/service_message'
20
21
  require 'stealth/session'
@@ -80,6 +80,16 @@ module Stealth
80
80
  end
81
81
  end
82
82
 
83
+ def step_to_in(delay, session: nil, flow: nil, state: nil)
84
+ flow, state = get_flow_and_state(session: session, flow: flow, state: state)
85
+
86
+ unless delay.is_a?(ActiveSupport::Duration)
87
+ raise ArgumentError, "Please specify your schedule_step_to `in` parameter using ActiveSupport::Duration, e.g. `1.day` or `5.hours`"
88
+ end
89
+
90
+ Stealth::ScheduledReplyJob.perform_in(delay, current_service, current_user_id, flow, state)
91
+ end
92
+
83
93
  def step_to(session: nil, flow: nil, state: nil)
84
94
  flow, state = get_flow_and_state(session: session, flow: flow, state: state)
85
95
  step(flow: flow, state: state)
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ module Stealth
5
+
6
+ class ScheduledReplyJob < Stealth::Jobs
7
+ sidekiq_options queue: :webhooks, retry: false
8
+
9
+ def perform(service, user_id, flow, state)
10
+ service_message = ServiceMessage.new(service: service)
11
+ service_message.sender_id = user_id
12
+ controller = BotController.new(service_message: service_message)
13
+ controller.update_session_to(flow: flow, state: state)
14
+ controller.route
15
+ end
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stealth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Gomes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -185,6 +185,7 @@ files:
185
185
  - lib/stealth/jobs.rb
186
186
  - lib/stealth/logger.rb
187
187
  - lib/stealth/reply.rb
188
+ - lib/stealth/scheduled_reply.rb
188
189
  - lib/stealth/server.rb
189
190
  - lib/stealth/service_message.rb
190
191
  - lib/stealth/service_reply.rb