fix(config): add fallback values for Matrix config checks

Added fallback values for Matrix 'Password' and 'UserID' config checks to prevent exceptions when these keys are not present. This ensures smoother handling of missing configurations.
This commit is contained in:
Kumi 2024-08-18 10:50:27 +02:00
parent 99d3974e17
commit 525aea3f05
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -241,8 +241,8 @@ class GPTBot:
homeserver = config["Matrix"]["Homeserver"] homeserver = config["Matrix"]["Homeserver"]
if config.get("Matrix", "Password"): if config.get("Matrix", "Password", fallback=""):
if not config.get("Matrix", "UserID"): if not config.get("Matrix", "UserID", fallback=""):
raise Exception("Cannot log in: UserID not set in config") raise Exception("Cannot log in: UserID not set in config")
bot.matrix_client = AsyncClient(homeserver, user=config["Matrix"]["UserID"]) bot.matrix_client = AsyncClient(homeserver, user=config["Matrix"]["UserID"])