diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fdc74e19..f40916f633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ * A lot of `TextSource` implementors was added. More info [here](src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/) * All `MessageEntity` implementations now are using new `TextSource` analogues as delegates +### 0.20.2 + +* New exception type `MessageIsNotModifierException` was added + ## 0.19.0 ImplicitReflection removing * Total rework of serialization for requests. Now all `SimpleRequest` children have: diff --git a/build.gradle b/build.gradle index df3dce2e6c..b74193cccf 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" } -project.version = "0.20.1" +project.version = "0.20.2" project.group = "com.github.insanusmokrassar" apply from: "publish.gradle" diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt index 6cdcbfcd34..63f777b830 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/exceptions/RequestException.kt @@ -8,11 +8,14 @@ fun newRequestException( plainAnswer: String, message: String? = null, cause: Throwable? = null -) = when (response.description) { - "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause) - "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause) - else -> CommonRequestException(response, plainAnswer, message, cause) -} +) = response.description ?.let { description -> + when { + description == "Bad Request: reply message not found" -> ReplyMessageNotFoundException(response, plainAnswer, message, cause) + description.contains("Bad Request: message is not modified") -> MessageIsNotModifierException(response, plainAnswer, message, cause) + description == "Unauthorized" -> UnauthorizedException(response, plainAnswer, message, cause) + else -> null + } +} ?: CommonRequestException(response, plainAnswer, message, cause) sealed class RequestException constructor( val response: Response, @@ -32,3 +35,6 @@ class UnauthorizedException(response: Response, plainAnswer: String, message: St class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : RequestException(response, plainAnswer, message, cause) + +class MessageIsNotModifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : + RequestException(response, plainAnswer, message, cause)