Skip to content

Commit

Permalink
add frame to reply
Browse files Browse the repository at this point in the history
  • Loading branch information
RamRamez committed Aug 10, 2024
1 parent 8e506d0 commit 29eb7f9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ jobs:
source ~/.nvm/nvm.sh
cd farcaster-praise-bot
git pull origin main
pm2 reload all
pm2 stop all
bun install
pm2 start all
Binary file modified bun.lockb
Binary file not shown.
38 changes: 33 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -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 });
}
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "farcaster-praise-bot",
"module": "index.ts",
"type": "module",
"scripts": {
"start": "bun run index.ts"
},
"devDependencies": {
"@types/bun": "latest"
},
Expand Down

0 comments on commit 29eb7f9

Please sign in to comment.