1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export async function post_to_bsky(text, identifier, password) {
const { default: bsky } = await import("npm:@atproto/api");
const { BskyAgent, RichText } = bsky;
const agent = new BskyAgent({ service: "https://bsky.social" });
await agent.login({ identifier, password });
const post = new RichText({ text });
await post.detectFacets(agent);
// todo card & images
// https://github.com/milanmdev/bsky.rss/blob/main/app/utils/bskyHandler.ts#L51
const postRecord = {
$type: "app.bsky.feed.post",
text: post.text,
facets: post.facets,
createdAt: new Date().toISOString(),
};
return await agent.post(postRecord);
}