diff --git a/src/RxTelegram.Bot/Interface/ChatBackground/BackgroundTypeWallpaper.cs b/src/RxTelegram.Bot/Interface/ChatBackground/BackgroundTypeWallpaper.cs index a55a8d9..45eee6b 100644 --- a/src/RxTelegram.Bot/Interface/ChatBackground/BackgroundTypeWallpaper.cs +++ b/src/RxTelegram.Bot/Interface/ChatBackground/BackgroundTypeWallpaper.cs @@ -1,6 +1,31 @@ +using RxTelegram.Bot.Interface.BaseTypes; + namespace RxTelegram.Bot.Interface.ChatBackground; -public class BackgroundTypeWallpaper +public class BackgroundTypeWallpaper : BackgroundType { - + /// + /// Type of the background, always “wallpaper” + /// + public override string Type { get; } = "wallpaper"; + + /// + /// Document with the wallpaper + /// + public Document Document { get; set; } + + /// + /// Dimming of the background in dark themes, as a percentage; 0-100 + /// + public int DarkThemeDimming { get; set; } + + /// + /// Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 + /// + public bool IsBlurred { get; set; } + + /// + /// Optional. True, if the background moves slightly when the device is tilted + /// + public bool IsMoving { get; set; } } diff --git a/src/RxTelegram.Bot/Utils/HexToRGB24Converter.cs b/src/RxTelegram.Bot/Utils/HexToRGB24Converter.cs new file mode 100644 index 0000000..b530820 --- /dev/null +++ b/src/RxTelegram.Bot/Utils/HexToRGB24Converter.cs @@ -0,0 +1,26 @@ +using System; +using System.Globalization; + +namespace RxTelegram.Bot.Utils; + +public class HexToRgb24 +{ + public int Convert(string hexColor) => int.Parse(FormatHexString(hexColor), NumberStyles.HexNumber); + + public bool TryConvert(string hexColor, out int result) => int.TryParse(FormatHexString(hexColor), NumberStyles.HexNumber, null, out result); + + private static string FormatHexString(string hexColor) + { + hexColor = hexColor.TrimStart('#'); + if (hexColor.Length == 3) + { + hexColor = string.Concat(hexColor[0], hexColor[0], hexColor[1], hexColor[1], hexColor[2], hexColor[2]); + } + else if (hexColor.Length != 6) + { + throw new ArgumentException("Hex color must be 3 or 6 characters long."); + } + + return hexColor; + } +}