forked from GreyMatter658/StringSessionBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.py
32 lines (27 loc) · 874 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
31
32
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()
MUST_JOIN = os.getenv("MUST_JOIN", "")
if not API_ID:
print("No API_ID found. Exiting...")
raise SystemExit
if not API_HASH:
print("No API_HASH found. Exiting...")
raise SystemExit
if not BOT_TOKEN:
print("No BOT_TOKEN found. Exiting...")
raise SystemExit
if not DATABASE_URL:
print("No DATABASE_URL found. Exiting...")
raise SystemExit
try:
API_ID = int(API_ID)
except ValueError:
print("API_ID is not a valid integer. Exiting...")
raise SystemExit
if 'postgres' in DATABASE_URL and 'postgresql' not in DATABASE_URL:
DATABASE_URL = DATABASE_URL.replace("postgres", "postgresql")