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