generated from alex/base-template
feat: add disk storage for already-greeted nicks #2
No reviewers
Labels
No labels
dependencies
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
alex/irc-greeter-bot!2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "pi/issue1-1783972974060"
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?
Closes #1.
Summary
Adds a simple disk-backed store that keeps track of nicks the bot has already greeted, so the same person is not re-greeted — even after a restart.
Changes
src/storage.ts(new) —GreetedNicksStoreclass backed by a JSON file. Loads nicks into an in-memorySeton startup, and persists each newly greeted nick to disk. Uses Deno's built-in file I/O (Deno.readTextFile/Deno.writeTextFile) — no external dependencies.src/storage_test.ts(new) — 8 unit tests covering: empty start, load from disk, persist on add, no-op for existing nicks, preservation of old nicks, non-string entry filtering, and error handling for malformed/non-array JSON.src/config.ts— added optionalIRC_STORE_PATHconfig (defaults togreeted-nicks.json) via the existingresolve()helper.src/main.ts— loads the store on startup, skips already-greeted nicks in thejoinhandler, and persists after a successful greeting.deno.json— added--allow-writetodev,start,test, andcompiletasks..env.example,.gitignore,README.md— documented the new option and behavior.Design notes
Deno.readTextFile/Deno.writeTextFileAPIs are the simplest fit for "simple disk storage." No@std/*package was needed./pi rebase the pr, push change
44be66b224bac701a02aNow let me look at what master changed (potential conflict areas) vs what the PR changes, so I can be prepared:Let me examine the full content of conflicting files in both branches:Let me see master's version of main.ts and check the file tree:Now I have a clear picture. Master diverged from the PR's base by simplifying the README (removing the
{gift}/horse-gift concept and project-structure section) and addingbot: trueto theClientconstructor. Let me look at the PR's exact changes to the overlapping files:I now have a full understanding of the divergence. Master addedbot: trueto theClientconstructor and simplified the README (removed the{gift}/horse-gift concept, example-greeting block, and project-structure section). The PR adds storage logic/docs. The conflicts will be inREADME.mdandsrc/main.ts. Let me check out the PR branch and start the rebase:Two conflicts as expected. Let me check the state of both files:Now let me check the auto-mergedsrc/main.ts:Thesrc/main.tsauto-merge is correct — it has bothbot: true(from master) and the storage logic (from the PR). Now I'll resolve theREADME.mdconflict, keeping master's simplifications (no{gift}, no example-greeting block, no project-structure section) while adding the storage documentation from the PR:Now let me verify there are no conflict markers and rundeno fmtto ensure proper formatting (Deno aligns markdown tables):Deno isn't on the PATH. Let me locate it:Deno isn't installed. Let me install it so I can verify the rebased code type-checks and tests pass:deno fmtapplied trailing comma inmain.tsand wrapped the README intro. Let me verify the results:Both files look correct. Let me run formatting check on all PR-touched files, then type-check and run the test suite to verify the rebase produces working code:Type-check and lint pass. Now let me run the test suite:All 8 tests pass, and lint/check/fmt are clean. Now let me stage the resolved files and continue the rebase:Rebase succeeded. Let me verify the result — confirm the branch is now based on master and review the final diff:The branch now sits directly on top of master. Let me do a final review of the resolved conflicts to confirm correctness:The diff is exactly right — it cleanly combines master'sbot: trueand simplified README with the PR's storage feature, without re-introducing the removed{gift}/horse-gift content. Now let me force-push the rebased branch:The rebased branch has been force-pushed. Let me verify the final state of the PR:Done. The PR has been rebased onto the latestmasterand force-pushed.What happened:
masterhad diverged from the PR's original base with two commits that touched the same files as this PR (README.mdandsrc/main.ts), so a straight rebase produced two conflicts. I resolved them as follows:src/main.ts— auto-merged cleanly, combining master's newbot: trueoption on theClientconstructor with the PR's storage logic and restructuredjoinhandler.README.md— kept master's simplifications (the "fixed message" wording,{nick}-only greeting, and the removed example-greeting block and project-structure section) and layered the PR's storage documentation on top: the greeted-nicks sentence in the intro, the newIRC_STORE_PATHconfig-table row, and the "filesystem access" note in Usage. The stale{gift}/horse-gift content was not re-introduced.Verification before pushing:
deno fmt --check— clean (applied a trailing comma tobot: true,and wrapped the README intro to match repo style)deno lint— cleandeno check src/main.ts— passesdeno test— all 8 tests passThe branch now contains a single commit (
bac701a) sitting directly on top ofmaster(5ddf130), with no merge commits.View action run | Model: zai/glm-5.2 (thinking: max) | Time: 3m 57s | Tokens: 450.1K | Pi SDK v0.80.6 | Action v2.25.1-develop (develop @ 9c24480)