bot.sendphoto does not work asp.net

旧巷老猫 提交于 2019-12-24 07:40:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!