зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-06 19:15:50 +03:00
Easily run UpdatesController's actions without updates
Этот коммит содержится в:
17
README.md
17
README.md
@@ -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
|
||||
|
||||
Ссылка в новой задаче
Block a user