Created
August 28, 2023 20:23
-
-
Save grikomsn/872e9f302fe6294a953ab03adff62276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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