update helps and commands (#1288)
This commit is contained in:
+11
-22
@@ -1,8 +1,8 @@
|
||||
"""TSSBOT autolog matcher.
|
||||
|
||||
For each game received from the Spectra TSS feed, match it against every
|
||||
subscribing guild's preferences (``tss-team`` / ``tss-player`` entries) and
|
||||
work out which channels should be notified, deduping per session.
|
||||
subscribing guild's ``tss-team`` preference entries and work out which channels
|
||||
should be notified, deduping per session.
|
||||
|
||||
NOTE: building and sending the scoreboard embed is intentionally a TODO for now
|
||||
(it needs significant rework). The matching + dedup pipeline below is complete
|
||||
@@ -33,10 +33,9 @@ def set_bot(bot: discord.Client) -> None:
|
||||
_bot = bot
|
||||
|
||||
|
||||
def _present_entities(game: dict[str, Any]) -> tuple[set[str], set[str]]:
|
||||
"""Return (player_uids, team_tags) present in a game dict."""
|
||||
def _present_team_tags(game: dict[str, Any]) -> set[str]:
|
||||
"""Return the set of team tags present in a game dict."""
|
||||
players = game.get("players") or {}
|
||||
uids = {str(k) for k in players}
|
||||
tags: set[str] = set()
|
||||
for p in players.values():
|
||||
if not isinstance(p, dict):
|
||||
@@ -45,7 +44,7 @@ def _present_entities(game: dict[str, Any]) -> tuple[set[str], set[str]]:
|
||||
tag = tag_raw[1:-1] if len(tag_raw) > 2 else tag_raw
|
||||
if tag:
|
||||
tags.add(tag)
|
||||
return uids, tags
|
||||
return tags
|
||||
|
||||
|
||||
async def process_game(game: dict[str, Any]) -> None:
|
||||
@@ -60,7 +59,7 @@ async def process_game(game: dict[str, Any]) -> None:
|
||||
if not session_id:
|
||||
return
|
||||
|
||||
present_uids, present_tags = _present_entities(game)
|
||||
present_tags = _present_team_tags(game)
|
||||
tags_lower = {t.lower() for t in present_tags}
|
||||
|
||||
# Resolve present tags → team_ids so team subscriptions (keyed by team_id) match.
|
||||
@@ -78,24 +77,14 @@ async def process_game(game: dict[str, Any]) -> None:
|
||||
|
||||
for guild_id, prefs in preferences.iter_guild_preferences():
|
||||
for entity_id, entry in prefs.items():
|
||||
if not isinstance(entry, dict):
|
||||
if not isinstance(entry, dict) or entry.get("Type") != "tss-team":
|
||||
continue
|
||||
channel_id, enabled = preferences.parse_channel(entry.get("Logs"))
|
||||
if not channel_id or not enabled:
|
||||
continue
|
||||
|
||||
etype = entry.get("Type")
|
||||
matched = False
|
||||
if etype == "tss-team":
|
||||
if str(entity_id) in present_team_ids:
|
||||
matched = True
|
||||
else:
|
||||
name = (entry.get("Name") or "").lower()
|
||||
if name and name in tags_lower:
|
||||
matched = True
|
||||
elif etype == "tss-player":
|
||||
if str(entity_id) in present_uids:
|
||||
matched = True
|
||||
name = (entry.get("Name") or "").lower()
|
||||
matched = str(entity_id) in present_team_ids or (name and name in tags_lower)
|
||||
|
||||
if not matched or channel_id in sent:
|
||||
continue
|
||||
@@ -105,6 +94,6 @@ async def process_game(game: dict[str, Any]) -> None:
|
||||
# The matched target is fully resolved here; the only thing missing
|
||||
# is the rendered scoreboard (out of scope for now).
|
||||
log.info(
|
||||
"autolog match (send TODO): session=%s guild=%s channel=%s entity=%s type=%s",
|
||||
session_id, guild_id, channel_id, entity_id, etype,
|
||||
"autolog match (send TODO): session=%s guild=%s channel=%s team=%s",
|
||||
session_id, guild_id, channel_id, entity_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user