При отправке через Bot.SendPhotoAsyn c изображение теряет качество, я решил использовать Bot.SendDocumentAsyn c, но файл отправляется без расширения и с именем «document». Снимок экрана https://imgur.com/a/VkKQ5ex
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - SendPhotoAsyn c
case "/screenshot":
await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.UploadDocument);
Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
bitmap.Save("C:/Windows/Temp/screen.jpg", ImageFormat.Jpeg);
}
const string screen = @"C:/Windows/Temp/screen.jpg";
using (var fileStream = new FileStream(screen, FileMode.Open, FileAccess.Read, FileShare.Read))
{
await Bot.SendPhotoAsync(
chatId: message.Chat.Id,
photo: new InputOnlineFile(fileStream),
caption: "Screenshot !"
);
}
break;
- = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - SendDocumentAsyn c
case "/screenshot":
await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.UploadDocument);
Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
bitmap.Save("C:/Windows/Temp/screen.jpg", ImageFormat.Jpeg);
}
const string screen = @"C:/Windows/Temp/screen.jpg";
using (var fileStream = new FileStream(screen, FileMode.Open, FileAccess.Read, FileShare.Read))
{
await Bot.SendDocumentAsync(
chatId: message.Chat.Id,
document: new InputOnlineFile(fileStream),
caption: "Screenshot!"
);
}
break;