Merge branch 'master' of ssh://git.lapikud.ee:202/renkar/tipibot
# Conflicts: # bot.py
This commit is contained in:
47
config.py
47
config.py
@@ -23,8 +23,18 @@ DISCORD_TOKEN = (
|
||||
) or _LEGACY_DISCORD_TOKEN
|
||||
|
||||
SHEET_ID = os.getenv("SHEET_ID")
|
||||
# Separate spreadsheet holding the tournament team registrations (Team Name +
|
||||
# lineup of Discord usernames). Optional: when unset, team-role sync is a no-op.
|
||||
TEAM_SHEET_ID = os.getenv("TEAM_SHEET_ID")
|
||||
GOOGLE_CREDS_PATH = os.getenv("GOOGLE_CREDS_PATH", "credentials.json")
|
||||
|
||||
# Fienta ticketing: the registration collects each competitor's Discord username
|
||||
# (+ sometimes Discord user ID) and team name per ticket, giving a reliable
|
||||
# Discord-identity -> team mapping the nickname-only sheet cannot. Primary source
|
||||
# for team-role sync; the sheet stays as a fallback. Unset -> Fienta is skipped.
|
||||
FIENTA_API_TOKEN = os.getenv("FIENTA_API_TOKEN", "")
|
||||
FIENTA_EVENT_ID = os.getenv("FIENTA_EVENT_ID", "")
|
||||
|
||||
_LEGACY_GUILD_ID = _env_int("GUILD_ID", 0)
|
||||
GUILD_ID_DEV = _env_int("GUILD_ID_DEV", _LEGACY_GUILD_ID)
|
||||
GUILD_ID_ECONOMY = _env_int("GUILD_ID_ECONOMY", _LEGACY_GUILD_ID)
|
||||
@@ -75,6 +85,43 @@ 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, int]:
|
||||
"""Collect TEAM_DIVIDER_<SUFFIX> env vars into {suffix: divider role ID}.
|
||||
|
||||
The suffix says which sheet sections the divider covers, the value is the
|
||||
Discord role ID their teams get positioned under:
|
||||
|
||||
TEAM_DIVIDER_CS2_2026=1498736834656604251
|
||||
|
||||
Matching by ID (not name) means renaming the divider role in Discord never
|
||||
breaks positioning. 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, int] = {}
|
||||
for key, value in os.environ.items():
|
||||
if not key.startswith(_TEAM_DIVIDER_PREFIX):
|
||||
continue
|
||||
suffix = key[len(_TEAM_DIVIDER_PREFIX):].strip().lower()
|
||||
raw = value.strip()
|
||||
if not suffix or not raw:
|
||||
continue
|
||||
try:
|
||||
dividers[suffix] = int(raw)
|
||||
except ValueError:
|
||||
raise SystemExit(
|
||||
f"{key}: expected a Discord role ID (integer), got {raw!r}"
|
||||
)
|
||||
return dividers
|
||||
|
||||
|
||||
TEAM_DIVIDERS: dict[str, int] = _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