diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5bd7f23..226854b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,4 +20,6 @@ jobs: source ~/.nvm/nvm.sh cd farcaster-praise-bot git pull origin main - pm2 reload all \ No newline at end of file + pm2 stop all + bun install + pm2 start all \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index de1ffc4..de71178 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/index.ts b/index.ts index d3099b1..85dbb8f 100644 --- a/index.ts +++ b/index.ts @@ -1,25 +1,53 @@ import neynarClient from "./neynarClient"; +import type {NeynarFrameCreationRequest} from "@neynar/nodejs-sdk/build/neynar-api/v2"; const server = Bun.serve({ port: 3000, async fetch(req) { try { + const body = await req.text(); + const hookData = JSON.parse(body); + + const creationRequest: NeynarFrameCreationRequest = { + name: `gm ${hookData.data.author.username}`, + pages: [ + { + image: { + url: "https://moralis.io/wp-content/uploads/web3wiki/638-gm/637aeda23eca28502f6d3eae_61QOyzDqTfxekyfVuvH7dO5qeRpU50X-Hs46PiZFReI.jpeg", + aspect_ratio: "1:1", + }, + title: "Page title", + buttons: [], + input: { + text: { + enabled: false, + }, + }, + uuid: "gm", + version: "vNext", + }, + ], + }; + const frame = await neynarClient.publishNeynarFrame(creationRequest); + if (!process.env.SIGNER_UUID) { throw new Error("Make sure you set SIGNER_UUID in your .env file"); } - const body = await req.text(); - const hookData = JSON.parse(body); - const reply = await neynarClient.publishCast( process.env.SIGNER_UUID, `gm ${hookData.data.author.username}`, { + embeds: [ + { + url: frame.link, + }, + ], replyTo: hookData.data.hash, } ); - console.log("reply:", reply); - return new Response("Welcome to my Farcaster praise bot!!!!!"); + console.log("Date:" + new Date() + reply); + return new Response(`Replied to the cast with hash: ${reply.hash}`); } catch (e: any) { return new Response(e.message, { status: 500 }); } diff --git a/package.json b/package.json index ea335eb..6179f6f 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "name": "farcaster-praise-bot", "module": "index.ts", "type": "module", + "scripts": { + "start": "bun run index.ts" + }, "devDependencies": { "@types/bun": "latest" },