mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
apply length restrictions to all textable send requests
This commit is contained in:
parent
eab147a38f
commit
2af4ebcd44
@ -13,6 +13,7 @@
|
||||
### 0.9.1
|
||||
|
||||
* Updated built-in lengths restrictions
|
||||
* Apply restrictions of text limit for sending messages
|
||||
|
||||
### 0.8.5
|
||||
|
||||
|
@ -35,6 +35,11 @@ data class SendMessage(
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
DisableWebPagePreview
|
||||
{
|
||||
init {
|
||||
if (text.length !in textLength) {
|
||||
throw IllegalArgumentException("Text must be in $textLength range")
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendMessage"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -95,6 +95,13 @@ data class SendAnimationData internal constructor(
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
SizedSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAnimation"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -95,6 +95,13 @@ data class SendAudioData internal constructor(
|
||||
TitledSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendAudio"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -78,6 +78,13 @@ data class SendDocumentData internal constructor(
|
||||
TextableSendMessageRequest<RawMessage>,
|
||||
ThumbedSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendDocument"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -63,6 +63,14 @@ data class SendPhotoData internal constructor(
|
||||
ReplyingMarkupSendMessageRequest<RawMessage>,
|
||||
TextableSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendPhoto"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
}
|
||||
|
@ -100,6 +100,13 @@ data class SendVideoData internal constructor(
|
||||
DuratedSendMessageRequest<RawMessage>,
|
||||
SizedSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideo"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -94,6 +94,13 @@ data class SendVideoNoteData internal constructor(
|
||||
override val height: Int?
|
||||
get() = width
|
||||
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVideoNote"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
@ -84,6 +84,13 @@ data class SendVoiceData internal constructor(
|
||||
ThumbedSendMessageRequest<RawMessage>,
|
||||
DuratedSendMessageRequest<RawMessage>
|
||||
{
|
||||
init {
|
||||
text ?.let {
|
||||
if (it.length !in captionLength) {
|
||||
throw IllegalArgumentException("Caption must be in $captionLength range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "sendVoice"
|
||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||
|
Loading…
Reference in New Issue
Block a user