Добрый день!
Хочу сделать что бы телеграм-бот скачивал файл, работал с ним и отправлял в ответ готовый.
Этот цикл у меня работает 1 раз, и выдает следующую ошибку:
A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: wrong remote file id specified: Wrong padding in the string"}']
Вот код:
import telebot
import constant
bot = telebot.TeleBot(constant.API_TOKEN)
# Сохраняем присланый от пользователя файл
@bot.message_handler(content_types=['document'])
def handle_file(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)
src = u'D:\\Python\\Bot\\' + message.document.file_name
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
#import delete
import tableTOtable
bot.reply_to(message, 'Одну минуточку...')
doc = open('D:\\Python\\Bot\\Счет-фактура.pdf', 'rb')
bot.send_document(chat_id, doc)
bot.send_document(chat_id, "FILEID")
except Exception as e:
bot.reply_to(message, e)
import kill_procces
import delete
bot.polling(none_stop=True, interval=0)
Может с интервалом что? Или помогите как автоматом перезапускать файл.py после цикла. Спасибо!