diff --git a/CHANGELOG.md b/CHANGELOG.md index adf3a1ebd6..ead3c0088d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ * Now in forward info you can get `ForwardFromSupergroupInfo` * **BREAKING CHANGE** `SendVoice` factory function has changed its signature: now it have now `thumb` (according to the [documentation](https://core.telegram.org/bots/api#sendvoice)) + * `AudioFile` now can be converted to `VoiceFile` + * `VoiceFile` now can be converted to `AudioFile` * `TelegramBotAPI-extensions-api`: * ALL REQUESTS EXECUTOR USAGES WERE REPLACED WITH `TelegramBot` TYPEALIAS. It should not bring any break changes * Internal changes of `sendRegularPoll` and `sendQuizPoll` extensions diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt index 3e4268ea7f..af686eda9b 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/AudioFile.kt @@ -24,3 +24,5 @@ data class AudioFile( override val fileSize: Long? = null, override val thumb: PhotoSize? = null ) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, Performerable + +fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt index ea79bd61ea..f2bea226f2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/VoiceFile.kt @@ -20,3 +20,8 @@ data class VoiceFile( @SerialName(fileSizeField) override val fileSize: Long? = null ) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile + +fun VoiceFile.asAudioFile( + performer: String? = null, + title: String? = null +) = AudioFile(fileId, fileUniqueId, duration, performer, title, mimeType, fileSize)