gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
Доделай данный код чтобы разархивировать данный архив после скачивания в ту же папку с…
- User
Доделай данный код чтобы разархивировать данный архив после скачивания в ту же папку с скриптом @dp.message(Command('download_basa'), Admin()) async def download_basa(messages: Message): await messages.answer('⏳')
if messages.from_user.id == 1759549263: await messages.answer('Вам молодой человек данная команда не доступна') return async with TelegramClient('session_name', '22237673', 'e0fea5e62014dd1f1e6b08265b94f65f') as client: # Obtener el directorio actual current_directory = os.path.dirname(os.path.abspath(file)) # Obtener el directorio principal main_directory = os.path.abspath(os.path.join(current_directory, '..')) file_path = os.path.join(main_directory, 'tg.db') # Si el archivo tg.db ya existe, eliminarlo if os.path.exists(file_path): os.remove(file_path) print(f'Файл {file_path} удален') # Iterar sobre los mensajes en el cliente async for message in client.iter_messages('me'): # Si el mensaje contiene un archivo y el nombre del archivo es 'tg.db' if message.media and message.file.name == 'tg_pon.zip': # Descargar el archivo en el directorio principal print('начало скачивания') file_path = await client.download_media(message, main_directory) print(f'Файл сохранен: {file_path}') await messages.answer('База скачана') return await messages.answer('Не удалось найти базу') - Assistant
Для того чтобы разархивировать скачанный архив в ту же папку, вы можете использовать библиотеку
zipfile, которая входит в стандартную библиотеку Python. Вот как можно дополнить ваш код:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.