mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 02:52:12 +00:00
Webhook docs (#1248)
* Added documentation for polling/webhook modes * Added changelog * Added changelog
This commit is contained in:
parent
62d4b9014c
commit
b311d59fce
37 changed files with 2595 additions and 692 deletions
|
|
@ -8,14 +8,14 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: aiogram \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-10-01 22:51+0300\n"
|
||||
"POT-Creation-Date: 2023-08-06 16:52+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.10.3\n"
|
||||
"Generated-By: Babel 2.12.1\n"
|
||||
|
||||
#: ../../dispatcher/index.rst:3
|
||||
msgid "Handling events"
|
||||
|
|
@ -54,3 +54,23 @@ msgid ""
|
|||
"Dispatcher is also separated into two entities - Router and Dispatcher. "
|
||||
"Dispatcher is subclass of router and should be always is root router."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/index.rst:18
|
||||
msgid "Telegram supports two ways of receiving updates:"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/index.rst:20
|
||||
msgid ""
|
||||
":ref:`Webhook <webhook>` - you should configure your web server to "
|
||||
"receive updates from Telegram;"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/index.rst:21
|
||||
msgid ""
|
||||
":ref:`Long polling <long-polling>` - you should request updates from "
|
||||
"Telegram."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/index.rst:23
|
||||
msgid "So, you can use both of them with *aiogram*."
|
||||
msgstr ""
|
||||
|
|
|
|||
62
docs/locale/en/LC_MESSAGES/dispatcher/long_polling.po
Normal file
62
docs/locale/en/LC_MESSAGES/dispatcher/long_polling.po
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) 2023, aiogram Team
|
||||
# This file is distributed under the same license as the aiogram package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: aiogram \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-06 16:52+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.12.1\n"
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:5
|
||||
msgid "Long-polling"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:7
|
||||
msgid ""
|
||||
"Long-polling is a technology that allows a Telegram server to send "
|
||||
"updates in case when you don't have dedicated IP address or port to "
|
||||
"receive webhooks for example on a developer machine."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:11
|
||||
msgid ""
|
||||
"To use long-polling mode you should use "
|
||||
":meth:`aiogram.dispatcher.dispatcher.Dispatcher.start_polling` or "
|
||||
":meth:`aiogram.dispatcher.dispatcher.Dispatcher.run_polling` methods."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:16
|
||||
msgid ""
|
||||
"You can use polling from only one polling process per single Bot token, "
|
||||
"in other case Telegram server will return an error."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:21
|
||||
msgid ""
|
||||
"If you will need to scale your bot, you should use webhooks instead of "
|
||||
"long-polling."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:25
|
||||
msgid "If you will use multibot mode, you should use webhook mode for all bots."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:28
|
||||
msgid "Example"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/long_polling.rst:30
|
||||
msgid ""
|
||||
"This example will show you how to create simple echo bot based on long-"
|
||||
"polling."
|
||||
msgstr ""
|
||||
303
docs/locale/en/LC_MESSAGES/dispatcher/webhook.po
Normal file
303
docs/locale/en/LC_MESSAGES/dispatcher/webhook.po
Normal file
|
|
@ -0,0 +1,303 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) 2023, aiogram Team
|
||||
# This file is distributed under the same license as the aiogram package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: aiogram \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-06 16:52+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.12.1\n"
|
||||
|
||||
#: ../../dispatcher/webhook.rst:5
|
||||
msgid "Webhook"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:7
|
||||
msgid ""
|
||||
"Telegram Bot API supports webhook. If you set webhook for your bot, "
|
||||
"Telegram will send updates to the specified url. You can use "
|
||||
":meth:`aiogram.methods.set_webhook.SetWebhook` method to specify a url "
|
||||
"and receive incoming updates on it."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:14
|
||||
msgid "If you use webhook, you can't use long polling at the same time."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:16
|
||||
msgid ""
|
||||
"Before start i'll recommend you to read `official Telegram's "
|
||||
"documentation about webhook <https://core.telegram.org/bots/webhooks>`_"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:18
|
||||
msgid "After you read it, you can start to read this section."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:20
|
||||
msgid ""
|
||||
"Generally to use webhook with aiogram you should use any async web "
|
||||
"framework. Buy out of the box aiogram has an aiohttp integration, so "
|
||||
"we'll use it."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:25
|
||||
msgid ""
|
||||
"You can use any async web framework you want, but you should write your "
|
||||
"own integration if you don't use aiohttp."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:29
|
||||
msgid "aiohttp integration"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:31
|
||||
msgid "Out of the box aiogram has aiohttp integration, so you can use it."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:33
|
||||
msgid ""
|
||||
"Here is available few ways to do it using different implementations of "
|
||||
"the webhook controller:"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:35
|
||||
msgid ""
|
||||
":class:`aiogram.webhook.aiohttp_server.BaseRequestHandler` - Abstract "
|
||||
"class for aiohttp webhook controller"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:36
|
||||
msgid ""
|
||||
":class:`aiogram.webhook.aiohttp_server.SimpleRequestHandler` - Simple "
|
||||
"webhook controller, uses single Bot instance"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:37
|
||||
msgid ""
|
||||
":class:`aiogram.webhook.aiohttp_server.TokenBasedRequestHandler` - Token"
|
||||
" based webhook controller, uses multiple Bot instances and tokens"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:39
|
||||
msgid "You can use it as is or inherit from it and override some methods."
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.__init__:1 of
|
||||
msgid ""
|
||||
"Base handler that helps to handle incoming request from aiohttp and "
|
||||
"propagate it to the Dispatcher"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.__init__
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.register
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.__init__
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.register
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.ip_filter_middleware of
|
||||
msgid "Parameters"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.__init__:4
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.__init__:3
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__:9 of
|
||||
msgid "instance of :class:`aiogram.dispatcher.dispatcher.Dispatcher`"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.__init__:5 of
|
||||
msgid ""
|
||||
"immediately responds to the Telegram instead of a waiting end of a "
|
||||
"handler process"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.register:1 of
|
||||
msgid "Register route and shutdown callback"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.register:3
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.register:3 of
|
||||
msgid "instance of aiohttp Application"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.register:4
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.register:4 of
|
||||
msgid "route path"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.resolve_bot:1
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.resolve_bot:1 of
|
||||
msgid "This method should be implemented in subclasses of this class."
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.resolve_bot:3
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.resolve_bot:3 of
|
||||
msgid "Resolve Bot instance from request."
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.resolve_bot
|
||||
#: aiogram.webhook.aiohttp_server.ip_filter_middleware of
|
||||
msgid "Returns"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.BaseRequestHandler.resolve_bot:6
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.resolve_bot:6 of
|
||||
msgid "Bot instance"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.__init__:1 of
|
||||
msgid "Handler for single Bot instance"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.__init__:4
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__:10 of
|
||||
msgid ""
|
||||
"immediately responds to the Telegram instead of a waiting end of handler "
|
||||
"process"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.__init__:6 of
|
||||
msgid "instance of :class:`aiogram.client.bot.Bot`"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.SimpleRequestHandler.close:1 of
|
||||
msgid "Close bot session"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__:1 of
|
||||
msgid ""
|
||||
"Handler that supports multiple bots the context will be resolved from "
|
||||
"path variable 'bot_token'"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__:6 of
|
||||
msgid ""
|
||||
"This handler is not recommended in due to token is available in URL and "
|
||||
"can be logged by reverse proxy server or other middleware."
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.__init__:12 of
|
||||
msgid "kwargs that will be passed to new Bot instance"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.register:1 of
|
||||
msgid "Validate path, register route and shutdown callback"
|
||||
msgstr ""
|
||||
|
||||
#: aiogram.webhook.aiohttp_server.TokenBasedRequestHandler.resolve_bot:1 of
|
||||
msgid "Get bot token from a path and create or get from cache Bot instance"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:51
|
||||
msgid "Security"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:53
|
||||
msgid ""
|
||||
"Telegram supports two methods to verify incoming requests that they are "
|
||||
"from Telegram:"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:56
|
||||
msgid "Using a secret token"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:58
|
||||
msgid ""
|
||||
"When you set webhook, you can specify a secret token and then use it to "
|
||||
"verify incoming requests."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:61
|
||||
msgid "Using IP filtering"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:63
|
||||
msgid ""
|
||||
"You can specify a list of IP addresses from which you expect incoming "
|
||||
"requests, and then use it to verify incoming requests."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:65
|
||||
msgid ""
|
||||
"It can be acy using firewall rules or nginx configuration or middleware "
|
||||
"on application level."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:67
|
||||
msgid ""
|
||||
"So, aiogram has an implementation of the IP filtering middleware for "
|
||||
"aiohttp."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:75
|
||||
msgid "Examples"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:78
|
||||
msgid "Behind reverse proxy"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:80
|
||||
msgid ""
|
||||
"In this example we'll use aiohttp as web framework and nginx as reverse "
|
||||
"proxy."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:84
|
||||
msgid ""
|
||||
"When you use nginx as reverse proxy, you should set `proxy_pass` to your "
|
||||
"aiohttp server address."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:98
|
||||
msgid "Without reverse proxy (not recommended)"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:100
|
||||
msgid ""
|
||||
"In case you want can't use reverse proxy, you can use aiohttp's ssl "
|
||||
"context."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:102
|
||||
msgid "Also this example contains usage with self-signed certificate."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:108
|
||||
msgid "With using other web framework"
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:110
|
||||
msgid ""
|
||||
"You can pass incoming request to aiogram's webhook controller from any "
|
||||
"web framework you want."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:112
|
||||
msgid ""
|
||||
"Read more about it in "
|
||||
":meth:`aiogram.dispatcher.dispatcher.Dispatcher.feed_webhook_update` or "
|
||||
":meth:`aiogram.dispatcher.dispatcher.Dispatcher.feed_update` methods."
|
||||
msgstr ""
|
||||
|
||||
#: ../../dispatcher/webhook.rst:123
|
||||
msgid ""
|
||||
"If you want to use reply into webhook, you should check that result of "
|
||||
"the :code:`feed_update` methods is an instance of API method and build "
|
||||
":code:`multipart/form-data` or :code:`application/json` response body "
|
||||
"manually."
|
||||
msgstr ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue