Is it possible to use the aiogram library asynchronously just by executing methods? Not only as an answer for the user.

Conditional code:

from aiogram import Bot, Dispatcher, executor, types
bot= Bot (token)
dp= Dispatcher (bot)
await bot.send_message (54656484, 'text')
  • Answer # 1
    await bot.send_message (user_id, text)

    is executed once like this

    import asyncio
    asyncio.get_event_loop (). run_until_complete (bot.send_message (user_id, text))

    I do not see chats in your example, add the question -I will fix it.

    eri2021-12-24 16:08:54

    Everything works, but displays a warning: Unclosed client session client_session: Unclosed connector connections: ['[(, 50036.275)] '] connector:Can I disable it somehow?

    RNB2021-12-24 16:57:28