feat: Add telegram bot to the config

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-11-14 12:26:06 +00:00
parent cf706d1717
commit 68cd88e96a
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -21,8 +21,11 @@ pub(crate) const DEFAULT_CONFIG_PATH: &str = "/app/forgejo-guardian.toml";
use regex::Regex; use regex::Regex;
use serde::{de, Deserialize}; use serde::{de, Deserialize};
use teloxide::types::ChatId;
use url::Url; use url::Url;
use crate::telegram_bot::Lang;
/// Deserialize a string into a `url::Url` /// Deserialize a string into a `url::Url`
/// ///
/// This will check if the url is `http` or `https` and if it is a valid 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, 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 /// The expression
#[derive(Deserialize, Debug, Default)] #[derive(Deserialize, Debug, Default)]
pub struct Expr { pub struct Expr {
@ -126,6 +140,8 @@ pub struct Exprs {
pub struct Config { pub struct Config {
/// Configuration for the forgejo guard itself /// Configuration for the forgejo guard itself
pub forgejo: Forgejo, pub forgejo: Forgejo,
/// Configuration of the telegram bot
pub telegram: Telegram,
/// The expressions, which are used to determine the actions /// The expressions, which are used to determine the actions
#[serde(default)] #[serde(default)]
pub expressions: Exprs, pub expressions: Exprs,