/// <summary> /// Sends a possibly long text message. /// Short messages are sent as text messages. /// Long messages are sent as text files. /// </summary> /// <inheritdoc cref="TelegramBotClientExtensions.SendTextMessageAsync(ITelegramBotClient, ChatId, string, ParseMode?, IEnumerable{MessageEntity}?, bool?, bool?, int?, bool?, IReplyMarkup?, CancellationToken)"/> public static Task SendPossiblyLongTextMessageAsync( this ITelegramBotClient botClient, ChatId chatId, string text, ParseMode?parseMode = null, IEnumerable <MessageEntity>?entities = null, bool?disableWebPagePreview = null, bool?disableNotification = null, bool?protectContent = null, int?replyToMessageId = null, bool?allowSendingWithoutReply = null, IReplyMarkup?replyMarkup = null, CancellationToken cancellationToken = default) { if (text.Length <= 4096) { return(botClient.SendTextMessageAsync(chatId, text, parseMode, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, cancellationToken)); } else // too large, send as file { var filename = parseMode switch { ParseMode.Markdown => "long-message.md", ParseMode.Html => "long-message.html", ParseMode.MarkdownV2 => "long-message.md", _ => "long-message.txt", }; return(botClient.SendTextFileFromStringAsync(chatId, filename, text, null, null, parseMode, entities, null, disableNotification, protectContent, replyToMessageId, null, replyMarkup, cancellationToken)); } }