mirror of
https://github.com/flibusta-apps/telegram_files_server.git
synced 2025-12-06 04:25:38 +01:00
Add downloading
This commit is contained in:
30
fastapi_file_server/app/services/storages.py
Normal file
30
fastapi_file_server/app/services/storages.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from telegram_files_storage import AiogramFilesStorage, TelethonFilesStorage
|
||||
|
||||
from core.config import env_config
|
||||
|
||||
|
||||
class StoragesContainer:
|
||||
AIOGRAM_STORAGES: list[AiogramFilesStorage] = []
|
||||
TELETHON_STORAGES: list[TelethonFilesStorage] = []
|
||||
|
||||
@classmethod
|
||||
async def prepare(cls):
|
||||
if env_config.BOT_TOKENS:
|
||||
cls.AIOGRAM_STORAGES: list[AiogramFilesStorage] = [
|
||||
AiogramFilesStorage(env_config.TELEGRAM_CHAT_ID, token)
|
||||
for token in env_config.BOT_TOKENS
|
||||
]
|
||||
|
||||
if env_config.TELETHON_APP_CONFIG and env_config.TELETHON_SESSIONS:
|
||||
cls.TELETHON_STORAGES: list[TelethonFilesStorage] = [
|
||||
TelethonFilesStorage(
|
||||
env_config.TELEGRAM_CHAT_ID,
|
||||
env_config.TELETHON_APP_CONFIG.APP_ID,
|
||||
env_config.TELETHON_APP_CONFIG.API_HASH,
|
||||
session,
|
||||
)
|
||||
for session in env_config.TELETHON_SESSIONS
|
||||
]
|
||||
|
||||
for storage in [*cls.AIOGRAM_STORAGES, *cls.TELETHON_STORAGES]:
|
||||
await storage.prepare()
|
||||
Reference in New Issue
Block a user