-
Notifications
You must be signed in to change notification settings - Fork 360
/
env.py
30 lines (25 loc) · 910 Bytes
/
env.py
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
import os
from dotenv import load_dotenv
load_dotenv()
API_ID = os.getenv("API_ID", "").strip()
API_HASH = os.getenv("API_HASH", "").strip()
BOT_TOKEN = os.getenv("BOT_TOKEN", "").strip()
DATABASE_URL = os.getenv("DATABASE_URL", "").strip() # Not a necessary variable anymore but you can add to get stats
MUST_JOIN = os.getenv("MUST_JOIN", "")
if not API_ID:
raise SystemExit("No API_ID found. Exiting...")
elif not API_HASH:
raise SystemExit("No API_HASH found. Exiting...")
elif not BOT_TOKEN:
raise SystemExit("No BOT_TOKEN found. Exiting...")
'''
if not DATABASE_URL:
print("No DATABASE_URL found. Exiting...")
raise SystemExit
'''
try:
API_ID = int(API_ID)
except ValueError:
raise SystemExit("API_ID is not a valid integer. Exiting...")
if 'postgres' in DATABASE_URL and 'postgresql' not in DATABASE_URL:
DATABASE_URL = DATABASE_URL.replace("postgres", "postgresql")