问题
I have a problem when I use the following code:
try
{
var url = "https://www.telegadmin.com/image/tinakish/qavasi.jpg";
var uri = new Uri(url);
using (WebClient webClient = new WebClient())
{
using (Stream stream = webClient.OpenRead(uri))
{
//bot.SendTextMessageAsync(update.Message.Chat.Id, "تا اینجا اوکیه", replyMarkup: mainMenu);
bot.SendPhotoAsync(update.Message.Chat.Id, new FileToSend("test.jpg", stream), caption: "این تصویر از سرور برای شما ارسال شده است", replyMarkup: mainMenu);
return Ok();
}
}
return Ok();
}
catch(Exception ex){
bot.SendTextMessageAsync(update.Message.Chat.Id,ex.ToString(), replyMarkup: mainMenu);
return Ok();
}
It's working for me in C#, but does not work in setwebhook. Can you help me?
回答1:
try this:
Bot.SendPhotoAsync(update.Message.Chat.Id, new FileToSend("test.jpeg", stream), caption: "این تصویر از سرور برای شما ارسال شده است", replyMarkup: mainMenu).GetAwaiter().GetResult();
you didn't execute the task.
来源:https://stackoverflow.com/questions/43840834/bot-sendphoto-does-not-work-asp-net