private void SendPhoto(TelegramMessageWebHook receivedMessage, string urlPhoto, string caption, bool replyMessage = false)
        {
            string[] ListButton1 = { "Today", "Yesterday", "Tomorrow" };
            string[] ListButton2 = { "Back", "All Days", "Exit" };
            var      message     = new TelegramSendPhoto
            {
                ChatId = receivedMessage.MessageReceived.ReceivedChat.ChatId,
                DisableNotification   = false,
                DisableWebPagePreview = false,
                UrlPhoto    = urlPhoto,
                ParseMode   = "HTML",
                ReplyMarkup = new TelegramMessageBase.Reply_Markup
                {
                    Keyboard        = new string[][] { ListButton1, ListButton2 },
                    OneTimeKeyboard = true,
                    ResizeKeyboard  = true,
                    Selective       = true
                },
                ReplyToMessageId = replyMessage ? receivedMessage.MessageReceived.MessageId.ToString() : ""
            };

            message.SetCaption(caption);

            SendPhoto(message);
        }
        public TelegramMessageSendReturn SendPhoto(TelegramSendPhoto message)
        {
            var returnRequest = new TelegramMessageSendReturn();
            var URL           = $"https://api.telegram.org/bot{IdBot}/sendPhoto";

            using (HttpClient client = new HttpClient())
            {
                var response = client.PostAsJsonAsync <TelegramSendPhoto>(URL, message).Result;
                returnRequest = response.Content.ReadAsAsync <TelegramMessageSendReturn>().Result;
            }

            return(returnRequest);
        }
示例#3
0
        public ActionResult <string> index([FromServices] ITelegramService _telegramService, TelegramSendPhoto telegramSendPhoto)
        {
            var res = _telegramService.SendPhoto(telegramSendPhoto);

            return("Ok! =)");
        }