-
-
Save PSingletary/e65b8bc503fda37e76b9e6317521a434 to your computer and use it in GitHub Desktop.
big-league-me.ts
This file contains hidden or 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 dotenv from 'dotenv' | |
import { BskyAgent } from '@atproto/api' | |
import { ProfileView } from '@atproto/api/dist/client/types/app/bsky/actor/defs' | |
const bigLeagueMe = async () => { | |
dotenv.config() | |
// YOUR bluesky handle | |
// Ex: user.bsky.social | |
const handle = process.env.BSKYHANDLE || '' | |
// YOUR bluesky password, or preferably an App Password (found in your client settings) | |
// Ex: abcd-1234-efgh-5678 | |
const password = process.env.BSKYPASS || '' | |
// only update this if in a test environment | |
const agent = new BskyAgent({ service: 'https://bsky.social' }) | |
await agent.login({ identifier: handle, password }) | |
let follows: ProfileView[] = [] | |
let cursor | |
while (true) { | |
const following = await agent.app.bsky.graph.getFollows({ | |
cursor, | |
actor: handle, | |
}) | |
cursor = following.data.cursor | |
follows = [...follows, ...following.data.follows] | |
if (!cursor) break | |
} | |
for (const actor of follows) { | |
const [rkey, , repo] = actor.viewer?.following?.split('/').reverse() || [] | |
console.log(rkey, repo) | |
console.log( | |
`Unfollowing ${actor.handle}`, | |
await agent.com.atproto.repo.deleteRecord({ | |
collection: 'app.bsky.graph.follow', | |
repo, | |
rkey, | |
}), | |
) | |
} | |
} | |
bigLeagueMe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment