TelegramIndex-Fork/app/config.py

41 lines
1.1 KiB
Python
Raw Normal View History

2020-08-13 06:05:46 +02:00
import traceback
2020-08-10 09:27:52 +02:00
import sys
import os
try:
port = int(os.environ.get("PORT", "8080"))
except ValueError:
port = -1
if not 1 <= port <= 65535:
print("Please make sure the PORT environment variable is an integer between 1 and 65535")
sys.exit(1)
try:
api_id = int(os.environ["API_ID"])
api_hash = os.environ["API_HASH"]
except (KeyError, ValueError):
2020-08-13 06:05:46 +02:00
traceback.print_exc()
print("\n\nPlease set the API_ID and API_HASH environment variables correctly")
2020-08-10 09:27:52 +02:00
print("You can get your own API keys at https://my.telegram.org/apps")
sys.exit(1)
try:
2020-08-13 06:05:46 +02:00
chat_id_raw = os.environ["CHAT_ID"].strip()
chat_ids = [int(chat_id.strip()) for chat_id in chat_id_raw.split(' ')]
2020-08-13 05:58:55 +02:00
alias_ids = []
2020-08-10 09:27:52 +02:00
except (KeyError, ValueError):
2020-08-13 06:05:46 +02:00
traceback.print_exc()
print("\n\nPlease set the CHAT_ID environment variable correctly")
2020-08-10 09:27:52 +02:00
sys.exit(1)
try:
session_string = os.environ["SESSION_STRING"]
except (KeyError, ValueError):
2020-08-13 06:05:46 +02:00
traceback.print_exc()
print("\n\nPlease set the SESSION_STRING environment variable correctly")
2020-08-10 09:27:52 +02:00
sys.exit(1)
host = os.environ.get("HOST", "0.0.0.0")
2020-08-13 06:07:18 +02:00
debug = bool(os.environ.get("DEBUG"))