no-name-here commited on
Commit
661c7ab
·
verified ·
1 Parent(s): f6b94f0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -7
main.py CHANGED
@@ -46,7 +46,6 @@ logging.getLogger("pyrogram").setLevel(logging.ERROR)
46
  def LOGGER(name: str) -> logging.Logger:
47
  return logging.getLogger(name)
48
 
49
- # ============================================================
50
  # Config
51
  # ============================================================
52
  try:
@@ -55,17 +54,28 @@ try:
55
  except Exception:
56
  pass
57
 
 
 
 
 
 
 
58
  _required = ["BOT_TOKEN", "API_ID", "API_HASH", "SPACE_URL"]
59
  _missing = [v for v in _required if not os.getenv(v)]
60
  if _missing:
61
  print(f"ERROR: Missing required env vars: {', '.join(_missing)}")
62
  sys.exit(1)
63
 
64
- API_ID = int(os.getenv("API_ID"))
65
- API_HASH = os.getenv("API_HASH")
66
- BOT_TOKEN = os.getenv("BOT_TOKEN")
67
- SPACE_URL = os.getenv("SPACE_URL") # e.g. https://yourname-spacename.hf.space
68
- FILE_EXPIRE_MINUTES = int(os.getenv("FILE_EXPIRE_MINUTES", "0")) # 0 = never expire
 
 
 
 
 
69
 
70
  # ============================================================
71
  # FileManager
@@ -306,4 +316,4 @@ async def telegram_webhook(request: Request):
306
  "📎 **Please send a file, photo, video or audio.**\n"
307
  "I'll generate a public link for it!"))
308
 
309
- return JSONResponse({"status": "ok"})
 
46
  def LOGGER(name: str) -> logging.Logger:
47
  return logging.getLogger(name)
48
 
 
49
  # Config
50
  # ============================================================
51
  try:
 
54
  except Exception:
55
  pass
56
 
57
+ # Debug: show what env vars are actually received
58
+ print(f"[config] API_ID = {os.getenv('API_ID', 'NOT SET')}")
59
+ print(f"[config] API_HASH = {'SET' if os.getenv('API_HASH') else 'NOT SET'}")
60
+ print(f"[config] BOT_TOKEN = {'SET' if os.getenv('BOT_TOKEN') else 'NOT SET'}")
61
+ print(f"[config] SPACE_URL = {os.getenv('SPACE_URL', 'NOT SET')}")
62
+
63
  _required = ["BOT_TOKEN", "API_ID", "API_HASH", "SPACE_URL"]
64
  _missing = [v for v in _required if not os.getenv(v)]
65
  if _missing:
66
  print(f"ERROR: Missing required env vars: {', '.join(_missing)}")
67
  sys.exit(1)
68
 
69
+ try:
70
+ API_ID = int(os.getenv("API_ID"))
71
+ except (TypeError, ValueError):
72
+ print(f"ERROR: API_ID must be a plain integer, got: {os.getenv('API_ID')!r}")
73
+ sys.exit(1)
74
+
75
+ API_HASH = os.getenv("API_HASH").strip()
76
+ BOT_TOKEN = os.getenv("BOT_TOKEN").strip()
77
+ SPACE_URL = os.getenv("SPACE_URL").strip()
78
+ FILE_EXPIRE_MINUTES = int(os.getenv("FILE_EXPIRE_MINUTES", "0"))
79
 
80
  # ============================================================
81
  # FileManager
 
316
  "📎 **Please send a file, photo, video or audio.**\n"
317
  "I'll generate a public link for it!"))
318
 
319
+ return JSONResponse({"status": "ok"})