Verified Commit 99101d26 authored by Mroik's avatar Mroik
Browse files

Added env var checking

parent 7dc161a9
from os import environ
from sys import exit
import logging
LOGGER = logging.getLogger(__name__)
SERVER = environ.get("BITS_SERVER")
PORT = int(environ.get("BITS_PORT", default=1883))
USERNAME = environ.get("BITS_USER")
PASSWORD = environ.get("BITS_PASSWORD", default="")
TG_KEY = environ.get("BITS_TG_KEY", default="")
PASSWORD = environ.get("BITS_PASSWORD")
TG_KEY = environ.get("BITS_TG_KEY")
ADMIN_CHANNELS_FULL = [] # Channels that are allowed to change HQ's status
ADMIN_CHANNELS_PRIV = [] # Channels that are allowed to change HQ's status
DEBUG = environ.get("DEBUG", default=None)
for chan in environ.get("BITS_TG_GROUPS_FULL", default="").split(":"):
if chan == "":
continue
ADMIN_CHANNELS_FULL.append(chan)
for chan in environ.get("BITS_TG_GROUPS_PRIV", default="").split(":"):
if chan == "":
continue
ADMIN_CHANNELS_PRIV.append(chan)
if SERVER is None:
LOGGER.critical("An IP for the mqtt broker must be specified")
exit()
if USERNAME is None or PASSWORD is None:
LOGGER.critical("Credentials for both username and password are unspecified")
exit()
if TG_KEY is None:
LOGGER.critical("The token for the telegrambot is unspecified")
exit()
if len(ADMIN_CHANNELS_PRIV) == 0 and len(ADMIN_CHANNELS_FULL) == 0:
LOGGER.critical("Atleast 1 admin channel must be given")
exit()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment