import { fetch } from "https://esm.town/v/std/fetch";
import { set } from "https://esm.town/v/std/set?v=11";
import { topHNThreadByHour } from "https://esm.town/v/elsif_maj/topHNThreadByHour";
export let nameTopHNThreadCron = (async () => {
const cheerio = await import("npm:cheerio");
const reply = await fetch("https://news.ycombinator.com/");
const replyText = await reply.text();
const $ = await cheerio.load(replyText);
const firstThreadTitle = $(".athing:first-child .titleline > a").first()
.text();
let now = new Date();
let currentHour = now.getHours();
topHNThreadByHour.push(
"Top thread on Hackernews for " + currentHour + ":00 " +
"is: " + firstThreadTitle,
);
await set(
"topHNThreadByHour",
topHNThreadByHour,
);
});