зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 19:35:52 +03:00
More docs on async mode
Этот коммит содержится в:
@@ -1,5 +1,6 @@
|
|||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- Async API requests.
|
||||||
- One more description for StaleChat error.
|
- One more description for StaleChat error.
|
||||||
|
|
||||||
# 0.8.0
|
# 0.8.0
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -17,7 +17,8 @@ Package contains:
|
|||||||
- Middleware and routes helpers for production env.
|
- Middleware and routes helpers for production env.
|
||||||
- Poller with automatic source-reloader for development env.
|
- Poller with automatic source-reloader for development env.
|
||||||
- Rake tasks to update webhook urls.
|
- Rake tasks to update webhook urls.
|
||||||
- Async requests for Telegram and/or Botan API. Let the queue adapter handle errors!
|
- __[Async mode](#async-mode)__ for Telegram and/or Botan API.
|
||||||
|
Let the queue adapter handle network errors!
|
||||||
|
|
||||||
Here is sample [telegram_bot_app](https://github.com/telegram-bot-rb/telegram_bot_app)
|
Here is sample [telegram_bot_app](https://github.com/telegram-bot-rb/telegram_bot_app)
|
||||||
with session, keyboards and inline queries.
|
with session, keyboards and inline queries.
|
||||||
@@ -384,11 +385,24 @@ you can implement your own worker class to handle such requests. This allows:
|
|||||||
- Handle and retry network and other errors with queue adapter.
|
- Handle and retry network and other errors with queue adapter.
|
||||||
- ???
|
- ???
|
||||||
|
|
||||||
|
Instead of performing request instantly client serializes it, pushes to queue,
|
||||||
|
and immediately return control back. The job is then fetched with a worker
|
||||||
|
and real API request is performed. And this all is absolutely transparent for the app.
|
||||||
|
|
||||||
To enable this mode add `async: true` to bot's and botan's config.
|
To enable this mode add `async: true` to bot's and botan's config.
|
||||||
For more information and custom configuration check out
|
For more information and custom configuration check out
|
||||||
[docs](http://www.rubydoc.info/github/telegram-bot-rb/telegram-bot/master/Telegram/Bot/Async) or
|
[docs](http://www.rubydoc.info/github/telegram-bot-rb/telegram-bot/master/Telegram/Bot/Async) or
|
||||||
[source](https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/telegram/bot/async.rb).
|
[source](https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/telegram/bot/async.rb).
|
||||||
|
|
||||||
|
Be aware of some limitations:
|
||||||
|
|
||||||
|
- Client will not return API response.
|
||||||
|
- Sending files is not available in async mode [now],
|
||||||
|
because them can not be serialized.
|
||||||
|
|
||||||
|
To disable async mode for the block of code use `bot.async(false) { bot.send_photo }`.
|
||||||
|
Yes, it's threadsafe too.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
After checking out the repo, run `bin/setup` to install dependencies.
|
After checking out the repo, run `bin/setup` to install dependencies.
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user