Closed Jox2y1MOQAu1NQ closed 8 months ago
private void SendMessageAlbum(long chatId) { var messageContents = new List<Telegram.Td.Api.InputMessageContent>(); foreach (string item in listBox1.Items) { if (item.Equals(string.Empty) || !System.IO.File.Exists(item)) continue; string[] strFilePath = item.Split('\\'); string[] strFileName = strFilePath[strFilePath.Length - 1].Split('.'); string strFileType = strFileName[strFileName.Length - 1].ToLower(); if (strFileType.Contains("jpg")) { messageContents.Add(new Telegram.Td.Api.InputMessagePhoto() { Photo = new Telegram.Td.Api.InputFileLocal(item), //use this did not achieve the effect Caption = new Telegram.Td.Api.FormattedText(textBox1.Text, null) }); } else if (strFileType.Contains("mp4")) { messageContents.Add(new Telegram.Td.Api.InputMessageVideo() { Video = new Telegram.Td.Api.InputFileLocal(item), Caption = new Telegram.Td.Api.FormattedText(textBox1.Text, null) }); } } if (!textBox1.Text.Equals(string.Empty)) { //use this callback 400 result //error { // code = 400 // message = "Invalid message content type" // } messageContents.Add(new Telegram.Td.Api.InputMessageText() { Text = new Telegram.Td.Api.FormattedText() { Text = textBox1.Text, } }); } var msg = new Telegram.Td.Api.SendMessageAlbum( chatId : chatId, messageThreadId:0, replyTo: null, options: new Telegram.Td.Api.MessageSendOptions(), messageContents.ToArray() ); TelegramSend(msg, TelegramSendRequestResult); }
You can't use InputMessageText in albums. Album caption is a caption of any message in the album if there is only one message with caption, so you need to add it only to one of the messages.
InputMessageText