@router.message(Command("myprofile"))
async def show_profile(message: Message):
user_id = message.from_user.id
with DATABASE:
cur = DATABASE.cursor()
cur.execute("SELECT user_name, user_age, user_city, user_photo FROM user WHERE user_id = ?", (user_id,))
user_data = cur.fetchone()
if user_data:
user_name, user_age, user_city, user_photo = user_data
profile_info = (
f"Имя: {user_name}\n"
f"Возраст: {user_age}\n"
f"Город: {user_city}\n"
)
await message.answer(profile_info)
if os.path.exists(user_photo):
photo = InputFile(user_photo)
await message.answer_photo(photo, caption=profile_info)
else:
await message.answer(f"Фото не найдено. Проверьте путь к файлу: {user_photo}")
else:
await message.answer("Ваша анкета не найдена. Пожалуйста, создайте её сначала.")
Ошибка:
Cause exception while process update id=716058876 by bot id=6731739064
TypeError: Can't instantiate abstract class InputFile without an implementation for abstract method 'read'
Traceback (most recent call last):
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 309, in _process_update
response = await self.feed_update(bot, update, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 158, in feed_update
response = await self.update.wrap_outer_middleware(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\middlewares\error.py", line 25, in __call__
return await handler(event, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\middlewares\user_context.py", line 56, in __call__
return await handler(event, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\fsm\middleware.py", line 42, in __call__
return await handler(event, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\event\telegram.py", line 121, in trigger
return await wrapped_inner(event, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\event\handler.py", line 43, in call
return await wrapped()
^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 276, in _listen_update
return await self.propagate_event(update_type=update_type, event=event, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 142, in propagate_event
return await observer.wrap_outer_middleware(_wrapped, event=event, data=kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 137, in _wrapped
return await self._propagate_event(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 170, in _propagate_event
response = await router.propagate_event(update_type=update_type, event=event, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 142, in propagate_event
return await observer.wrap_outer_middleware(_wrapped, event=event, data=kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 137, in _wrapped
return await self._propagate_event(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\router.py", line 162, in _propagate_event
response = await observer.trigger(event, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\event\telegram.py", line 121, in trigger
return await wrapped_inner(event, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\.venv\Lib\site-packages\aiogram\dispatcher\event\handler.py", line 43, in call
return await wrapped()
^^^^^^^^^^^^^^^
File "C:\Users\peeck\Documents\pythonProject\hendlers\hendlers.py", line 126, in show_profile
photo = InputFile(user_photo)
^^^^^^^^^^^^^^^^^^^^^
TypeError: Can't instantiate abstract class InputFile without an implementation for abstract method 'read'