1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-06 19:15:50 +03:00

Easily run UpdatesController's actions without updates

Этот коммит содержится в:
Max Melentiev
2016-03-11 13:03:13 +06:00
родитель e03e39bd53
Коммит 225290b677
8 изменённых файлов: 220 добавлений и 17 удалений

Просмотреть файл

@@ -158,6 +158,9 @@ config.telegram_updates_controller.session_store = :redis_store, {expires_in: 1.
class Telegram::WebhookController < Telegram::Bot::UpdatesController
include Telegram::Bot::UpdatesController::Session
# or just shortcut:
use_session!
# You can override global config
self.session_store = :file_store
@@ -219,6 +222,20 @@ class Telegram::WebhookController < Telegram::Bot::UpdatesController
end
```
To process update run:
```ruby
ControllerClass.dispatch(bot, update)
```
There is also ability to run action without update:
```ruby
# Most likely you'll want to pass :from and :chat
controller = ControllerClass.new(bot, from: telegram_user, chat: telegram_chat)
controller.process(:help, *args)
```
### Routes
Use `telegram_webhooks` helper to add routes. It will create routes for bots