1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { email } from "https://esm.town/v/std/email?v=9";
import { rssEntriesToHTML } from "https://esm.town/v/zackoverflow/rssEntriesToHTML";
import { set } from "https://esm.town/v/std/set?v=11";
import { pollRss } from "https://esm.town/v/zackoverflow/pollRss";
import { rssEmail } from "https://esm.town/v/zackoverflow/rssEmail";
let { rssCache } = await import("https://esm.town/v/zackoverflow/rssCache");
let { rssFeeds } = await import("https://esm.town/v/zackoverflow/rssFeeds");
export const pollRssAndEmail = async () => {
rssFeeds = rssFeeds ??
["https://journal.stuffwithstuff.com/rss.xml"];
rssCache = rssCache ?? {} as any;
if (typeof rssEmail !== "string")
throw new Error(
"You haven't set your email, please create a val called @rssEmail and set its value to your e-mail address.",
);
const rssEntries = await pollRss(
rssFeeds,
rssCache,
);
await set("rssCache", rssCache);
if (rssEntries.length === 0)
return;
const html = await rssEntriesToHTML(rssEntries);
return await email({
to: [rssEmail],
subject: `RSS Update ${(new Date()).toDateString()}`,
html,
});
};