From 68cd88e96af0cd92c10e30ec9675f003c89c436f Mon Sep 17 00:00:00 2001 From: Awiteb Date: Thu, 14 Nov 2024 12:26:06 +0000 Subject: [PATCH] feat: Add telegram bot to the config Signed-off-by: Awiteb --- src/config.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/config.rs b/src/config.rs index 9af9836..5733e42 100644 --- a/src/config.rs +++ b/src/config.rs @@ -21,8 +21,11 @@ pub(crate) const DEFAULT_CONFIG_PATH: &str = "/app/forgejo-guardian.toml"; use regex::Regex; use serde::{de, Deserialize}; +use teloxide::types::ChatId; use url::Url; +use crate::telegram_bot::Lang; + /// Deserialize a string into a `url::Url` /// /// This will check if the url is `http` or `https` and if it is a valid url @@ -64,6 +67,17 @@ pub struct Forgejo { pub instance: Url, } +/// The telegram bot configuration +#[derive(Deserialize)] +pub struct Telegram { + /// Telegram bot token + pub token: String, + /// Chat to send the alert in + pub chat: ChatId, + /// Bot language + pub lang: Lang, +} + /// The expression #[derive(Deserialize, Debug, Default)] pub struct Expr { @@ -126,6 +140,8 @@ pub struct Exprs { pub struct Config { /// Configuration for the forgejo guard itself pub forgejo: Forgejo, + /// Configuration of the telegram bot + pub telegram: Telegram, /// The expressions, which are used to determine the actions #[serde(default)] pub expressions: Exprs,