mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
0.20.2 - MessageIsNotModifierException
This commit is contained in:
parent
fdf45d7566
commit
5249fb517f
@ -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:
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user