diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 88319639..d2626231 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -3,6 +3,7 @@ pub use allowed_update::*; pub use animation::*; pub use audio::*; +pub use background_fill::*; pub use birthdate::*; pub use bot_command::*; pub use bot_command_scope::*; @@ -168,6 +169,7 @@ pub use write_access_allowed::*; mod allowed_update; mod animation; mod audio; +mod background_fill; mod birthdate; mod bot_command; mod bot_command_scope; diff --git a/crates/teloxide-core/src/types/background_fill.rs b/crates/teloxide-core/src/types/background_fill.rs new file mode 100644 index 00000000..6e45f0a7 --- /dev/null +++ b/crates/teloxide-core/src/types/background_fill.rs @@ -0,0 +1,52 @@ +use serde::{Deserialize, Serialize}; + +use crate::types::Rgb; + +/// This object describes the way a background is filled based on the selected +/// colors. +#[derive(Clone, Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +#[serde(tag = "type")] +pub enum BackgroundFill { + Solid(BackgroundFillSolid), + Gradient(BackgroundFillGradient), + FreeformGradient(BackgroundFillFreeformGradient), +} + +/// The background is filled using the selected color. +#[derive(Clone, Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Serialize, Deserialize)] +pub struct BackgroundFillSolid { + /// The color of the background fill in the RGB24 format + pub color: Rgb, +} + +/// The background is a gradient fill. +#[derive(Clone, Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Serialize, Deserialize)] +pub struct BackgroundFillGradient { + /// Top color of the gradient in the RGB24 format + pub top_color: Rgb, + + /// Bottom color of the gradient in the RGB24 format + pub bottom_color: Rgb, + + /// Clockwise rotation angle of the background fill in degrees; 0-359 + // FIXME: use/add a specialized rotation type? + pub rotation_angle: u16, +} + +/// The background is a freeform gradient that rotates after every message in +/// the chat. +#[derive(Clone, Debug)] +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Serialize, Deserialize)] +pub struct BackgroundFillFreeformGradient { + /// A list of the 3 or 4 base colors that are used to generate the freeform + /// gradient in the RGB24 format + pub colors: Vec, +}