A work-in-progress, horribly overpowered CLI for Ozone

Compare changes

Choose any two refs to compare.

Changed files
+60 -40
+15 -1
README.md
··· 1 1 ## Cursory attempt to build a script that rapidly actions appeals 2 2 3 - This is a work in progress. :pray: 3 + This is a work in progress. :pray: 4 + 5 + Currently it has one command, `autoappeal`, which removes all the labels from and resolves every appeal in your queue. 6 + 7 + Don't ask why I need this. 8 + 9 + Usage: 10 + 11 + ```bash 12 + ATP_USERNAME="user.bsky.social" ATP_PASSWORD="yadda-yadda" SERVICE_DID="your-labeller-DID" deno main.ts autoappeal 13 + ``` 14 + 15 + You can also use a .env file or pass `--username`, `--password` and `--proxy` (service DID) flags. 16 + 17 + I'm awful at using Deno. Apologies for all the typescript errors :sob:
+2 -1
login.ts
··· 6 6 username = Deno.env.get("ATP_USERNAME"), 7 7 password = Deno.env.get("ATP_PASSWORD"), 8 8 service = Deno.env.get("SERVICE_URI") ?? "https://bsky.social", 9 + proxy = Deno.env.get("SERVICE_DID"), 9 10 } = parseArgs(Deno.args); 10 11 11 12 const agent = new AtpAgent({ service }); 12 - agent.configureProxy("did:plc:newitj5jo3uel7o4mnf3vj2o#atproto_labeler"); 13 + agent.configureProxy(proxy); 13 14 14 15 try { 15 16 await agent.login({ identifier: username, password });
+43 -38
main.ts
··· 18 18 }); 19 19 20 20 for (const record of records) { 21 - const evt = { 22 - subject: { 23 - $type: "com.atproto.repo.strongRef", 24 - uri: record.uri, 25 - cid: record.cid, 26 - }, 27 - createdBy: agent.did!, 28 - subjectBlobCids: record.blobCids, 29 - modTool: { name: "ozone-cli/autoappeal" }, 30 - }; 21 + try { 22 + const evt = { 23 + subject: { 24 + $type: "com.atproto.repo.strongRef", 25 + uri: record.uri, 26 + cid: record.cid, 27 + }, 28 + createdBy: agent.did!, 29 + subjectBlobCids: record.blobCids, 30 + modTool: { name: "ozone-cli/autoappeal" }, 31 + }; 31 32 32 - // Remove ALL labels from each post 33 - // @TODO add some sort of NLP to determine what action to take (i.e., replace label X with label Y) 34 - await agent.tools.ozone.moderation.emitEvent({ 35 - ...evt, 36 - event: { 37 - $type: "tools.ozone.moderation.defs#modEventLabel", 38 - createLabelVals: [], 39 - negateLabelVals: record.labels, 40 - comment: `Labels removed by ozone-cli at ${new Date().toISOString()}`, 41 - }, 42 - }); 33 + // Remove ALL labels from each post 34 + // @TODO add some sort of NLP to determine what action to take (i.e., replace label X with label Y) 35 + await agent.tools.ozone.moderation.emitEvent({ 36 + ...evt, 37 + event: { 38 + $type: "tools.ozone.moderation.defs#modEventLabel", 39 + createLabelVals: [], 40 + negateLabelVals: record.labels, 41 + comment: `Labels removed by ozone-cli at ${new Date().toISOString()}`, 42 + }, 43 + }); 43 44 44 - // Acknowledge appeal 45 - await agent.tools.ozone.moderation.emitEvent({ 46 - ...evt, 47 - event: { 48 - $type: "tools.ozone.moderation.defs#modEventAcknowledge", 49 - comment: "", 50 - acknowledgeAccountSubjects: false, 51 - }, 52 - }); 45 + // Acknowledge appeal 46 + await agent.tools.ozone.moderation.emitEvent({ 47 + ...evt, 48 + event: { 49 + $type: "tools.ozone.moderation.defs#modEventAcknowledge", 50 + comment: "ACK appeal", 51 + acknowledgeAccountSubjects: false, 52 + }, 53 + }); 53 54 54 - // Resolve appeal 55 - await agent.tools.ozone.moderation.emitEvent({ 56 - ...evt, 57 - event: { 58 - $type: "tools.ozone.moderation.defs#modEventResolveAppeal", 59 - comment: "Resolving", 60 - }, 61 - }); 55 + // Resolve appeal 56 + await agent.tools.ozone.moderation.emitEvent({ 57 + ...evt, 58 + event: { 59 + $type: "tools.ozone.moderation.defs#modEventResolveAppeal", 60 + comment: "Resolving appeal", 61 + }, 62 + }); 63 + } catch (e) { 64 + console.error(e); 65 + console.error(record); 66 + } 62 67 } 63 68 } 64 69 }