This commit is contained in:
Alex Root Junior 2023-06-25 01:05:40 +03:00
parent a890622e40
commit 25c7e75eea
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
2 changed files with 5 additions and 6 deletions

View file

@ -500,11 +500,10 @@ class Dispatcher(Router):
workflow_data = {
"dispatcher": self,
"bots": bots,
"bot": bots[-1],
**kwargs,
**self.workflow_data,
**kwargs,
}
await self.emit_startup(**workflow_data)
await self.emit_startup(bot=bots[-1], **workflow_data)
loggers.dispatcher.info("Start polling")
try:
tasks: List[asyncio.Task[Any]] = [
@ -515,7 +514,7 @@ class Dispatcher(Router):
polling_timeout=polling_timeout,
backoff_config=backoff_config,
allowed_updates=allowed_updates,
**kwargs,
**workflow_data,
)
)
for bot in bots
@ -534,7 +533,7 @@ class Dispatcher(Router):
finally:
loggers.dispatcher.info("Polling stopped")
try:
await self.emit_shutdown(**workflow_data)
await self.emit_shutdown(bot=bots[-1], **workflow_data)
finally:
if close_bot_session:
await asyncio.gather(*(bot.session.close() for bot in bots))

View file

@ -28,8 +28,8 @@ def setup_application(app: Application, dispatcher: Dispatcher, /, **kwargs: Any
workflow_data = {
"app": app,
"dispatcher": dispatcher,
**kwargs,
**dispatcher.workflow_data,
**kwargs,
}
async def on_startup(*a: Any, **kw: Any) -> None: # pragma: no cover