Something went wrong. Try again.
Atproto Agent
Something went wrong. Try again.
dicesprite write-test-entry.js
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import "dotenv/config";import { AtpAgent } from "@atproto/api";
// ---------------------------------------------------------------------// write-test-entry.js -- writes ONE test membership/entry record from// an alt account. Genuinely different from write-test-guess.js: an// entry (com.pyxorium.dicesprite.entry) marks "I'm participating in// this game," written once and rarely changing, separate from a guess// (com.pyxorium.dicesprite.numGuess), which is a per-round pick written// fresh often. The two-record-type split matches their real, different// lifecycles -- see sprite-hop-reference.md for the full reasoning.//// Matches the formal lexicon at lexicons/com.pyxorium.dicesprite.entry.json.//// Run with an optional status ("active" or "withdrawn"), defaults to// "active":// node write-test-entry.js withdrawn// ---------------------------------------------------------------------
const COLLECTION = "com.pyxorium.dicesprite.entry";const GAME_ID = "dice-chestahedron-guess";
const statusArg = process.argv[2];const status = statusArg === "withdrawn" ? "withdrawn" : "active";
async function main() { if (!process.env.ALT_HANDLE || !process.env.ALT_PASSWORD) { console.error("Missing ALT_HANDLE or ALT_PASSWORD in .env -- these are the alt/test account's own credentials, separate from the bot's."); process.exit(1); }
const agent = new AtpAgent({ service: process.env.ALT_PDS || "https://bsky.social" }); await agent.login({ identifier: process.env.ALT_HANDLE, password: process.env.ALT_PASSWORD, }); console.log(`Logged in as ${agent.session.handle} (${agent.session.did})`);
await agent.com.atproto.repo.putRecord({ repo: agent.session.did, collection: COLLECTION, rkey: "self", record: { gameId: GAME_ID, status, joinedAt: new Date().toISOString(), }, });
console.log(`Wrote test entry -- gameId=${GAME_ID} status=${status}`); console.log("This writes to a DIFFERENT collection than write-test-guess.js -- listener.js would need its own separate watch on com.pyxorium.dicesprite.entry to see this (not built yet, since the current listener only watches the guess collection).");}
main().catch((err) => { console.error("Fatal error:", err); process.exit(1);});