@decode_router.message(lambda message: True)
async def decode(message: Message):
await main.bot.send_message(message.chat.id, "Decoding...")
fl = await main.bot.download_file(message.photo, f"qrcode{message.from_user.id}.png")
file = FSInputFile(message.photo[-1].file_id)
img = cv2.imread(fl)
detector = cv2.QRCodeDetector()
data, ver, binary = detector.detectAndDecode(img)
if ver is not None:
await message.answer(data)
else:
await message.answer("No QR code detected.")
i want to decode qr-code from photo-message from user, by lib cv2. but, when i trying to download the photo, i recieve th error:
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('https://api.telegram.org/file/bot6526677170:AAHXvI03Tn48IhrAXlKS1JJhRtfVotFDiEQ/%5BPhotoSize(file_id='AgACAgIAAxkBAAIBFmZ4pB0X2mFPTV_s946k5-BCEQn_AAJL2TEb3QrJS0QwT7WdzZFlAQADAgADcwADNQQ',%20file_unique_id='AQADS9kxG90KyUt4',%20width=90,%20height=90,%20file_size=2652),%20PhotoSize(file_id='AgACAgIAAxkBAAIBFmZ4pB0X2mFPTV_s946k5-BCEQn_AAJL2TEb3QrJS0QwT7WdzZFlAQADAgADeAADNQQ',%20file_unique_id='AQADS9kxG90KyUt9',%20width=370,%20height=370,%20file_size=12681),%20PhotoSize(file_id='AgACAgIAAxkBAAIBFmZ4pB0X2mFPTV_s946k5-BCEQn_AAJL2TEb3QrJS0QwT7WdzZFlAQADAgADbQADNQQ',%20file_unique_id='AQADS9kxG90KyUty',%20width=320,%20height=320,%20file_size=20649)%5D')
i tried just download the file without some different code:
@decode_router.message(lambda message: True)
async def decode(message: Message):
fl = await main.bot.download_file(message.photo, f"qrcode{message.from_user.id}.png")
and have the same error
ps. sorry for my mistakes, my english is not perfect btw
New contributor
Евгений is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.