Last active
July 9, 2023 11:45
-
-
Save kawarimidoll/f6e05b7a2e992be84ad580d15b6abb0a to your computer and use it in GitHub Desktop.
Bluesky invite code history checker
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
// deno run --allow-net=bsky.social invite_history.ts | |
import AtprotoAPI from "npm:@atproto/api"; | |
const { BskyAgent } = AtprotoAPI; | |
const service = "https://bsky.social"; | |
const agent = new BskyAgent({ service }); | |
const identifier = "YOUR_BLUESKY_IDENTIFIER"; // did or handle | |
const password = "YOUR_BLUESKY_PASSWORD"; // app-password is available | |
await agent.login({ identifier, password }); | |
const { data: { codes } } = await agent.api.com.atproto.server | |
.getAccountInviteCodes(); | |
const used = codes.filter((code) => code.uses.length > 0); | |
console.log({ distributed: codes.length, used: used.length }); | |
for await (const code of used) { | |
const { usedBy, usedAt } = code.uses[0]; | |
let handle = ""; | |
try { | |
const { data } = await agent.getProfile({ | |
actor: usedBy, | |
}); | |
handle = data.handle; | |
} catch (_e) { | |
handle = "deleted"; | |
} | |
console.log({ | |
code: code.code, | |
createdAt: code.createdAt, | |
handle, | |
usedAt, | |
profile: `https://bsky.app/profile/${usedBy}`, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment