Skip to main content

Send Photo

Add imports:

using Telega.Rpc.Dto.Functions.Users;
using Telega.Rpc.Dto.Types;

Download photo:

var photoUrl = "https://cdn1.img.jp.sputniknews.com/images/406/99/4069980.png";
var webClient = new System.Net.WebClient();
var photo = await webClient.DownloadDataTaskAsync(photoUrl);

Upload photo:

var tgPhoto = await tg.Upload.UploadFile(
"photo.png",
photo.Length,
new System.IO.MemoryStream(photo)
);

Send photo:

var recipient = new InputPeer.SelfTag();
await tg.Messages.SendPhoto(
peer: recipient,
file: tgPhoto,
message: ""
);