Class: FlowChat::Telegram::Gateway::BotApi
- Inherits:
-
Object
- Object
- FlowChat::Telegram::Gateway::BotApi
- Includes:
- GatewayAsyncSupport, Instrumentation
- Defined in:
- lib/flow_chat/telegram/gateway/bot_api.rb
Constant Summary
Constants included from Instrumentation
Instrumentation::DELIVERED_MESSAGE_ID_KEY, Instrumentation::DELIVERY_DURATION_KEY
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Attributes included from GatewayAsyncSupport
Class Method Summary collapse
-
.configure_middleware_stack(builder, custom_middleware) ⇒ Object
Platform-specific middleware configuration.
Instance Method Summary collapse
- #call(context) ⇒ Object
-
#initialize(app, config = nil) ⇒ BotApi
constructor
A new instance of BotApi.
Methods included from GatewayAsyncSupport
#async_supported?, #enqueue_async_job, #extract_body_for_background, #extract_headers_for_background, #extract_host, #extract_path, #extract_remote_ip, #in_background?, #should_enqueue_async?, #side_events_already_published?
Methods included from Instrumentation
#elapsed_ms_since, #inbound_message?, #instrument, instrument, report_api_error, #report_delivery_failure, #report_delivery_success, #report_to_app, #report_to_subscribers
Constructor Details
#initialize(app, config = nil) ⇒ BotApi
Returns a new instance of BotApi.
12 13 14 15 16 17 18 |
# File 'lib/flow_chat/telegram/gateway/bot_api.rb', line 12 def initialize(app, config = nil) @app = app @config = config || FlowChat::Telegram::Configuration.from_credentials @client = FlowChat::Telegram::Client.new(@config) FlowChat.logger.info { "BotApi: Initialized Telegram Bot API gateway" } end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/flow_chat/telegram/gateway/bot_api.rb', line 10 def client @client end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/flow_chat/telegram/gateway/bot_api.rb', line 10 def context @context end |
Class Method Details
.configure_middleware_stack(builder, custom_middleware) ⇒ Object
Platform-specific middleware configuration
42 43 44 45 46 |
# File 'lib/flow_chat/telegram/gateway/bot_api.rb', line 42 def self.configure_middleware_stack(builder, custom_middleware) FlowChat.logger.debug { "BotApi: Configuring Telegram middleware stack" } builder.use custom_middleware builder.use FlowChat::Telegram::Middleware::ChoiceMapper end |
Instance Method Details
#call(context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/flow_chat/telegram/gateway/bot_api.rb', line 20 def call(context) @context = context @controller = context.controller request = @controller.request FlowChat.logger.debug { "BotApi: Processing #{begin request.request_method rescue "POST" end} request" } # Handle POST webhooks only if request.post? return handle_webhook(context) end @controller.head :bad_request end |