/// <summary> /// Sends a string as a text file. /// </summary> /// <param name="filename">Filename.</param> /// <param name="text">The string to send.</param> /// <inheritdoc cref="TelegramBotClientExtensions.SendDocumentAsync(ITelegramBotClient, ChatId, InputOnlineFile, InputMedia?, string?, ParseMode?, IEnumerable{MessageEntity}?, bool?, bool?, int?, bool?, IReplyMarkup?, CancellationToken)"/> public static async Task <Message> SendTextFileFromStringAsync( this ITelegramBotClient botClient, ChatId chatId, string filename, string text, InputMedia?thumb = null, string?caption = null, ParseMode?parseMode = null, IEnumerable <MessageEntity>?captionEntities = null, bool?disableContentTypeDetection = null, bool?disableNotification = null, bool?protectContent = null, int?replyToMessageId = null, bool?allowSendingWithoutReply = null, IReplyMarkup?replyMarkup = null, CancellationToken cancellationToken = default) { await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(text)); return(await botClient.SendDocumentAsync(chatId, new(stream, filename), thumb, caption, parseMode, captionEntities, disableContentTypeDetection, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, cancellationToken)); }
public DocumentMessage(InputOnlineFile document, string?caption = null, ParseMode?parseMode = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, InputMedia?thumb = null, ChatId?chatId = null) { Document = document; Caption = caption; ParseMode = parseMode ?? ParseModeExtensions.RecognizeSuitableParseMode(caption); ReplyToMessageId = replyToMessageId; DisableNotification = disableNotification; ReplyMarkup = replyMarkup; Thumb = thumb; ChatId = chatId; }
public VideoNoteMessage(InputTelegramFile videoNote, int duration = 0, int length = 0, InputMedia?thumb = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, ChatId?chatId = null) { VideoNote = videoNote; Duration = duration; Length = length; Thumb = thumb; ReplyToMessageId = replyToMessageId; DisableNotification = disableNotification; ReplyMarkup = replyMarkup; ChatId = chatId; }
public AudioMessage(InputOnlineFile audio, string?caption = null, ParseMode?parseMode = null, int duration = 0, string?performer = null, string?title = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, InputMedia?thumb = null, ChatId?chatId = null) { Audio = audio; Caption = caption; ParseMode = parseMode ?? ParseModeExtensions.RecognizeSuitableParseMode(caption); Duration = duration; Performer = performer; Title = title; DisableNotification = disableNotification; ReplyToMessageId = replyToMessageId; ReplyMarkup = replyMarkup; Thumb = thumb; ChatId = chatId; }
public AnimationMessage(InputOnlineFile animation, int duration = 0, int width = 0, int height = 0, InputMedia?thumb = null, string?caption = null, ParseMode?parseMode = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, ChatId?chatId = null) { Animation = animation; Duration = duration; Width = width; Height = height; Thumb = thumb; Caption = caption; ParseMode = parseMode ?? ParseModeExtensions.RecognizeSuitableParseMode(caption); ReplyToMessageId = replyToMessageId; DisableNotification = disableNotification; ReplyMarkup = replyMarkup; ChatId = chatId; }
/// <summary> /// Sends a file with auto retry to work around Telegram API's rate limit. /// </summary> /// <inheritdoc cref="TelegramBotClientExtensions.SendDocumentAsync(ITelegramBotClient, ChatId, InputOnlineFile, InputMedia?, string?, ParseMode?, IEnumerable{MessageEntity}?, bool?, bool?, bool?, int?, bool?, IReplyMarkup?, CancellationToken)"/> public static async Task <Message> SendDocumentWithRetryAsync( this ITelegramBotClient botClient, ChatId chatId, InputOnlineFile document, InputMedia?thumb = null, string?caption = null, ParseMode?parseMode = null, IEnumerable <MessageEntity>?captionEntities = null, bool?disableContentTypeDetection = null, bool?disableNotification = null, bool?protectContent = null, int?replyToMessageId = null, bool?allowSendingWithoutReply = null, IReplyMarkup?replyMarkup = null, CancellationToken cancellationToken = default) { while (true) { try { return(await botClient.SendDocumentAsync(chatId, document, thumb, caption, parseMode, captionEntities, disableContentTypeDetection, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, cancellationToken)); } catch (ApiRequestException ex) when(ex.ErrorCode == 429) { await Task.Delay(GetRetryWaitTimeMs(ex), cancellationToken); } } }
public DocumentMessage(string document, string?caption = null, ParseMode?parseMode = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, InputMedia?thumb = null, ChatId?chatId = null) : this(new InputOnlineFile(document), caption, parseMode, disableNotification, replyToMessageId, replyMarkup, thumb, chatId) { }
public AudioMessage(string audio, string?caption = null, ParseMode?parseMode = null, int duration = 0, string?performer = null, string?title = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, InputMedia?thumb = null, ChatId?chatId = null) : this(new InputOnlineFile(audio), caption, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup, thumb, chatId) { }
public AnimationMessage(string animation, int duration = 0, int width = 0, int height = 0, InputMedia?thumb = null, string?caption = null, ParseMode?parseMode = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, ChatId?chatId = null) : this(new InputOnlineFile(animation), duration, width, height, thumb, caption, parseMode, disableNotification, replyToMessageId, replyMarkup, chatId) { }
public VideoNoteMessage(string videoNote, int duration = 0, int length = 0, InputMedia?thumb = null, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, ChatId?chatId = null) : this(new InputTelegramFile(videoNote), duration, length, thumb, disableNotification, replyToMessageId, replyMarkup, chatId) { }
public VideoMessage(string video, int duration = 0, int width = 0, int height = 0, InputMedia?thumb = null, string?caption = null, ParseMode?parseMode = null, bool supportsStreaming = false, bool disableNotification = false, int replyToMessageId = 0, IReplyMarkup?replyMarkup = null, ChatId?chatId = null) : this(new InputOnlineFile(video), duration, width, height, thumb, caption, parseMode, supportsStreaming, disableNotification, replyToMessageId, replyMarkup, chatId) { }