Telegram Bot aiogram отправка фото от нескольких пользователей на диск
Задача по кнопке отправляется фото или видео на диск, столкнулся с проблемой по очереди все отправляется создается папка фото прилетают, но столкнулся с проблемой если несколько пользователей начинают отправлять, то прилетает в папку кто первый запустил бота. Вот мой код
button1 = KeyboardButton('User1')
button2 = KeyboardButton('User2')
greet_kb = ReplyKeyboardMarkup(resize_keyboard=True).row(button1, button2)
d = 'X:\ '
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
await message.reply("Выбери себя", reply_markup=greet_kb)
@dp.message_handler(text=['User1'])
async def process_button1_command(message: types.Message):
global d
d = 'X:\User1'
await message.reply("Прикрепи фото или видео", reply_markup=ReplyKeyboardRemove())
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
await message.reply("Выбери себя", reply_markup=greet_kb)
@dp.message_handler(text=['User2'])
async def process_button1_command(message: types.Message):
global d
d = 'X:\User2'
await message.reply("Прикрепи фото или видео", reply_markup=ReplyKeyboardRemove())
@dp.message_handler(content_types=["photo"])
async def download_photo(message: types.Message):
#await bot.send_photo(message.photo[-1].download(destination_dir=(d))
await message.photo[-1].download(destination_dir=(d))
@dp.message_handler(content_types=["video"])
async def download_video(message: types.Message):
await message.video.download(destination_dir=(d))
if __name__ == '__main__':
executor.start_polling(dp)
Подскажите в каком направлении копать я так понимаю что то с глобальной переменной?