97
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
101 const telegramToken = Deno.env.get("TELEGRAM_TOKEN");
102
106 }
107
108 if (!apiKey) {
109 console.error("Anthropic API key is not configured.");
110 return;
111 }
122
123 // Initialize Anthropic client
124 const anthropic = new Anthropic({ apiKey });
125
126 // Initialize Telegram bot
162
163 // disabled title for now, it seemes unnecessary...
164 // await bot.api.sendMessage(chatId, `*${title}*`, { parse_mode: "Markdown" });
165
166 // Then send the main content
169
170 if (content.length <= MAX_LENGTH) {
171 await bot.api.sendMessage(chatId, content, { parse_mode: "Markdown" });
172 // Store the briefing in chat history
173 await storeChatMessage(
198 // Send each chunk as a separate message and store in chat history
199 for (const chunk of chunks) {
200 await bot.api.sendMessage(chatId, chunk, { parse_mode: "Markdown" });
201 // Store each chunk in chat history
202 await storeChatMessage(
1import { createServer } from "https://esm.town/v/nbbaier/dbToAPI";
2import { faker } from "npm:@faker-js/faker";
3
8const urls = res.rows.map(r => {
9 const url = new URL(r[0]);
10 return "https://api.fxtwitter.com" + url.pathname;
11});
12
11import { fetchTweet, makeFriendly, transformTweet } from "https://esm.town/v/nbbaier/twitterCards/tweetCardUtils.ts";
12
13const BASE_URL = new URL("https://api.fxtwitter.com");
14const targetURL = new URL(
15 "https://x.com/jasonzhou1993/status/1852895969970720914",
1import type {
2 APIPhoto,
3 APITweet,
4 APIVideo,
5 TweetData,
6 TweetPhoto,
18}
19
20function transformAuthor(author: APITweet["author"]): TweetAuthor {
21 return {
22 name: author.name,
28
29function getTweetMedia(
30 media: NonNullable<APITweet["media"]>,
31): TweetData["media"] {
32 const result: TweetData["media"] = {};
43}
44
45export function transformTweet(tweet: APITweet): TweetData {
46 return {
47 url: tweet.url,
57}
58
59export async function fetchTweet(url: URL | string): Promise<APITweet> {
60 const response = await fetch(url);
61 const { tweet } = (await response.json()) as {
62 code: number;
63 tweet: APITweet;
64 message: string;
65 };
68}
69
70export function transformPhoto(inputPhoto: APIPhoto): TweetPhoto {
71 return {
72 url: inputPhoto.url,
75}
76
77export function transformVideo(inputVideo: APIVideo): TweetVideo {
78 return {
79 url: inputVideo.thumbnail_url,
14}
15
16export interface APIPhoto extends BaseMedia {
17 type: "photo";
18}
19
20export interface APIVideo extends BaseMedia {
21 type: "video" | "gif";
22 thumbnail_url: string;
24}
25
26export interface APIExternalMedia {
27 type: string;
28 url: string;
32}
33
34export interface APIMosaicPhotoFormats {
35 webp: string;
36 jpeg: string;
37}
38
39export interface APIMosaicPhoto {
40 type: "mosaic_photo";
41 width: number;
42 height: number;
43 formats: APIMosaicPhotoFormats;
44}
45
46export interface TweetMedia {
47 all?: APIVideo[];
48 external?: APIExternalMedia;
49 photos?: APIPhoto[];
50 videos?: APIVideo[];
51 mosaic?: APIMosaicPhoto;
52}
53
54export interface APIPollChoice {
55 label: string;
56 count: number;
58}
59
60export interface APIPoll {
61 choices: APIPollChoice[];
62 total_votes: number;
63 ends_at: string;
65}
66
67export interface APITranslate {
68 text: string;
69 source_lang: string;
71}
72
73export interface APIAuthor {
74 name: string;
75 screen_name: string;
79}
80
81export interface APITweet {
82 id: string;
83 url: string;
90 replying_to_status: string | null;
91 twitter_card: TwitterCardType;
92 author: APIAuthor;
93 source: string;
94
98 views: number | null;
99
100 quote?: APITweet;
101 poll?: APIPoll;
102 translation?: APITranslate;
103 media?: TweetMedia;
104}
1import { db } from "https://esm.town/v/nbbaier/dbToAPI_backup/lowdbTest.ts";
2import { createServer } from "https://esm.town/v/nbbaier/dbToAPI_backup/server.tsx";
3
4const app = await createServer(db);
1/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
2
3import { Homepage } from "https://esm.town/v/nbbaier/dbToAPI_backup/frontend.tsx";
4import {
5 checkResource,
7 type Options,
8 validate,
9} from "https://esm.town/v/nbbaier/dbToAPI_backup/helpers.tsx";
10import { Hono } from "npm:hono";
11
1// https://www.val.town/v/nbbaier/dbToAPIFrontend
2
3/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
25
26 <div class="space-y-2">
27 <p>You've set up an API for your Val Town lowdb instance</p>
28 <p>
29 ✧*。٩(ˊᗜˋ*)و✧*。
38function MiniApps() {
39 const { data: miniapps } = useQuery(["miniapps"], async () => {
40 // return await fetch(`/api/miniapps`).then(r => r.json()).then(r => r);
41 // return await fetchNeynarGet(`frame/catalog?limit=100`).then(r => r.frames);
42 return await fetchNeynarGetPages(`frame/catalog?limit=100`, 4, "frames").then(r => r.frames);
98 onChange={e => setSearch(e.target.value)}
99 placeholder="Search..."
100 autoCapitalize="on"
101 autoCorrect="on"
102 type="text"