Answer the question
In order to leave comments, you need to log in
(-2147221008, 'CoInitialize was not called.', None, None) — What to fix?
Hello!
The code:
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)
from importlib import reload
import tableTOtable
while True:
reload(tableTOtable) #Запускается обработчик файла
break
doc = open('D:\\Python\\Bot\\Счет-фактура.pdf', 'rb')
bot.send_document(chat_id, doc)
#bot.send_document(chat_id, "FILEID")
#bot.sendDocument(chat_id, data, {fileName: 'file.pdf'});
except Exception as e:
bot.reply_to(message, e)
from importlib import reload
import kill_procces # Закрывается процесс эксэля
while True:
reload(kill_procces) #Запускается обработчик файла
break # Удаляется больше не нужный файл
from importlib import reload
import delete
while True:
reload(delete)
break
bot.polling(none_stop=True, interval=0)
(-2147221008, 'CoInitialize was not called.', None, None)
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