Пример #1
0
if not API_KEY and not API_HASH and not STRING_SESSION:
    if not check_secure_config():
        log.error("Cannot continue to start HyperUBot. "
                  "You may need to create a (new) secure config first.")
    quit(1)

try:
    load_configs(SAFEMODE)  # optional configs
except KeyboardInterrupt:
    log.info("Exiting...")
    quit()
except Exception:
    log.error("Unable to load optional configurations", exc_info=True)

if SAFEMODE and not getConfig("UBOT_LANG"):
    addConfig("UBOT_LANG", "en")

if not getConfig("TEMP_DL_DIR"):
    addConfig("TEMP_DL_DIR", path.join(".", "downloads"))

log.info("Configurations loaded")

try:
    if getConfig("USERDATA") and not path.exists(getConfig("USERDATA")):
        mkdir(getConfig("USERDATA"))
except Exception:
    log.error("Failed to initialize user data directory")

try:
    if not path.exists(getConfig("TEMP_DL_DIR")):
        mkdir(getConfig("TEMP_DL_DIR"))
Пример #2
0
else:
    log.info("Loading configurations")

if path.exists(path.join(".", "userbot", "config.env")):
    from userbot.include.aux_funcs import strlist_to_list, str_to_bool
    len_before = len(environ.items())
    load_dotenv(path.join(".", "userbot", "config.env"))
    loaded_env = {
        key: value
        for key, value in list(environ.items())[len_before:]
    }
    if not SAFEMODE:
        for key, value in loaded_env.items():
            if not key in ("API_KEY", "API_HASH", "STRING_SESSION"):
                if value.startswith("[") and value.endswith("]"):
                    addConfig(key, strlist_to_list(value))
                elif value in ("True", "true", "False", "false"):
                    addConfig(key, str_to_bool(value))
                else:  # default case
                    addConfig(key, int(value) if value.isnumeric() else value)
    if getConfig("SAMPLE_CONFIG", None):
        log.error("Please remove SAMPLE_CONFIG from config.env!")
        quit(1)
    API_KEY = environ.get("API_KEY", None)
    API_HASH = environ.get("API_HASH", None)
    STRING_SESSION = environ.get("STRING_SESSION", None)
    if SAFEMODE:
        addConfig("UBOT_LANG", loaded_env.get("UBOT_LANG", "en"))
    environ["API_KEY"] = "0"
    environ["API_HASH"] = "None"
    environ["STRING_SESSION"] = "None"
Пример #3
0
if path.exists(CURR_PATH + "config.env"):
    len_before = len(environ.items())
    load_dotenv(CURR_PATH + "config.env")
    loaded_env = {
        key: value
        for key, value in list(environ.items())[len_before:]
    }
    for key, value in loaded_env.items():
        if not key in ("API_KEY", "API_HASH", "STRING_SESSION"):
            if key == "TEMP_DL_DIR":
                if OS and OS.lower().startswith("win"):
                    value += "\\"
                else:
                    value += "/"
            if value.startswith("[") and value.endswith("]"):
                addConfig(key, strlist_to_list(value))
            elif value in ("True", "true", "False", "false"):
                addConfig(key, str_to_bool(value))
            else:  # default case
                addConfig(key, int(value) if value.isnumeric() else value)
    if getConfig("SAMPLE_CONFIG", None):
        log.error("Please remove SAMPLE_CONFIG from config.env!")
        quit(1)
    API_KEY = environ.get("API_KEY", None)
    API_HASH = environ.get("API_HASH", None)
    STRING_SESSION = environ.get("STRING_SESSION", None)
    environ["API_KEY"] = "0"
    environ["API_HASH"] = "None"
    environ["STRING_SESSION"] = "None"
    del loaded_env
elif path.exists(CURR_PATH + "config.py"):