From 461abf187232ccbdb2c751146e0aec5aec35e063 Mon Sep 17 00:00:00 2001 From: Niklas Elsbrock Date: Sat, 11 Nov 2023 20:26:49 +0100 Subject: [PATCH] add variable embed colours --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a19df8a..2bf2ca9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,8 +69,15 @@ impl DisbahnClient { } } + fn icon_name_to_colour(name: &str) -> u32 { + match name { + "HIM1" => 0xf5c211, + "HIM2" => 0xc1121c, + _ => 0x154889, + } + } + fn item_to_embed(item: &rss::Item) -> anyhow::Result { - const COLOUR: u32 = 0x008d4f; const FOOTER_ICON_URL: &str = "https://www.zuginfo.nrw/img/customer/apple-touch-icon.png"; let categories = item.categories(); @@ -116,7 +123,7 @@ impl DisbahnClient { e.title(title) .url(link) .thumbnail(icon_url) - .colour(COLOUR) + .colour(Self::icon_name_to_colour(icon)) .description(description) .field("Beginn:", format!("", validity_begin), true) .field("Ende:", format!("", validity_end), true)