diff --git a/Config.py b/Config.py index 6d03ba1..dc1e8cb 100644 --- a/Config.py +++ b/Config.py @@ -1,4 +1,8 @@ import yaml +from yaml.parser import ParserError +from rich import print + +from Exceptions.InvalidCredentialsException import InvalidCredentialsException class Config: @@ -18,16 +22,33 @@ def __init__(self, configPath: str) -> None: with open(configPath, "r", encoding='utf-8') as f: config = yaml.safe_load(f) accs = config.get("accounts") + onlyDefaultUsername = True for account in accs: self.accounts[account] = { "username": accs[account]["username"], "password": accs[account]["password"], } + if "username" != accs[account]["username"]: + onlyDefaultUsername = False + if onlyDefaultUsername: + raise InvalidCredentialsException self.debug = config.get("debug", False) self.connectorDrops = config.get("connectorDropsUrl", "") except FileNotFoundError as ex: - print(f"ERROR: The configuration file cannot be found at {configPath}") + print(f"[red]CRITICAL ERROR: The configuration file cannot be found at {configPath}\nHave you extacted the ZIP archive and edited the configuration file?") + print("Press any key to exit...") + input() + raise ex + except (ParserError, KeyError) as ex: + print(f"[red]CRITICAL ERROR: The configuration file does not have a valid format.\nPlease, check it for extra spaces and other characters.\nAlternatively, use confighelper.html to generate a new one.") + print("Press any key to exit...") + input() + raise ex + except InvalidCredentialsException as ex: + print(f"[red]CRITICAL ERROR: There are only default credentials in the configuration file.\nYou need to add you Riot account login to config.yaml to receive drops.") + print("Press any key to exit...") + input() raise ex with open("bestStreams.txt", "r", encoding='utf-8') as f: diff --git a/Exceptions/InvalidCredentialsException.py b/Exceptions/InvalidCredentialsException.py new file mode 100644 index 0000000..6154e6b --- /dev/null +++ b/Exceptions/InvalidCredentialsException.py @@ -0,0 +1,5 @@ +from Exceptions.CapsuleFarmerEvolvedException import CapsuleFarmerEvolvedException + +class InvalidCredentialsException(CapsuleFarmerEvolvedException): + def __init__(self): + super().__init__(f"Invalid account credentials.") \ No newline at end of file