Created
August 19, 2023 04:05
-
-
Save nuklearfiziks/ed2a520340ddd5b7e94ca7e3e2a64ec9 to your computer and use it in GitHub Desktop.
big-league-me.ts
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 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