forked from sass/tipibot
CS2 team dividers.
This commit is contained in:
30
config.py
30
config.py
@@ -69,6 +69,36 @@ def _parse_admin_roles(raw: str) -> dict[int, set[int]]:
|
||||
|
||||
BOT_ADMIN_ROLES: dict[int, set[int]] = _parse_admin_roles(os.getenv("DISCORD_ADMIN_ROLES", ""))
|
||||
|
||||
_TEAM_DIVIDER_PREFIX = "TEAM_DIVIDER_"
|
||||
|
||||
|
||||
def _parse_team_dividers() -> dict[str, str]:
|
||||
"""Collect TEAM_DIVIDER_<SUFFIX> env vars into {suffix: divider role name}.
|
||||
|
||||
The suffix says which sheet sections the divider covers, the value is the
|
||||
exact Discord role name their teams get positioned under:
|
||||
|
||||
TEAM_DIVIDER_CS2_2026="====== COUNTER-STRIKE 2 2026 ======"
|
||||
|
||||
Every underscore-separated part of the suffix must appear in the section's
|
||||
title row, so `CS2_2026` matches only "TipiLAN 2026 CS2 Registration Log"
|
||||
while a plain `CS2` would match that section in any year. Defining a var is
|
||||
what switches positioning on for those sections; teams whose section matches
|
||||
nothing are still granted their role, just never moved.
|
||||
"""
|
||||
dividers: dict[str, str] = {}
|
||||
for key, value in os.environ.items():
|
||||
if not key.startswith(_TEAM_DIVIDER_PREFIX):
|
||||
continue
|
||||
suffix = key[len(_TEAM_DIVIDER_PREFIX):].strip().lower()
|
||||
name = value.strip()
|
||||
if suffix and name:
|
||||
dividers[suffix] = name
|
||||
return dividers
|
||||
|
||||
|
||||
TEAM_DIVIDERS: dict[str, str] = _parse_team_dividers()
|
||||
|
||||
PB_URL = os.getenv("PB_URL", "http://127.0.0.1:8090")
|
||||
PB_ADMIN_EMAIL = os.getenv("PB_ADMIN_EMAIL", "")
|
||||
PB_ADMIN_PASSWORD = os.getenv("PB_ADMIN_PASSWORD", "")
|
||||
|
||||
Reference in New Issue
Block a user