feat(go-services): discord-go — Go port of discord-rare-monitor

Consumes the Python tracker's /ws/live firehose (subscribed to rare+chat),
classifies rares common/great, posts embeds + relays allegiance chat.

- classify.go: the 74-name common-rares set, extracted verbatim from the Python
  COMMON_RARES_PATTERN (not hand-transcribed). go test runs at build time; a
  server-side dump-rares vs the Python regex confirms the sets are IDENTICAL.
- poster.go: a `poster` interface with a real discordgo impl (REST sends by
  channel id; gold/blue embeds, location/time fields, icon attachment) and a
  dry-run log impl.
- ws.go: coder/websocket client to /ws/live with subscribe, ping keepalive,
  exponential-backoff reconnect; rare/chat dispatch incl. vortex-warning + the
  MONITOR_CHARACTER filter.
- SAFE BY DEFAULT: dry-run unless a token AND DRY_RUN=0 are set, so it can never
  double-post to production. Deployed via the compose override
  (discord-rare-monitor-go), running dry-run against the same live firehose.

Validated on the server: connects, subscribes, relays a real chat in dry-run;
classifier parity 74/74 vs the Python regex.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-24 10:06:59 +02:00
parent 426fe025d3
commit 8d4c6ff68f
8 changed files with 593 additions and 0 deletions

View file

@ -42,3 +42,33 @@ services:
options:
max-size: "10m"
max-file: "3"
# Go port of discord-rare-monitor. Consumes the SAME Python /ws/live firehose
# as the live Python bot. DRY-RUN by default (logs classifications, posts
# nothing) so it can't double-post. To parallel-test for real, set a TEST
# DISCORD_RARE_BOT_TOKEN + TEST channel IDs + DRY_RUN=0 here.
discord-rare-monitor-go:
build:
context: ./go-services/discord-go
args:
BUILD_VERSION: ${BUILD_VERSION:-dev}
container_name: discord-rare-monitor-go
environment:
DERETH_TRACKER_WS_URL: "ws://dereth-tracker:8765/ws/live"
MONITOR_CHARACTER: "Dunking Rares"
ICONS_DIR: "/icons"
LOG_LEVEL: "INFO"
# DISCORD_RARE_BOT_TOKEN: "" # set a TEST token to go live
# DRY_RUN: "0" # required (with a token) to actually post
# COMMON_RARE_CHANNEL_ID / GREAT_RARE_CHANNEL_ID / SAWATOLIFE_CHANNEL_ID /
# ACLOG_CHANNEL_ID: set TEST channels before going live
volumes:
- ./discord-rare-monitor/icons:/icons:ro
depends_on:
- dereth-tracker
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"