Skip to content

Instantly share code, notes, and snippets.

@grikomsn
Created August 28, 2023 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grikomsn/872e9f302fe6294a953ab03adff62276 to your computer and use it in GitHub Desktop.
Save grikomsn/872e9f302fe6294a953ab03adff62276 to your computer and use it in GitHub Desktop.
import { AtUri, BskyAgent } from "@atproto/api";
const raise = (message?: string) => {
throw new Error(message);
};
const besky = async () => {
const username = process.env.BLUESKY_USERNAME || raise(`env BLUESKY_USERNAME not set`);
const password = process.env.BLUESKY_PASSWORD || raise(`env BLUESKY_PASSWORD not set`);
console.log(`> initializing agent`);
const agent = new BskyAgent({
service: "https://bsky.social",
});
console.log(`> signing in as ${username}`);
const { data: authData } = await agent.login({
identifier: username,
password,
});
agent.api.setHeader("Authorization", `Bearer ${authData.accessJwt}`);
console.log(`> fetching likes for ${username}`);
const { data } = await agent.api.com.atproto.repo.listRecords({
collection: "app.bsky.feed.like",
repo: username,
});
for await (const record of data.records) {
console.log(`> unliking ${record.uri}`);
const uri = new AtUri(record.uri);
await agent.api.com.atproto.repo.deleteRecord({
collection: "app.bsky.feed.like",
repo: username,
rkey: uri.rkey,
});
console.log(`> unliked ${record.uri}`);
}
};
void besky();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment