lib/telegram/bot/updates_controller.rb in telegram-bot-0.3.0 vs lib/telegram/bot/updates_controller.rb in telegram-bot-0.4.0

- old
+ new

@@ -1,25 +1,41 @@ require 'abstract_controller' require 'active_support/callbacks' +require 'active_support/version' module Telegram - class Bot + module Bot class UpdatesController < AbstractController::Base - include AbstractController::Callbacks - include AbstractController::Translation + abstract! + require 'telegram/bot/updates_controller/session' require 'telegram/bot/updates_controller/log_subscriber' require 'telegram/bot/updates_controller/instrumentation' + + include AbstractController::Callbacks + # Redefine callbacks with default terminator. + if ActiveSupport.gem_version >= Gem::Version.new('5') + define_callbacks :process_action, + skip_after_callbacks_if_terminated: true + else + define_callbacks :process_action, + terminator: ->(_, result) { result == false }, + skip_after_callbacks_if_terminated: true + end + + include AbstractController::Translation prepend Instrumentation + extend Session::ConfigMethods + autoload :TypedUpdate, 'telegram/bot/updates_controller/typed_update' + PAYLOAD_TYPES = %w( message inline_query chosen_inline_result ).freeze CMD_REGEX = %r{\A/([a-z\d_]{,31})(@(\S+))?(\s|$)}i CONFLICT_CMD_REGEX = Regexp.new("^(#{PAYLOAD_TYPES.join('|')}|\\d)") - abstract! class << self def dispatch(*args) new(*args).dispatch end