Feature: BotNotificator #18

Merged
akulij merged 13 commits from dev into main 2025-06-02 11:54:14 +00:00
Showing only changes of commit 91bf739365 - Show all commits

View File

@ -604,12 +604,13 @@ impl Parcelable<BotFunction> for BotDialog {
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum NotificationTime { pub enum NotificationTime {
Delta(Duration), Delta(isize),
Specific(SpecificTime), Specific(SpecificTime),
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(try_from = "SpecificTimeFormat")] #[serde(try_from = "SpecificTimeFormat")]
pub struct SpecificTime { pub struct SpecificTime {
hour: u8, hour: u8,
@ -645,18 +646,27 @@ impl TryFrom<SpecificTimeFormat> for SpecificTime {
} }
#[derive(Serialize, Deserialize, Default, Debug, Clone)] #[derive(Serialize, Deserialize, Default, Debug, Clone)]
#[serde(untagged)]
pub enum NotificationFilter { pub enum NotificationFilter {
#[default] #[default]
#[serde(rename = "all")]
All, All,
/// Send to randomly selected N people /// Send to randomly selected N people
Random(usize), Random { random: u8 },
/// Function that returns list of user id's who should get notification /// Function that returns list of user id's who should get notification
BotFunction(BotFunction), BotFunction(BotFunction),
} }
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum NotificationMessage { pub enum NotificationMessage {
Literal(String), Literal {
literal: String,
},
Text {
text: String,
},
/// Function can accept user which will be notified and then return generated message
BotFunction(BotFunction), BotFunction(BotFunction),
} }