print traceback for config errors

This commit is contained in:
odysseusmax 2020-08-13 04:05:46 +00:00
parent 8ae8df2323
commit 0085a117d6
1 changed files with 10 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import traceback
import sys import sys
import os import os
@ -14,23 +15,26 @@ try:
api_id = int(os.environ["API_ID"]) api_id = int(os.environ["API_ID"])
api_hash = os.environ["API_HASH"] api_hash = os.environ["API_HASH"]
except (KeyError, ValueError): except (KeyError, ValueError):
print("Please set the API_ID and API_HASH environment variables correctly") traceback.print_exc()
print("\n\nPlease set the API_ID and API_HASH environment variables correctly")
print("You can get your own API keys at https://my.telegram.org/apps") print("You can get your own API keys at https://my.telegram.org/apps")
sys.exit(1) sys.exit(1)
try: try:
chat_id_raw = os.environ["CHAT_ID"] chat_id_raw = os.environ["CHAT_ID"].strip()
chat_ids = [int(chat_id) for chat_id in chat_id_raw.split(' ')] chat_ids = [int(chat_id.strip()) for chat_id in chat_id_raw.split(' ')]
alias_ids = [] alias_ids = []
except (KeyError, ValueError): except (KeyError, ValueError):
print("Please set the CHAT_ID environment variable correctly") traceback.print_exc()
print("\n\nPlease set the CHAT_ID environment variable correctly")
sys.exit(1) sys.exit(1)
try: try:
session_string = os.environ["SESSION_STRING"] session_string = os.environ["SESSION_STRING"]
except (KeyError, ValueError): except (KeyError, ValueError):
print("Please set the SESSION_STRING environment variable correctly") traceback.print_exc()
print("\n\nPlease set the SESSION_STRING environment variable correctly")
sys.exit(1) sys.exit(1)
host = os.environ.get("HOST", "0.0.0.0") host = os.environ.get("HOST", "0.0.0.0")
debug = bool(os.environ.get("DEBUG")) debug = True