25 lines
583 B
TypeScript
25 lines
583 B
TypeScript
import * as dotenv from "dotenv";
|
|
|
|
import bsky from "@atproto/api";
|
|
const { BskyAgent, RichText } = bsky;
|
|
|
|
dotenv.config();
|
|
|
|
const agent = new BskyAgent({
|
|
service: process.env.BLUESKY_ENDPOINT as string,
|
|
});
|
|
await agent.login({
|
|
identifier: process.env.BLUESKY_EMAIL as string,
|
|
password: process.env.BLUESKY_PASSWORD as string,
|
|
});
|
|
|
|
const rt = new RichText({ text: "Hello Bluesky!" });
|
|
await rt.detectFacets(agent);
|
|
const postRecord = {
|
|
$type: "app.bsky.feed.post",
|
|
text: rt.text,
|
|
facets: rt.facets,
|
|
createdAt: new Date().toISOString(),
|
|
};
|
|
await agent.post(postRecord);
|