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)[source]

Start bot in long-polling mode

Parameters
  • dispatcher

  • loop

  • skip_updates

  • reset_webhook

  • on_startup

  • on_shutdown

  • timeout

aiogram.utils.executor.set_webhook(dispatcher: aiogram.dispatcher.dispatcher.Dispatcher, webhook_path: str, *, loop: Optional[asyncio.events.AbstractEventLoop] = None, skip_updates: bool = None, on_startup: Optional[Callable] = None, on_shutdown: Optional[Callable] = None, check_ip: bool = False, retry_after: Union[str, int, None] = None, route_name: str = 'webhook_handler', web_app: Optional[aiohttp.web_app.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: aiohttp.web_app.Application)[source]

Change instance of aiohttp.web.Applicaton

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: Optional[str] = None, request_handler: Any = <class 'aiogram.dispatcher.webhook.WebhookRequestHandler'>, route_name: str = 'webhook_handler', web_app: 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

start_polling(reset_webhook=None, timeout=20, relax=0.1, fast=True)[source]

Start bot in long-polling mode

Parameters
  • reset_webhook

  • timeout

start(future)[source]

Execute Future.

Return the Future’s result, or raise its exception.

Parameters

future

Returns