Back
Version 11
10/7/2024
import { BskyAgent, BlobRef } from 'npm:@atproto/api';
const BSKY_EMAIL = Deno.env.get("BSKY_EMAIL");
const BSKY_PWD = Deno.env.get("BSKY_PWD");
export async function blueskyPostWithImage(statusText: string, imageBuffer: any, altText: string) {
const agent = new BskyAgent({service: 'https://bsky.social'})
const loginResult = await agent.login({ identifier: BSKY_EMAIL!, password: BSKY_PWD!})
const { data } = await agent.uploadBlob(imageBuffer, { encoding: "png" })
console.log(data)
const postReuslt = await agent.post({
text: statusText,
embed: {
$type: 'app.bsky.embed.images',
images: [
{
image: data.blob,
alt: altText
}
]
}
});
console.log(postReuslt)
}
Updated: October 7, 2024