From 7ca93042b77eed17c202d73d3ce46a5e0a7e0bc8 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 7 Apr 2026 12:36:27 +0300 Subject: [PATCH] make `is_live`, `is_short`, `is_upcoming` optional --- example/config.toml | 6 +++--- src/config/channel.rs | 6 +++--- src/main.rs | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/example/config.toml b/example/config.toml index 40c4db6..e34f663 100644 --- a/example/config.toml +++ b/example/config.toml @@ -13,9 +13,9 @@ sleep = 1 [channel.test] id = "UCl2mFZoRqjw_ELax4Yisf6w" # channel ID - is_live = false - is_short = false - is_upcoming = false + # is_live = false + # is_short = false + # is_upcoming = false # items_limit = 1 # item_name_regex = ".*" diff --git a/src/config/channel.rs b/src/config/channel.rs index f0dab3d..027edf6 100644 --- a/src/config/channel.rs +++ b/src/config/channel.rs @@ -8,9 +8,9 @@ use serde::Deserialize; pub struct Channel { pub id: String, pub command: Vec, - pub is_live: bool, - pub is_short: bool, - pub is_upcoming: bool, + pub is_live: Option, + pub is_short: Option, + pub is_upcoming: Option, pub items_limit: Option, #[serde(default)] #[serde(with = "serde_regex")] diff --git a/src/main.rs b/src/main.rs index 44904ec..ff64d55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,21 +79,30 @@ async fn main() { item.id ), } - if item.is_live != channel.is_live { + if channel + .is_live + .is_some_and(|is_live| item.is_live != is_live) + { debug!( "skip item `{}` for channel `{c}` by `is_live` filter (item: {:?}/config:{:?})", item.id, item.is_live, channel.is_live ); continue; } - if item.is_short != channel.is_short { + if channel + .is_short + .is_some_and(|is_short| item.is_short != is_short) + { debug!( "skip item `{}` for channel `{c}` by `is_short` filter (item: {:?}/config:{:?})", item.id, item.is_short, channel.is_short ); continue; } - if item.is_upcoming != channel.is_upcoming { + if channel + .is_upcoming + .is_some_and(|is_upcoming| item.is_upcoming != is_upcoming) + { debug!( "skip item `{}` for channel `{c}` by `is_upcoming` filter (item: {:?}/config:{:?})", item.id, item.is_upcoming, channel.is_upcoming