diff --git a/CHANGELOG.md b/CHANGELOG.md index 36017cd539..9bf9231fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * `API`: * Add opportunity to `reply` with `Poll` * Add opportunity to `reply` with any `MessageContent` + * Add opportunity to `reply` with any `TelegramMediaFile` ## 0.38.10 diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt index 9dadb6e31a..0ee552946d 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/Replies.kt @@ -17,12 +17,14 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.chat.abstracts.Chat import dev.inmo.tgbotapi.types.dice.DiceAnimationType import dev.inmo.tgbotapi.types.files.* +import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile import dev.inmo.tgbotapi.types.files.sticker.Sticker import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent +import dev.inmo.tgbotapi.types.passport.encrypted.PassportFile import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.polls.* @@ -993,3 +995,79 @@ suspend fun TelegramBot.reply( ) ) } + +suspend fun TelegramBot.reply( + to: Message, + mediaFile: TelegramMediaFile, + disableNotification: Boolean = false, + protectContent: Boolean = false, + allowSendingWithoutReply: Boolean? = null, + replyMarkup: KeyboardMarkup? = null +) { + when (mediaFile) { + is AudioFile -> reply( + to = to, + audio = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is AnimationFile -> reply( + to = to, + animation = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is VoiceFile -> reply( + to = to, + voice = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is VideoFile -> reply( + to = to, + video = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is VideoNoteFile -> reply( + to = to, + videoNote = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is DocumentFile -> reply( + to = to, + document = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + is Sticker -> reply( + to = to, + sticker = mediaFile, + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + else -> reply( + to = to, + document = mediaFile.asDocumentFile(), + disableNotification = disableNotification, + protectContent = protectContent, + allowSendingWithoutReply = allowSendingWithoutReply, + replyMarkup = replyMarkup + ) + } +}