@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text == 'Зашифровать':
bot.send_message(message.chat.id, 'Пришлите файл для зашифровки')
time.sleep(15)
@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 = 'D:' + message.document.file_name;
filename = message.document.file_name
return filename
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, "Шифрую...")
except Exception as e:
bot.reply_to(message, e)
@bot.message_handler(regexp="Зашифровать")
def send_text(message):
msg = bot.send_message(message.chat.id, 'Пришлите файл для зашифровки')
bot.register_next_step_handler(msg, handle_file)
def handle_file(message):
try:
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'D:' + message.document.file_name;
filename = message.document.file_name
return filename
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, "Шифрую...")
except Exception as e:
bot.reply_to(message, e)