Executor
- aiogram.utils.executor.start_polling(dispatcher, *, loop=None, skip_updates=False, reset_webhook=True, on_startup=None, on_shutdown=None, timeout=20, relax=0.1, fast=True, allowed_updates: Optional[List[str]] = None)[source]
Start bot in long-polling mode
- Parameters
dispatcher –
loop –
skip_updates –
reset_webhook –
on_startup –
on_shutdown –
timeout –
relax –
fast –
allowed_updates –
- aiogram.utils.executor.set_webhook(dispatcher: Dispatcher, webhook_path: str, *, loop: Optional[AbstractEventLoop] = None, skip_updates: Optional[bool] = None, on_startup: Optional[Callable] = None, on_shutdown: Optional[Callable] = None, check_ip: bool = False, retry_after: Optional[Union[str, int]] = None, route_name: str = 'webhook_handler', web_app: Optional[Application] = None)[source]
Set webhook for bot
- Parameters
dispatcher – Dispatcher
webhook_path – str
loop – Optional[asyncio.AbstractEventLoop] (default: None)
skip_updates – bool (default: None)
on_startup – Optional[Callable] (default: None)
on_shutdown – Optional[Callable] (default: None)
check_ip – bool (default: False)
retry_after – Optional[Union[str, int]] See https://tools.ietf.org/html/rfc7231#section-7.1.3 (default: None)
route_name – str (default: ‘webhook_handler’)
web_app – Optional[Application] (default: None)
- Returns
- aiogram.utils.executor.start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None, on_startup=None, on_shutdown=None, check_ip=False, retry_after=None, route_name='webhook_handler', **kwargs)[source]
Start bot in webhook mode
- Parameters
dispatcher –
webhook_path –
loop –
skip_updates –
on_startup –
on_shutdown –
check_ip –
route_name –
kwargs –
- Returns
- aiogram.utils.executor.start(dispatcher, future, *, loop=None, skip_updates=None, on_startup=None, on_shutdown=None)[source]
Execute Future.
- Parameters
dispatcher – instance of Dispatcher
future – future
loop – instance of AbstractEventLoop
skip_updates –
on_startup –
on_shutdown –
- Returns
- class aiogram.utils.executor.Executor(dispatcher, skip_updates=None, check_ip=False, retry_after=None, loop=None)[source]
Main executor class
- set_web_app(application: Application)[source]
Change instance of aiohttp.web.Application
- Parameters
application –
- on_startup(callback: callable, polling=True, webhook=True)[source]
Register a callback for the startup process
- Parameters
callback –
polling – use with polling
webhook – use with webhook
- on_shutdown(callback: callable, polling=True, webhook=True)[source]
Register a callback for the shutdown process
- Parameters
callback –
polling – use with polling
webhook – use with webhook
- set_webhook(webhook_path: ~typing.Optional[str] = None, request_handler: ~typing.Any = <class 'aiogram.dispatcher.webhook.WebhookRequestHandler'>, route_name: str = 'webhook_handler', web_app: ~typing.Optional[~aiohttp.web_app.Application] = None)[source]
Set webhook for bot
- Parameters
webhook_path – Optional[str] (default: None)
request_handler – Any (default: WebhookRequestHandler)
route_name – str Name of webhook handler route (default: ‘webhook_handler’)
web_app – Optional[Application] (default: None)
- Returns
- start_webhook(webhook_path=None, request_handler=<class 'aiogram.dispatcher.webhook.WebhookRequestHandler'>, route_name='webhook_handler', **kwargs)[source]
Start bot in webhook mode
- Parameters
webhook_path –
request_handler –
route_name – Name of webhook handler route
kwargs –
- Returns