Class: Telegram::Rails::ActionDispatcher
- Inherits:
-
Object
- Object
- Telegram::Rails::ActionDispatcher
- Defined in:
- lib/telegram/rails/action_dispatcher.rb
Constant Summary collapse
- ROUTE_DELIMETER =
"/"
- ENDPOINT_DELIMETER =
"#"
- COMMAND_START_SYMBOL =
"/"
- COMMAND_ARGS_SEPARATOR =
/\s+/
- DEFAULT_ACTION_NAME =
:process
Instance Method Summary collapse
- #dispatch_message(bot_name, message) ⇒ Object
-
#initialize(adapters) ⇒ ActionDispatcher
constructor
A new instance of ActionDispatcher.
- #register_route(route_data) ⇒ Object
Constructor Details
#initialize(adapters) ⇒ ActionDispatcher
Returns a new instance of ActionDispatcher.
15 16 17 18 |
# File 'lib/telegram/rails/action_dispatcher.rb', line 15 def initialize adapters @adapters = adapters @routes = [] end |
Instance Method Details
#dispatch_message(bot_name, message) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/telegram/rails/action_dispatcher.rb', line 27 def bot_name, adapter = find_adapter_for bot_name return unless adapter command, args = extract_command_from route = find_route_for bot_name, command return unless route , with: route end |
#register_route(route_data) ⇒ Object
21 22 23 24 |
# File 'lib/telegram/rails/action_dispatcher.rb', line 21 def register_route route_data route = parse_route(route_data) @routes << route end |