using BotFramework; using BotFramework.Attributes; using BotFramework.Enums; using SixLabors.ImageSharp; using Telegram.Bot; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; namespace West.TelegramBot.StickerTools; public class Handler : BotEventHandler { [Command("png", CommandParseMode.Both)] public async Task Sticker2Png() { var sticker = RawUpdate.Message?.ReplyToMessage?.Sticker; if (sticker == null || sticker.IsAnimated || sticker.IsVideo) { return; } await Bot.SendChatAction(Chat.Id, ChatAction.UploadDocument); using var file = new MemoryStream(); await Bot.GetInfoAndDownloadFile(sticker.FileId, file); file.Position = 0; using var img = await Image.LoadAsync(file); await file.DisposeAsync(); using var outfile = new MemoryStream(); await img.SaveAsPngAsync(outfile); outfile.Position = 0; await Bot.SendDocument(Chat.Id, new InputFileStream(outfile, "sticker.png"), replyParameters: RawUpdate?.Message?.MessageId); } }