import process from "node:process";
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
import { hnEmail } from "https://esm.town/v/stevekrouse/hnEmail";
import { hnLatestPosts } from "https://esm.town/v/stevekrouse/hnLatestPosts";
export async function hnValTown({ lastRunAt }: Interval) {
let posts = await hnLatestPosts({
query: '"val town" || "val.town"',
lastSyncTime: lastRunAt,
search_by_date: true,
});
let { text } = await hnEmail({ posts, footer: false });
if (posts.length) {
await discordWebhook({
url: process.env.mentionsDiscord,
content: text,
});
}
}