lib/bobot/events/common.rb in bobot-1.0.53 vs lib/bobot/events/common.rb in bobot-2.1.0

- old
+ new

@@ -24,15 +24,15 @@ @messaging['recipient'] end def delay(wait: 0, wait_until: nil) raise Bobot::FieldFormat.new('wait has to be positive integer.') unless wait.present? - if Bobot.async + if Bobot.config.async @delay_options[:wait] = wait if wait >= 0 @delay_options[:wait_until] = wait_until if wait_until.present? else - warn "delay is ignored since you configured Bobot.async to 'false'" + warn "delay is ignored since you configured Bobot.config.async to 'false'" end self end def sent_at @@ -41,11 +41,11 @@ def deliver(payload_template:) raise Bobot::FieldFormat.new('payload_template is required.') unless payload_template.present? @payloads_sent << payload_template job = Bobot::DeliverJob - if Bobot.async + if Bobot.config.async job = job.set(wait: @delay_options[:wait]) if @delay_options[:wait] > 0 job = job.set(wait: @delay_options[:wait_until]) if @delay_options[:wait_until].present? job.perform_later(sender: sender, access_token: access_token, payload_template: payload_template) else job.perform_now(sender: sender, access_token: access_token, payload_template: payload_template) @@ -161,10 +161,10 @@ ) end alias_method :reply_with_carousel, :reply_with_generic def access_token - Bobot.page_access_token + Bobot.config.find_page_by_id(recipient["id"]).try(:page_access_token) end end end end