Skip to content

Commit

Permalink
Fix settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Jun 18, 2024
1 parent 04b4177 commit 35e5aab
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class Config: # noqa: WPS431

@validator("BOT_CREDENTIALS", pre=True)
@classmethod
def parse_bot_credentials(cls, raw_credentials: Any) -> list[BotAccountWithSecret]:
def parse_bot_credentials(cls, raw_credentials: str) -> list[BotAccountWithSecret]:
"""Parse bot credentials separated by comma.
Each entry must be separated by "@" or "|".
"""
print(raw_credentials)
if not raw_credentials:
raise ValueError("`BOT_CREDENTIALS` can't be empty")

Expand All @@ -40,10 +41,16 @@ def _build_credentials_from_string(
credentials_str = credentials_str.replace("|", "@")
assert credentials_str.count("@") == 2, "Have you forgot to add `bot_id`?"

host, secret_key, bot_id = [
cts_url, secret_key, bot_id = [
str_value.strip() for str_value in credentials_str.split("@")
]
return BotAccountWithSecret(id=UUID(bot_id), host=host, secret_key=secret_key)

if "://" not in cts_url:
cts_url = f"https://{cts_url}"

return BotAccountWithSecret(
id=UUID(bot_id), cts_url=cts_url, secret_key=secret_key
)


settings = AppSettings()

0 comments on commit 35e5aab

Please sign in to comment.