ошибка выводится при ответе на сообщение aiogram python
ошибка выводится при ответе на сообщение
код:
from config import token, ls
bot = Bot(token, parse_mode='HTML')
dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def start_cmd(message: types.Message):
await message.answer(f'''Привет!
Я свяжу тебя с <a href="https://t.me/lilswatter">lilswatter'ом</a>!
Напиши ему сообщение здесь, а он тебе ответит в скором времени.
<b>Это автоматическое сообщение.</b>''')
@dp.message_handler(content_types=['any'])
async def p2p_handler(message: types.Message):
if message.chat.type == 'private':
if message.from_user.id == ls:
if not message.reply_to_message:
return
await bot.forward_message(message.reply_to_message.forward_from.id,
message.chat.id,
message.message_id
)
else:
await bot.forward_message(ls, message.chat.id, message.message_id)
if __name__ == '__main__':
print('\n -+- Бот работает. -+- \n')
executor.start_polling(dp, skip_updates=True)
лог:
future: <Task finished name='Task-24' coro=<Dispatcher._process_polling_updates() done, defined at /home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=AttributeError("'NoneType' object has no attribute 'id'")>
Traceback (most recent call last):
File "/home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "/home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "/home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "/home/runner/GrossIndianredGreyware/.pythonlibs/lib/python3.10/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/home/runner/GrossIndianredGreyware/main.py", line 23, in p2p_handler
await bot.forward_message(message.reply_to_message.forward_from.id,
AttributeError: 'NoneType' object has no attribute 'id'