feat: update this highly outdated app to use latest packages and custom configs (#1)

Reviewed-on: https://codeberg.org/nhcarrigan/tingle-bot/pulls/1
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
2024-09-26 19:46:33 +00:00
committed by Naomi the Technomancer
parent 1339b63378
commit 7c0bd7ad10
74 changed files with 6348 additions and 8905 deletions

View File

@ -1,37 +1,34 @@
import { AttachmentData } from "../../interfaces/commands/AttachmentData";
import { WeatherForecast } from "../../interfaces/weather/WeatherForecast";
import { getBannerImage } from "./getBannerImage";
import { getOverlayImage } from "./getOverlayImage";
import { overlayImages } from "./overlayImages";
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { getBannerImage } from "./getBannerImage.js";
import { getOverlayImage } from "./getOverlayImage.js";
import { overlayImages } from "./overlayImages.js";
import type { AttachmentData }
from "../../interfaces/commands/attachmentData.js";
import type { WeatherForecast }
from "../../interfaces/weather/weatherForecast.js";
/**
* Generates the banner image. If an overlay is available, constructs a new banner image by overlaying the overlay on the banner.
* Otherwise, returns the banner itself.
*
* @param {WeatherForecast} forecast The weather forecast.
* @returns {AttachmentData} The banner image attachment data.
* @param forecast - The weather forecast.
* @returns The banner image attachment data.
*/
export const generateBanner = async (
forecast: WeatherForecast
export const generateBanner = async(
forecast: WeatherForecast,
): Promise<AttachmentData> => {
const background = getBannerImage(forecast.region);
const overlayQuery =
forecast.special?.name === "Blight Rain"
const overlayQuery
= forecast.special?.name === "Blight Rain"
? "Blight Rain"
: forecast.precipitation?.name;
if (!overlayQuery) {
return background;
}
const overlayPath = getOverlayImage(overlayQuery ?? null);
const overlayPath = getOverlayImage(overlayQuery);
if (!overlayPath) {
return background;
}
const overlay = await overlayImages(background.filePath, overlayPath);
const overlay = await overlayImages(background.filePath, overlayPath ?? "");
return overlay;
};