import telebot
import mysql.connector
from telebot import types, TeleBot
from telebot.types import Message
import os
directory = "45468798"
parent_dir = "C:/Users/1/PycharmProjects/photo/"
path = os.path.join(parent_dir, directory)
os.mkdir(path)
print("Directory '%s' created" % directory)
@bot.message_handler(content_type=['photo'])
def process_photo_step(message):
chat_id = message.from_user.id
file_info = bot.get_file(message.photo[len(message.photo) - 1].file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = r"{}\{}\{}".format(os.getcwd(), chat_id, message.photo[-1].file_id)
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
msg = bot.send_message(message.chat.id, "спасибо")