this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

no brain left

+38 -30
+1 -7
src/agent.ts
··· 6 6 service: process.env.BSKY_SERVICE ?? "https://bsky.social", 7 7 }); 8 8 9 - await agent.login({ 10 - identifier: process.env.BSKY_IDENTIFIER!, 11 - password: process.env.BSKY_PASSWORD!, 12 - }); 13 9 return agent; 14 10 }; 15 11 16 - export const did = await getAgent().then((agent) => agent.session!.did); 17 - 18 12 BskyAgent.configure({ 19 - appLabelers: [did], 13 + appLabelers: [process.env.DID ?? ""], 20 14 });
+25
src/constants.ts
··· 1 + import "dotenv/config"; 2 + 1 3 export const PRONOUNS: Record<string, string> = { 2 4 "she/her": "she", 3 5 "he/him": "he", ··· 8 10 avoid: "avoid", 9 11 "look at bio": "bio", 10 12 }; 13 + 14 + export const URIs: Record<string, string> = { 15 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwsqucto3j2a": 16 + "Like this post to delete your labels", 17 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwss4ldkwd2j": 18 + "they/them", 19 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwss4fmiow2n": 20 + "it/its", 21 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwss4bzqlw2k": 22 + "he/him", 23 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwss45mxrh2j": 24 + "she/her", 25 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwst2tn2342f": 26 + "look at bio", 27 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwsslg3gqk2t": 28 + "avoid", 29 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwssldhzme27": 30 + "ask", 31 + "at://did:plc:wkoofae5uytcm7bjncmev6n6/app.bsky.feed.post/3kwss4vc4cw2x": 32 + "any/all", 33 + }; 34 + 35 + export const DID = process.env.DID ?? "";
+8 -21
src/label.ts
··· 1 - import { did } from "./agent.js"; 2 - import { AppBskyFeedPost, BskyAgent } from "@atproto/api"; 3 - import { PRONOUNS } from "./constants.js"; 4 - 5 - const getPostContent = async (agent: BskyAgent, uri: string) => { 6 - return await agent 7 - .getPosts({ uris: [uri] }) 8 - .catch((err) => { 9 - console.error(err.message); 10 - }) 11 - .then((posts) => { 12 - if (posts && AppBskyFeedPost.isRecord(posts.data.posts[0].record)) 13 - return posts.data.posts[0].record.text; 14 - else return ""; 15 - }); 16 - }; 1 + import { BskyAgent } from "@atproto/api"; 2 + import { DID, PRONOUNS, URIs } from "./constants.js"; 17 3 18 4 export const label = async (agent: BskyAgent, subject: string, uri: string) => { 19 5 const repo = await agent 20 - .withProxy("atproto_labeler", did) 6 + .withProxy("atproto_labeler", DID) 21 7 .api.tools.ozone.moderation.getRepo({ did: subject }); 22 8 23 - const post = await getPostContent(agent, uri); 9 + const post = URIs[uri]; 24 10 25 11 if (repo.data.labels && post.includes("Like this post to delete")) { 26 12 await agent 27 - .withProxy("atproto_labeler", did) 13 + .withProxy("atproto_labeler", DID) 28 14 .api.tools.ozone.moderation.emitEvent({ 29 15 event: { 30 16 $type: "tools.ozone.moderation.defs#modEventLabel", ··· 46 32 47 33 if (PRONOUNS[post]) { 48 34 await agent 49 - .withProxy("atproto_labeler", did) 35 + .withProxy("atproto_labeler", DID) 50 36 .api.tools.ozone.moderation.emitEvent({ 51 37 event: { 52 38 $type: "tools.ozone.moderation.defs#modEventLabel", ··· 60 46 createdBy: agent.session!.did, 61 47 createdAt: new Date().toISOString(), 62 48 subjectBlobCids: [], 63 - }); 49 + }) 50 + .then(() => console.log(`Labeled ${subject} with ${post}`)); 64 51 } 65 52 };
+4 -2
src/main.ts
··· 1 1 import { AppBskyFeedLike } from "@atproto/api"; 2 2 import { Firehose } from "@skyware/firehose"; 3 - import { did, getAgent } from "./agent.js"; 3 + import { getAgent } from "./agent.js"; 4 4 import { label } from "./label.js"; 5 + import { DID } from "./constants.js"; 5 6 6 7 const subscribe = async () => { 7 8 const agent = await getAgent(); 8 9 10 + //const firehose = new Firehose("wss://bsky.network", { cursor: "759324067" }); 9 11 const firehose = new Firehose(); 10 12 firehose.on("commit", (commit) => { 11 13 for (const op of commit.ops) { 12 14 if (op.action === "delete") continue; 13 15 if (AppBskyFeedLike.isRecord(op.record)) { 14 - if (op.record.subject.uri.includes(did)) { 16 + if (op.record.subject.uri.includes(DID)) { 15 17 if (op.record.subject.uri.includes("app.bsky.feed.post")) { 16 18 label(agent, commit.repo, op.record.subject.uri).catch((err) => 17 19 console.error(err),