mirror of
https://github.com/nelsbrock/disbahn.git
synced 2026-08-14 22:26:49 +02:00
remove thumbnail and use author feature for category
This commit is contained in:
+12
-8
@@ -1,5 +1,7 @@
|
||||
pub mod database;
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use crate::database::models::{NewPost, Post};
|
||||
use crate::database::schema::posts::dsl::posts;
|
||||
use crate::database::Database;
|
||||
@@ -9,7 +11,9 @@ use diesel::{ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl};
|
||||
use lazy_regex::{regex, Lazy, Regex};
|
||||
use log::{debug, error, info};
|
||||
use reqwest::IntoUrl;
|
||||
use serenity::all::{CreateEmbed, CreateEmbedFooter, EditWebhookMessage, ExecuteWebhook};
|
||||
use serenity::all::{
|
||||
CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, EditWebhookMessage, ExecuteWebhook,
|
||||
};
|
||||
use serenity::http::Http;
|
||||
use serenity::model::webhook::Webhook;
|
||||
|
||||
@@ -60,12 +64,12 @@ impl DisbahnClient {
|
||||
input.to_string()
|
||||
}
|
||||
|
||||
fn icon_name_to_url(name: &str) -> &str {
|
||||
fn icon_name_to_tag(name: &str) -> Cow<'static, str> {
|
||||
match name {
|
||||
"HIM1" => "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Zeichen_123_-_Arbeitsstelle%2C_StVO_2013.svg/273px-Zeichen_123_-_Arbeitsstelle%2C_StVO_2013.svg.png",
|
||||
"HIM2" => "https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Zeichen_101_-_Gefahrstelle%2C_StVO_1970.svg/273px-Zeichen_101_-_Gefahrstelle%2C_StVO_1970.svg.png",
|
||||
"HIM3" => "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/Strike_worker.svg/314px-Strike_worker.svg.png",
|
||||
_ => "https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Zeichen_365-61_-_Informationsstelle%2C_StVO_2013.svg/240px-Zeichen_365-61_-_Informationsstelle%2C_StVO_2013.svg.png",
|
||||
"HIM1" => "\u{1F6A7} Bauarbeiten".into(),
|
||||
"HIM2" => "\u{26A0}\u{FE0F} Störung".into(),
|
||||
"HIM3" => "\u{270A} Streik".into(),
|
||||
other => format!("\u{2139}\u{FE0F} Information ({other})").into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +107,7 @@ impl DisbahnClient {
|
||||
.iter()
|
||||
.find(|c| c.domain() == Some("icon"))
|
||||
.map_or("", |c| c.name());
|
||||
let icon_url = Self::icon_name_to_url(icon);
|
||||
let tag = Self::icon_name_to_tag(icon);
|
||||
|
||||
let description = Self::html_to_discord_markdown(
|
||||
item.description().ok_or(anyhow!("Missing description"))?,
|
||||
@@ -118,7 +122,7 @@ impl DisbahnClient {
|
||||
let embed = CreateEmbed::new()
|
||||
.title(title)
|
||||
.url(link)
|
||||
.thumbnail(icon_url)
|
||||
.author(CreateEmbedAuthor::new(tag))
|
||||
.colour(Self::icon_name_to_colour(icon))
|
||||
.description(description)
|
||||
.field("Beginn:", format!("<t:{validity_begin}:f>"), true)
|
||||
|
||||
Reference in New Issue
Block a user