A Discord bot to post webcomic updates that runs on Cloudflare Workers (including the free tier).
If you don't already have a Cloudflare account, you can sign up for one for free.
-
Log into Cloudflare.
-
Click the button below on this page:
-
Follow the remaining instructions provided by Cloudflare.
An example JSON file can be found here:
tests/e2e/comics.json.
- Using your favourite text editor, build a JSON file with the following
format:
[ { "name": "Oglaf!", "feedUrl": "https://www.oglaf.com/feeds/rss/", "webhooks": [ // Test webhook from Discord's documentation. "https://discord.com/api/webhooks/223704706495545344/3d89bb7572e0fb30d8128367b3b1b44fecd1726de135cbe28a41f8b2f777c372ba2939e72279b94526ff5d1bd4358d65cf11" ], "imageSelector": "img#strip" }, // Additional comic configurations, if desired. { // Another comic configuration. }, { // Another comic configuration. } ]
name: the name of the comic.feedUrl: the URL of the comic feed (e.g. an RSS feed).webhooks: a list of Discord webhook URLs to send updates to.imageSelector: the CSS selector for the comic image.altTextSelector(optional): if alt text isn't present on the comic img element, you can provide the CSS selector for any alt text.nextPageSelector(optional): the CSS selector for the link to the next comic page — this allows all pages from a multipage update to be retrieved.
- Remove all comments and unnecessary trailing commas:
- Before:
{ "name": "Oglaf!", "feedUrl": "https://www.oglaf.com/feeds/rss/", "webhooks": [ "https://discord.com/api/webhooks/223704706495545344/3d89bb7572e0fb30d8128367b3b1b44fecd1726de135cbe28a41f8b2f777c372ba2939e72279b94526ff5d1bd4358d65cf11", // 👆 the above line has a trailing comma that should be removed. ], "imageSelector": "img#strip", // 👆 the above line has a trailing comma that should be removed. }
- After:
{ "name": "Oglaf!", "feedUrl": "https://www.oglaf.com/feeds/rss/", "webhooks": [ "https://discord.com/api/webhooks/223704706495545344/3d89bb7572e0fb30d8128367b3b1b44fecd1726de135cbe28a41f8b2f777c372ba2939e72279b94526ff5d1bd4358d65cf11" ], "imageSelector": "img#strip" }
- Before:
- In the Cloudflare KV storage attached to this worker, add a new entry with
the following:
- Key:
index - Value: use the value from step 2.
- Key:
- Install pnpm.
- If Node.js also needs to be installed, you can use the following command:
pnpm env use --global lts
- If Node.js also needs to be installed, you can use the following command:
- Install dependencies with:
pnpm install --frozen-lockfile
- Create a
.envfile in the root of your project with the following info:WEBHOOK="<your Discord channel's webhook URL>"
- Run the following command:
pnpm run tests:e2e