Answer the question
In order to leave comments, you need to log in
Decrypts QRcode in TelegramBotAPI, but decodes photo characteristics?
There is a code snippet:
#bot decrypting a qrcode
@bot.message_handler(commands=['decrypt'])
def decrypting(message):
bot.send_message(message.chat.id, 'Пришли мне фото с QRкодом и я расшифрую его')
@bot.message_handler(content_types=['photo'])
def decrypting(message):
print('message.photo =', message.photo)
fileID = message.photo[-1].file_id
print('fileID =', fileID)
file_info = bot.get_file(fileID)
print('file.file_path =', file_info.file_path)
downloaded_file = bot.download_file(file_info.file_path)
with open("qr_decrypting.jpg", 'wb') as new_file:
new_file.write(downloaded_file)
data = decode(Image.open('qr_decrypting.jpg'))
bot.send_message(message.chat.id, f'QRкод: \n\n{data}')
os.remove('qr_decrypting.jpg')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question