import { loginToService } from "./login.ts"; import "@std/dotenv/load"; import { parseArgs } from "@std/cli"; import { getAllAppeals } from "./appeals.ts"; if (import.meta.main) { const { _: [command], } = parseArgs(Deno.args); switch (command) { case "autoappeal": { const agent = await loginToService(); const appeals = await getAllAppeals(agent); const { data: { records }, } = await agent.tools.ozone.moderation.getRecords({ uris: appeals.map((d) => d.subject.uri), }); for (const record of records) { try { const evt = { subject: { $type: "com.atproto.repo.strongRef", uri: record.uri, cid: record.cid, }, createdBy: agent.did!, subjectBlobCids: record.blobCids, modTool: { name: "ozone-cli/autoappeal" }, }; // Remove ALL labels from each post // @TODO add some sort of NLP to determine what action to take (i.e., replace label X with label Y) await agent.tools.ozone.moderation.emitEvent({ ...evt, event: { $type: "tools.ozone.moderation.defs#modEventLabel", createLabelVals: [], negateLabelVals: record.labels, comment: `Labels removed by ozone-cli at ${new Date().toISOString()}`, }, }); // Acknowledge appeal await agent.tools.ozone.moderation.emitEvent({ ...evt, event: { $type: "tools.ozone.moderation.defs#modEventAcknowledge", comment: "ACK appeal", acknowledgeAccountSubjects: false, }, }); // Resolve appeal await agent.tools.ozone.moderation.emitEvent({ ...evt, event: { $type: "tools.ozone.moderation.defs#modEventResolveAppeal", comment: "Resolving appeal", }, }); } catch (e) { console.error(e); console.error(record); } } } } }