Skip to content

Instantly share code, notes, and snippets.

@olegp

olegp/bluesky.js Secret

Last active November 27, 2024 11:34
Show Gist options
  • Save olegp/82eb6b54da56a2cf87cacde437328a12 to your computer and use it in GitHub Desktop.
Save olegp/82eb6b54da56a2cf87cacde437328a12 to your computer and use it in GitHub Desktop.
Bluesky contact finder
import fs from "fs";
import { AtpAgent } from "@atproto/api";
const agent = new AtpAgent({
service: "https://bsky.social",
});
await agent.login({
identifier: "ID.bsky.social",
password: "PASS",
});
const filePath = "connections.tsv";
const fileContent = fs.readFileSync(filePath, "utf8");
const lines = fileContent.split("\n");
for (let i = 1; i < lines.length; i++) {
const row = lines[i].trim();
if (!row) continue;
const fields = row.split("\t");
const name = fields[0],
url = fields[1],
company = fields[2],
position = fields[3];
if (!name) {
continue;
}
try {
const response = await agent.searchActors({ term: `"${name}"` });
const users = response.data.actors;
if (users.length === 0) {
console.warn(name);
} else {
users.forEach((user) => {
console.log(
`${name}\t${url}\t${company}\t${position}\thttps://bsky.app/profile/${
user.handle
}\t${user.description ? user.description.replace(/\s+/g, " ") : ""}`
);
});
}
} catch (error) {
console.error(`${i}\t${error.message}`);
}
}
@olegp
Copy link
Author

olegp commented Nov 27, 2024

This script tries to find your LinkedIn connections (or any other lists of names) on Bluesky by searching for them by name. For common names a lot of irrelevant results are returned, so the data needs to be post-processed manually. This might be a good thing, since there could be some LinkedIn connections you don't actually want to follow on Bluesky.

  1. Update ID and PASS as needed. For the PASS you should create an app password.
  2. Export connections from LinkedIn.
  3. Import the exported connections into e.g. Google Sheets, remove the extra stuff at the top, make sure that the columns are: Name, URL, company, position. Export to "connections.tsv".
  4. Install dependencies with "npm i @atproto/api", then run this script with "node bluesky.js > results.tsv".
  5. Import "results.tsv" back into Google Sheets and manually process the data there, following matching profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment