generated from alex/base-template
Improve horse facts ux #17
Labels
No labels
dependencies
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
alex/irc-greeter-bot#17
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
So far is pretty boring and repeating.
Search the web to find out if we can source from an API or web service instead of our static list.
/pi new pr
Let me look at the remaining test files and check whether I have network access to research APIs.Now let me check whether I have network access to research available horse facts APIs.I have network access. Let me research horse facts APIs more and read the storage modules to match conventions.I have network access and have completed my research. Let me verify one more API shape (the JSON response formats) so my implementation is accurate.My research is complete. Here's what I found:
horsefacts.orgis a parked landing page (404 on/api).catfact.ninja/fact→{"fact":"..."}anduselessfacts.jsph.pl/.../random→{"text":"..."}— neither is horse-specific.Given the bot's resilience-first design, I'll implement: (1) a non-repeating shuffle-deck so facts stop repeating, (2) a much larger curated list, and (3) an optional API-backed source with graceful fallback to the curated deck. Let me build it.Now the persistence store for the deck state:Now let me add the config for the optional API source and store path:Now let me update
main.tsto wire the deck and optional API provider:Now let me add thecreateFactProviderhelper tomain.ts. Let me place it nearbroadcastFact:Now let me update the existingbroadcastFacttest for the new async signature:Now let me updatefacts_test.ts— the data-integrity tests still apply, and I'll add thorough tests forshuffle,FactDeck, andfetchApiFact:Now let me create thefact-store_test.ts:Now let me add config tests for the newfactssettings:Now let me update the.env.exampleand README. First let me check the current Deno version and run the tests:FactsSettingslives inconfig.ts, notfacts.ts. Let me fix the import inmain.ts:The reconciliation test over-drew (crossing a cycle boundary). Let me fix it to assert only what reconciliation actually guarantees:All 180 tests pass. Now let me run the linter, formatter, type check, and Fallow static analysis:Type check passes. Let me fix the unused import:Lint is clean. Now let me run Fallow (dead-code analysis) and verify formatting:Fallow found issues. SinceHORSE_FACTSis now actually consumed bymain.ts, its suppression is stale. AndpickRandomFactis now dead code (superseded byFactDeck). Let me clean these up: removepickRandomFactand fix the suppressions.Now remove thepickRandomFactimport and its tests fromfacts_test.ts:Let me re-read the current state of the test file to make precise edits:The trailing prose in the suppression comment confused Fallow's parser. Let me use the exact recognized form:Fallow is clean. Now let me run the full test suite once more to confirm everything passes:All tests pass. Now let me update the documentation —.env.exampleand the README:I accidentally removed the feeds section. Let me restore it after the new facts section:Now let me update the README — the config table and the "Daily horse facts" section:Now let me update the "Daily horse facts" section in the README to describe the new behavior:Let me update the project structure section in the README to mention the new file:Now let me run the full check suite once more (fmt, lint, check, test, fallow) to make sure everything is green:The README needs formatting. Let me apply fmt:Everything is green. Let me do a final review of the complete diff:Let me verify the new untracked files are included and review the final config wiring:Let me verify the final main.ts wiring:All wiring looks correct. Let me run one final comprehensive check to confirm a clean state before creating the PR:All green: fmt, lint, type-check, 176 tests, and Fallow dead-code analysis all pass. Now let me create the PR:PR #18 created. Here's a summary of what I did to address issue #17 ("Improve horse facts ux — boring and repeating"):Research findings
I searched for a horse facts API and found none exists that's reliable and horse-specific —
horsefacts.orgis a parked page, and the only free, key-less options are generic trivia (catfact.ninja,uselessfacts.jsph.pl). So I kept the curated list as the resilient default and made an API an opt-in layer, consistent with how RSS feeds already work in this bot.The fix (3 parts)
No more repeats — facts now come from a shuffle bag (
FactDeck): the bot cycles through the entire list before any fact repeats. The state is persisted tofact-deck.json, so restarts/redeploys never repeat a just-shown fact. This is the direct fix for "repeating."~70 verified facts (up from ~30) — keeps things fresh for months.
Optional API source —
IRC_FACTS_API_URLtries a JSON endpoint ({"fact"}/{"text"}) first each day and silently falls back to the deck on any failure, so the channel always gets a fact and a flaky API can never break the feature.Quality
All CI gates pass:
deno fmt,deno lint,deno check, 176 tests (≈30 new), and Fallow dead-code analysis (clean). The unusedpickRandomFactwas removed rather than suppressed, and the new modules (fact-store.ts) follow the existing store/persistence conventions.View action run | Model: zai/glm-5.2 (thinking: max) | Time: 18m 17s | Tokens: 3.2M | Pi SDK v0.81.1 | Action v2.26.0-develop (develop @ 4387e26)