A chill Bluesky bot, with responses powered by Gemini.
1import { AtUri } from "@atproto/syntax";
2import { Type } from "@google/genai";
3import bot from "../bot";
4import z from "zod";
5
6export const definition = {
7 name: "create_blog_post",
8 description: "Creates a new blog post and returns the URL.",
9 parameters: {
10 type: Type.OBJECT,
11 properties: {
12 title: {
13 type: Type.STRING,
14 description: "The title of the blog post. Keep it concise.",
15 },
16 content: {
17 type: Type.STRING,
18 description:
19 "The text of the blog post. This can contain markdown, and can be as long as necessary.",
20 },
21 },
22 required: ["title", "content"],
23 },
24};
25
26export const validator = z.object({
27 title: z.string(),
28 content: z.string(),
29});
30
31export async function handler(args: z.infer<typeof validator>) {
32 //@ts-ignore: NSID is valid
33 const entry = await bot.createRecord("com.whtwnd.blog.entry", {
34 $type: "com.whtwnd.blog.entry",
35 title: args.title,
36 theme: "github-light",
37 content: args.content,
38 createdAt: new Date().toISOString(),
39 visibility: "public",
40 });
41
42 return {
43 link: `whtwnd.com/echo.indexx.dev/${new AtUri(entry.uri).rkey}`,
44 };
45}