AttributeError: 'Bot' object has no attribute 'get_session'

Скачала бота с GitHub, но при запуске файла main в PyCharm получаю ошибку:

AttributeError: 'Bot' object has no attribute 'get_session'

Проблемный блок кода:

async def send_message(bot_token, message, chat, rpl=None, prv=None):
    bot = Bot(token=bot_token)
    await bot.get_session()
    obj = await bot.send_message(
        chat_id=chat,
        text=message,
        parse_mode="HTML",
        reply_to_message_id=rpl,
        disable_web_page_preview=prv,
    )
    await asyncio.sleep(3)
    await bot._session.close()
    return obj.message_id


async def send_document(document, filename, caption=None, prv=None, rpl=None):
    bot = Bot(token=config.bot_key)
    await bot.get_session()
    obj = await bot.send_document(
        config.chat_id, (filename, document), caption=caption, reply_to_message_id=rpl
    )
    await asyncio.sleep(2)
    await bot._session.close()
    return obj.message_id

Полный код ошибки:

C:\Users\Виль\AppData\Local\Programs\Python\Python38\python.exe
C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py
        Traceback (most recent call last):
File "C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py", line 88, in <module>
    main()
  File "C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py", line 68, in main
    reply_id = loop.run_until_complete(
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\Виль\PycharmProjects\untitled1\venv\mail_reader-master\functions.py", line 89, in send_message
    await bot.get_session()
AttributeError: 'Bot' object has no attribute 'get_session'

Traceback (most recent call last):
  File "C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py", line 88, in <module>
    main()
  File "C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py", line 68, in main
    reply_id = loop.run_until_complete(
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\Виль\PycharmProjects\untitled1\venv\mail_reader-master\functions.py", line 89, in send_message
    await bot.get_session()
AttributeError: 'Bot' object has no attribute 'get_session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Виль/PycharmProjects/untitled1/venv/mail_reader-master/main.py", line 93, in <module>
    loop.run_until_complete(
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\Виль\PycharmProjects\untitled1\venv\mail_reader-master\functions.py", line 89, in send_message
    await bot.get_session()
AttributeError: 'Bot' object has no attribute 'get_session'
Exception ignored in: <function BaseBot.__del__ at 0x000000000428BCA0>
Traceback (most recent call last):
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\site-packages\aiogram\bot\base.py", line 109, in __del__
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 758, in new_event_loop
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 656, in new_event_loop
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 310, in __init__
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 632, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000000004BF82E0>
Exception ignored in: <function BaseBot.__del__ at 0x000000000428BCA0>
Traceback (most recent call last):
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\site-packages\aiogram\bot\base.py", line 109, in __del__
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 758, in new_event_loop
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 656, in new_event_loop
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 310, in __init__
  File "C:\Users\Виль\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 632, in __init__
ImportError: sys.meta_path is None, Python is likely shutting down
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000000004BF8640>

Process finished with exit code 1 

Ответы (0 шт):