-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
executable file
·48 lines (38 loc) · 1.91 KB
/
Copy pathconfig.py
File metadata and controls
executable file
·48 lines (38 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os # 導入 os 模組,用於操作環境變量
from dotenv import load_dotenv # 從 dotenv 導入 load_dotenv 函數,用於從 .env 文件加載環境變量
# Explicitly load the .env file from the /app directory inside the container
dotenv_path = '/app/.env'
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path=dotenv_path)
else:
print(f"Warning: .env file not found at {dotenv_path}")
# Database configuration
DB_USER = os.getenv("DB_USER", "user")
DB_PASSWORD = os.getenv("DB_PASSWORD", "password")
DB_HOST = os.getenv("DB_HOST", "localhost")
DB_PORT = os.getenv("DB_PORT", "3306")
DB_NAME = os.getenv("DB_NAME", "telegram_drive")
DATABASE_URL = f"mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
# Telegram 相關配置
TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
API_ID = os.getenv("API_ID")
API_HASH = os.getenv("API_HASH")
BOT_API_UPLOAD_LIMIT = 48 * 1024 * 1024 # 48 MB
MONITORED_CHAT_ID = os.getenv("MONITORED_CHAT_ID")
TELEGRAM_API_URL = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}"
# 上傳批次配置
UPLOAD_BATCH_SIZE = int(os.getenv("UPLOAD_BATCH_SIZE", 2))
UPLOAD_BATCH_DELAY = int(os.getenv("UPLOAD_BATCH_DELAY", 2))
# 緩存配置
CACHE_CLEANUP_INTERVAL_MINUTES = int(os.getenv("CACHE_CLEANUP_INTERVAL_MINUTES", 60))
CACHE_MAX_SIZE_GB = float(os.getenv("CACHE_MAX_SIZE_GB", 2.0))
CACHE_MAX_AGE_MINUTES = int(os.getenv("CACHE_MAX_AGE_MINUTES", 10))
# 縮略圖配置
THUMBNAIL_WIDTH = int(os.getenv("THUMBNAIL_WIDTH", 720))
THUMBNAIL_HEIGHT = int(os.getenv("THUMBNAIL_HEIGHT", 720))
# 管理員憑據配置
ADMIN_USERNAME = os.getenv("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD", "password")
# 是否優先使用 Telegram 官方縮略圖 (如果設為 True,則不再本地生成)
USE_TG_OFFICIAL_THUMBNAIL = os.getenv("USE_TG_OFFICIAL_THUMBNAIL", "FALSE").upper() == "TRUE"