Example #1
0
    def download_product_4(message):
        try:
            chat_id = message.chat.id
            file_info = bot.get_file(message.document.file_id)
            downloaded_file = bot.download_file(file_info.file_path)

            download = download_dict[message.chat.id]

            with open(message.document.file_name, 'wb') as doc:
                doc.write(downloaded_file)

            func.download_product(message.document.file_name, download.name_product)

            bot.send_message(chat_id=chat_id,
                             text='❕ Товар загружен 👍')
        except Exception as e:
            pass
            bot.send_message(chat_id=message.chat.id,
                             text='Упсс, что-то пошло не по плану')
Example #2
0
    def download_product_4(message):
        try:
            file_name = message.document.file_name.encode('UTF-8').decode(
                'UTF-8')
            chat_id = message.chat.id

            file_info = bot.get_file(message.document.file_id)
            downloaded_file = bot.download_file(file_info.file_path)

            download = download_dict[message.chat.id]

            with open(file_name, 'wb') as doc:
                doc.write(downloaded_file)

            func.download_product(file_name, download.name_product)

            bot.send_message(chat_id=chat_id, text='❕ Товар загружен 👍')
        except Exception as e:
            print(e)
            bot.send_message(chat_id=message.chat.id,
                             text='Упсс, что-то пошло не по плану',
                             reply_markup=menu.admin_menu)