feat: Add telegram bot to the config
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
cf706d1717
commit
68cd88e96a
1 changed files with 16 additions and 0 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue