forked from sass/tipibot
Merge branch 'master' of ssh://git.lapikud.ee:202/renkar/tipibot
# Conflicts: # bot.py
This commit is contained in:
@@ -19,7 +19,7 @@ The codebase is split into **`core/`** (domain logic), **`commands/`** (Discord
|
||||
| `core/economy/` | Economy business logic **package**, re-exported via `core/economy/__init__.py` so callers use `from core import economy` + attribute access (`economy.do_daily`, `economy.SHOP`, ...). Submodules: `store.py` (user records, per-user locks, `COOLDOWNS`, `ITEM_COOLDOWNS`/`effective_cooldown`, `JAIL_DURATION`, `COIN`, `get_user`/`_commit`/`_txn`, `pending_wager` escrow + `reconcile_pending_wagers`), `income.py`, `gambling.py`, `fishing.py`, `jail.py`, `heist.py`, `prestige.py`, `shop.py`, `consumables.py` (timed buffs + `grant_buff`), `vanity.py` (cosmetic badges), `lootbox.py` (mystery box), `bank.py` (rob-proof vault), `achievements.py` (milestone badges), `lottery.py` (daily draw), `levels.py`, `quests.py`, `leaderboards.py` (incl. `get_all_leaderboards`/`get_economy_stats`, net-worth = balance+bank), `house.py`, `admin.py` |
|
||||
| `core/pb_client.py` | Async PocketBase REST client - auth token cache, CRUD on `economy_users` collection |
|
||||
| `core/sheets.py` | Google Sheets integration (member sync) |
|
||||
| `core/member_sync.py` | Birthday/member sync helpers |
|
||||
| `core/member_sync.py` | Birthday/member sync helpers, plus tournament team-role sync + divider placement |
|
||||
|
||||
### `commands/` - one slash-command group per file
|
||||
|
||||
@@ -148,6 +148,37 @@ Gambling EXP is bet-scaled via `gamble_exp(bet)`; fish EXP is per-species in `FI
|
||||
|
||||
---
|
||||
|
||||
## Tournament Team Roles
|
||||
|
||||
Economy profile only. Roster-independent: matches Discord usernames straight against `TEAM_SHEET_ID`, never the member sheet. Entry points are `/teamsync` (`commands/economy_team_commands.py`) and the hourly `team_sync_hourly` task in `bot.py`; both call `sheets.refresh_teams()` then `member_sync.sync_all_team_roles()`.
|
||||
|
||||
### Pipeline
|
||||
|
||||
| Step | Where | Notes |
|
||||
|---|---|---|
|
||||
| Split a tab into per-game blocks | `sheets.parse_team_sections` | Returns `TeamSection(title, rosters)`. The merged title row above each header is the **only** thing identifying game + year |
|
||||
| Flatten to `{team: [players]}` | `sheets.parse_team_rosters` | Thin wrapper over `parse_team_sections` |
|
||||
| Section title → divider role name | `sheets.resolve_divider` | Matches `config.TEAM_DIVIDERS`; most specific key wins |
|
||||
| Cache | `sheets._refresh_teams_sync` | Populates `_team_roster`, `_team_by_username`, `_team_names`, `_team_divider` |
|
||||
| Grant/remove roles per member | `member_sync.sync_team_role` | Only names in `all_team_names()` are ever touched |
|
||||
| Compute new role positions | `member_sync.plan_team_positions` | **Pure** - list of names ascending + managed set + placements → `{name: new position}`. Unit-tested without Discord |
|
||||
| Apply | `member_sync.apply_team_role_positions` | One `guild.edit_role_positions` call per sync |
|
||||
|
||||
### Adding a game to the divider config
|
||||
|
||||
1. `.env` - add `TEAM_DIVIDER_<GAME>_<YEAR>="<exact Discord role name>"`. No code change; `config._parse_team_dividers` discovers any var with that prefix at startup.
|
||||
2. Restart the bot (env is read once at import).
|
||||
|
||||
### Position maths gotchas
|
||||
|
||||
- Discord positions are **ascending from the bottom** (`@everyone` = 0), so "under the divider in the UI" means a *lower* number. `plan_team_positions` therefore inserts each block reverse-sorted.
|
||||
- The bot can only reorder roles strictly below its own highest role. Dividers at or above it are skipped with an error rather than attempted.
|
||||
- `managed` roles (integration/bot/booster) are never emitted in the plan.
|
||||
- Roles are matched **by name** throughout the feature; with duplicate names the lowest-positioned one wins.
|
||||
- Only roles whose position actually changed are submitted, so a settled guild costs zero API calls.
|
||||
|
||||
---
|
||||
|
||||
## Role Hierarchy (Discord)
|
||||
|
||||
Order top to bottom in server roles:
|
||||
|
||||
Reference in New Issue
Block a user