/** * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { AtpAgent } from "@atproto/api"; /** * Forwards an announcement to our Bluesky account. * @param content - The main body of the announcement. * @returns A message indicating the success or failure of the operation. */ export const announceOnBluesky = async( content: string, ): Promise => { if (process.env.BSKY_APP_PASSWORD === undefined) { return "Bluesky credentials are not set."; } const agent = new AtpAgent({ service: "https://bsky.social", }); await agent.login({ identifier: "nhcarrigan.com", password: process.env.BSKY_APP_PASSWORD, }); const blueskyRequest = await agent.post({ text: content, }).catch((error: unknown) => { return error instanceof Error ? error.message : String(error); }); if (typeof blueskyRequest === "string") { return `Failed to send message to Bluesky. ${blueskyRequest}`; } return "Successfully sent message to Bluesky."; };