Update app.py
Browse files
app.py
CHANGED
|
@@ -30,34 +30,15 @@ logging.basicConfig(
|
|
| 30 |
]
|
| 31 |
)
|
| 32 |
|
| 33 |
-
# === Setup Telegram Client (only if credentials are available) ===
|
| 34 |
# === Setup Telegram Client (only if credentials are available) ===
|
| 35 |
client = None
|
| 36 |
if API_ID and API_HASH:
|
| 37 |
try:
|
| 38 |
-
|
| 39 |
-
session_path = "my_session"
|
| 40 |
-
session_file = "my_session.session"
|
| 41 |
-
|
| 42 |
-
if not os.path.exists(session_file):
|
| 43 |
-
# Try home directory if not found in CWD
|
| 44 |
-
home_session = os.path.expanduser("~/my_session.session")
|
| 45 |
-
if os.path.exists(home_session):
|
| 46 |
-
session_path = os.path.expanduser("~/my_session")
|
| 47 |
-
logging.info(f"✅ Found session in home dir: {home_session}")
|
| 48 |
-
else:
|
| 49 |
-
logging.warning("⚠️ No session file found in current dir or home dir. Will try to connect unauthenticated.")
|
| 50 |
-
|
| 51 |
-
else:
|
| 52 |
-
logging.info(f"✅ Found session in current directory: {session_file}")
|
| 53 |
-
|
| 54 |
-
client = TelegramClient(session_path, int(API_ID), API_HASH)
|
| 55 |
-
|
| 56 |
except ValueError as e:
|
| 57 |
-
logging.error(f"
|
| 58 |
client = None
|
| 59 |
|
| 60 |
-
|
| 61 |
# === Ensure download folder exists ===
|
| 62 |
os.makedirs("downloads", exist_ok=True)
|
| 63 |
|
|
|
|
| 30 |
]
|
| 31 |
)
|
| 32 |
|
|
|
|
| 33 |
# === Setup Telegram Client (only if credentials are available) ===
|
| 34 |
client = None
|
| 35 |
if API_ID and API_HASH:
|
| 36 |
try:
|
| 37 |
+
client = TelegramClient("my_session", int(API_ID), API_HASH)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
except ValueError as e:
|
| 39 |
+
logging.error(f"Failed to initialize Telegram client: {e}")
|
| 40 |
client = None
|
| 41 |
|
|
|
|
| 42 |
# === Ensure download folder exists ===
|
| 43 |
os.makedirs("downloads", exist_ok=True)
|
| 44 |
|