From 7a5c9c7ef8da5a6cbc797065948200fe9d42e686 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 30 May 2024 21:58:47 +0600 Subject: [PATCH] add base support of effects --- .../abstracts/types/OptionallyWithEffectId.kt | 7 ++ .../tgbotapi/requests/send/SendContact.kt | 22 +++-- .../inmo/tgbotapi/requests/send/SendDice.kt | 5 +- .../tgbotapi/requests/send/SendLocation.kt | 46 ++++++--- .../tgbotapi/requests/send/SendMessage.kt | 6 ++ .../inmo/tgbotapi/requests/send/SendVenue.kt | 7 ++ .../abstracts/OptionallyWithEffectRequest.kt | 6 ++ .../abstracts/SendContentMessageRequest.kt | 2 +- .../tgbotapi/requests/send/games/SendGame.kt | 2 + .../requests/send/media/SendAnimation.kt | 6 ++ .../tgbotapi/requests/send/media/SendAudio.kt | 66 +++++++------ .../requests/send/media/SendDocument.kt | 58 ++++++----- .../requests/send/media/SendMediaGroup.kt | 64 +++++++++---- .../tgbotapi/requests/send/media/SendPhoto.kt | 6 ++ .../requests/send/media/SendSticker.kt | 21 ++-- .../tgbotapi/requests/send/media/SendVideo.kt | 6 ++ .../requests/send/media/SendVideoNote.kt | 26 ++--- .../tgbotapi/requests/send/media/SendVoice.kt | 54 ++++++----- .../requests/send/payments/SendInvoice.kt | 8 +- .../requests/send/polls/SendQuizPoll.kt | 18 ++++ .../requests/send/polls/SendRegularPoll.kt | 96 +++++++++++-------- .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 1 + .../message/PrivateContentMessageImpl.kt | 4 +- .../inmo/tgbotapi/types/message/RawMessage.kt | 3 +- .../abstracts/PossiblyWithEffectMessage.kt | 5 + .../abstracts/PrivateContentMessage.kt | 2 +- .../MediaGroupContentMessageCreator.kt | 3 +- 27 files changed, 362 insertions(+), 188 deletions(-) create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/OptionallyWithEffectId.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithEffectRequest.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyWithEffectMessage.kt diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/OptionallyWithEffectId.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/OptionallyWithEffectId.kt new file mode 100644 index 0000000000..0ce2e71fd7 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/abstracts/types/OptionallyWithEffectId.kt @@ -0,0 +1,7 @@ +package dev.inmo.tgbotapi.abstracts.types + +import dev.inmo.tgbotapi.types.EffectId + +interface OptionallyWithEffectId { + val effectId: EffectId? +} \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt index cddf2625c2..2e86dc0e42 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendContact.kt @@ -32,6 +32,8 @@ data class SendContact( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) @@ -46,6 +48,7 @@ data class SendContact( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): this( @@ -57,6 +60,7 @@ data class SendContact( businessConnectionId, disableNotification, protectContent, + effectId, replyParameters, replyMarkup ) @@ -74,15 +78,17 @@ fun Contact.toRequest( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): SendContact = SendContact( - chatId, - this, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + contact = this, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt index 446224f314..726a336bf2 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendDice.kt @@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.types.DisableNotification import dev.inmo.tgbotapi.abstracts.types.OptionallyBusinessConnectionRequest import dev.inmo.tgbotapi.abstracts.types.WithReplyParameters import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest +import dev.inmo.tgbotapi.requests.send.abstracts.SendContentMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup @@ -30,11 +31,13 @@ data class SendDice( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) override val replyMarkup: KeyboardMarkup? = null -) : ReplyingMarkupSendMessageRequest>, WithReplyParameters, DisableNotification, +) : SendContentMessageRequest>, ReplyingMarkupSendMessageRequest>, WithReplyParameters, DisableNotification, OptionallyBusinessConnectionRequest { override val requestSerializer: SerializationStrategy<*> get() = serializer() diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt index a3e0d8b5b8..5c80328af1 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendLocation.kt @@ -23,6 +23,7 @@ fun SendLocation( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendLocation( @@ -37,6 +38,7 @@ fun SendLocation( businessConnectionId, disableNotification, protectContent, + effectId, replyParameters, replyMarkup ) @@ -49,9 +51,21 @@ fun SendStaticLocation( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null -) = SendLocation(chatId, latitude, longitude, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, replyMarkup) +) = SendLocation( + chatId = chatId, + latitude = latitude, + longitude = longitude, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup +) fun SendLiveLocation( chatId: ChatIdentifier, @@ -65,22 +79,24 @@ fun SendLiveLocation( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendLocation( - chatId, - latitude, - longitude, - livePeriod, - horizontalAccuracy, - heading, - proximityAlertRadius, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + latitude = latitude, + longitude = longitude, + livePeriod = livePeriod, + horizontalAccuracy = horizontalAccuracy, + heading = heading, + proximityAlertRadius = proximityAlertRadius, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) @Serializable @@ -107,6 +123,8 @@ data class SendLocation internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt index 0324c853b7..134fd2bf41 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendMessage.kt @@ -30,6 +30,7 @@ fun SendTextMessage( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( @@ -42,6 +43,7 @@ fun SendTextMessage( linkPreviewOptions, disableNotification, protectContent, + effectId, replyParameters, replyMarkup ) @@ -54,6 +56,7 @@ fun SendTextMessage( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendTextMessage( @@ -66,6 +69,7 @@ fun SendTextMessage( linkPreviewOptions, disableNotification, protectContent, + effectId, replyParameters, replyMarkup ) @@ -90,6 +94,8 @@ data class SendTextMessage internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt index 5f10337d3c..6085970862 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/SendVenue.kt @@ -41,6 +41,8 @@ data class SendVenue( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) @@ -57,6 +59,7 @@ data class SendVenue( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): this( @@ -70,8 +73,10 @@ data class SendVenue( googlePlaceId = venue.googlePlaceId, googlePlaceType = venue.googlePlaceType, threadId = threadId, + businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -89,6 +94,7 @@ fun Venue.toRequest( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): SendVenue = SendVenue( @@ -98,6 +104,7 @@ fun Venue.toRequest( businessConnectionId, disableNotification, protectContent, + effectId, replyParameters, replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithEffectRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithEffectRequest.kt new file mode 100644 index 0000000000..5b4fb09c6e --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/OptionallyWithEffectRequest.kt @@ -0,0 +1,6 @@ +package dev.inmo.tgbotapi.requests.send.abstracts + +import dev.inmo.tgbotapi.abstracts.types.OptionallyWithEffectId +import dev.inmo.tgbotapi.requests.abstracts.Request + +interface OptionallyWithEffectRequest : OptionallyWithEffectId, Request diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendContentMessageRequest.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendContentMessageRequest.kt index 3b357906be..a6ea0c0072 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendContentMessageRequest.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/abstracts/SendContentMessageRequest.kt @@ -2,4 +2,4 @@ package dev.inmo.tgbotapi.requests.send.abstracts import dev.inmo.tgbotapi.abstracts.types.OptionallyBusinessConnectionRequest -interface SendContentMessageRequest : SendMessageRequest, OptionallyBusinessConnectionRequest +interface SendContentMessageRequest : SendMessageRequest, OptionallyBusinessConnectionRequest, OptionallyWithEffectRequest diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt index f76a59d05d..1a364ab38f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/games/SendGame.kt @@ -28,6 +28,8 @@ data class SendGame ( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt index 3e692c4f97..8f95460751 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAnimation.kt @@ -36,6 +36,7 @@ fun SendAnimation( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -58,6 +59,7 @@ fun SendAnimation( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -86,6 +88,7 @@ fun SendAnimation( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -108,6 +111,7 @@ fun SendAnimation( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -157,6 +161,8 @@ data class SendAnimationData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt index d63e00d307..f0bb231a5c 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendAudio.kt @@ -35,6 +35,7 @@ fun SendAudio( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -42,21 +43,22 @@ fun SendAudio( val thumbAsFile = thumbnail as? MultipartFile val data = SendAudioData( - chatId, - audio, - thumbnail ?.fileId, - text, - parseMode, - null, - duration, - performer, - title, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + audio = audio, + thumbnail = thumbnail ?.fileId, + text = text, + parseMode = parseMode, + rawEntities = null, + duration = duration, + performer = performer, + title = title, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (audioAsFile == null && thumbAsFile == null) { @@ -81,6 +83,7 @@ fun SendAudio( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -88,21 +91,22 @@ fun SendAudio( val thumbAsFile = thumbnail as? MultipartFile val data = SendAudioData( - chatId, - audio, - thumbnail ?.fileId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - duration, - performer, - title, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + audio = audio, + thumbnail = thumbnail ?.fileId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + duration = duration, + performer = performer, + title = title, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (audioAsFile == null && thumbAsFile == null) { @@ -146,6 +150,8 @@ data class SendAudioData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt index 7b761ae617..1f46c032d3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendDocument.kt @@ -40,6 +40,7 @@ fun SendDocument( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null @@ -48,19 +49,20 @@ fun SendDocument( val thumbAsFile = thumbnail as? MultipartFile val data = SendDocumentData( - chatId, - document, - thumbnail ?.fileId, - text, - parseMode, - null, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup, - disableContentTypeDetection + chatId = chatId, + document = document, + thumbnail = thumbnail ?.fileId, + text = text, + parseMode = parseMode, + rawEntities = null, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup, + disableContentTypeDetection = disableContentTypeDetection ) return if (documentAsFile == null && thumbAsFile == null) { @@ -91,6 +93,7 @@ fun SendDocument( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, disableContentTypeDetection: Boolean? = null @@ -99,19 +102,20 @@ fun SendDocument( val thumbAsFile = thumbnail as? MultipartFile val data = SendDocumentData( - chatId, - document, - thumbnail ?.fileId, - entities.makeString(), - null, - entities.toRawMessageEntities(), - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup, - disableContentTypeDetection + chatId = chatId, + document = document, + thumbnail = thumbnail ?.fileId, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup, + disableContentTypeDetection = disableContentTypeDetection ) return if (documentAsFile == null && thumbAsFile == null) { @@ -158,6 +162,8 @@ data class SendDocumentData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt index 76ea3122fa..360d8fb440 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendMediaGroup.kt @@ -37,8 +37,8 @@ fun SendMediaGroup( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyParameters: ReplyParameters? = null, - allowSendingWithoutReply: Boolean? = null + effectId: EffectId? = null, + replyParameters: ReplyParameters? = null ): Request>> { if (media.size !in mediaCountInMediaGroup) { throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size) @@ -56,13 +56,14 @@ fun SendMediaGroup( } val data = SendMediaGroupData( - chatId, - media, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters + chatId = chatId, + media = media, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters ) return (if (files.isEmpty()) { @@ -88,9 +89,18 @@ inline fun SendPlaylist( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyParameters: ReplyParameters? = null, - allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) + effectId: EffectId? = null, + replyParameters: ReplyParameters? = null +) = SendMediaGroup( + chatId = chatId, + media = media, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters +) /** * Use this method to be sure that you are correctly sending documents media group @@ -105,9 +115,18 @@ inline fun SendDocumentsGroup( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, - replyParameters: ReplyParameters? = null, - allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) + effectId: EffectId? = null, + replyParameters: ReplyParameters? = null +) = SendMediaGroup( + chatId = chatId, + media = media, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters +) /** * Use this method to be sure that you are correctly sending visual media group @@ -123,9 +142,18 @@ inline fun SendVisualMediaGroup( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, - allowSendingWithoutReply: Boolean? = null -) = SendMediaGroup(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply) +) = SendMediaGroup( + chatId = chatId, + media = media, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters +) private object MessagesListSerializer: KSerializer>> { private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass>()) @@ -155,6 +183,8 @@ data class SendMediaGroupData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, ) : DataRequest>>, diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt index 0cbd8437ae..c6fd525d03 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendPhoto.kt @@ -31,6 +31,7 @@ fun SendPhoto( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -46,6 +47,7 @@ fun SendPhoto( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -69,6 +71,7 @@ fun SendPhoto( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -84,6 +87,7 @@ fun SendPhoto( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -125,6 +129,8 @@ data class SendPhotoData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt index 73ae6ad935..f628e803de 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendSticker.kt @@ -18,20 +18,21 @@ fun SendSticker( sticker: InputFile, threadId: MessageThreadId? = chatId.threadId, businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, - emoji: String? = null, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> = SendStickerByFileId( - chatId, - sticker, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + sticker = sticker, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ).let { when (sticker) { is MultipartFile -> CommonMultipartFileRequest( @@ -59,6 +60,8 @@ data class SendStickerByFileId internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt index 1fa756eec3..3d2ef14836 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideo.kt @@ -37,6 +37,7 @@ fun SendVideo( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -60,6 +61,7 @@ fun SendVideo( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -89,6 +91,7 @@ fun SendVideo( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -112,6 +115,7 @@ fun SendVideo( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -163,6 +167,8 @@ data class SendVideoData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt index cfff79e7b2..75b8e04a52 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVideoNote.kt @@ -23,6 +23,7 @@ fun SendVideoNote( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { @@ -30,17 +31,18 @@ fun SendVideoNote( val thumbAsFile = thumbnail as? MultipartFile val data = SendVideoNoteData( - chatId, - videoNote, - thumbnail ?.fileId, - duration, - size, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + videoNote = videoNote, + thumbnail = thumbnail ?.fileId, + duration = duration, + width = size, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (videoNoteAsFile == null && thumbAsFile == null) { @@ -76,6 +78,8 @@ data class SendVideoNoteData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt index b6c140fd1c..daae9ac786 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/media/SendVoice.kt @@ -31,24 +31,26 @@ fun SendVoice( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val voiceAsFile = voice as? MultipartFile val data = SendVoiceData( - chatId, - voice, - text, - parseMode, - null, - duration, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + voice = voice, + text = text, + parseMode = parseMode, + rawEntities = null, + duration = duration, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (voiceAsFile == null) { @@ -70,24 +72,26 @@ fun SendVoice( duration: Long? = null, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ): Request> { val voiceAsFile = voice as? MultipartFile val data = SendVoiceData( - chatId, - voice, - entities.makeString(), - null, - entities.toRawMessageEntities(), - duration, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + voice = voice, + text = entities.makeString(), + parseMode = null, + rawEntities = entities.toRawMessageEntities(), + duration = duration, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) return if (voiceAsFile == null) { @@ -125,6 +129,8 @@ data class SendVoiceData internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt index ce6261617c..ff5eda11ed 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/payments/SendInvoice.kt @@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.send.payments import dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData import dev.inmo.tgbotapi.abstracts.types.* +import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyWithEffectRequest import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId @@ -66,6 +67,8 @@ data class SendInvoice( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) @@ -75,7 +78,8 @@ data class SendInvoice( DisableNotification, WithReplyParameters, WithReplyMarkup, - SendMessageRequest> { + SendMessageRequest>, + OptionallyWithEffectRequest> { override fun method(): String = "sendInvoice" override val resultDeserializer: DeserializationStrategy> get() = invoiceMessageSerializer @@ -115,6 +119,7 @@ data class SendInvoice( threadId: MessageThreadId? = chatId.threadId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: InlineKeyboardMarkup? = null ) : this( @@ -138,6 +143,7 @@ data class SendInvoice( threadId = threadId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt index e38df7dedc..f4d767216f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendQuizPoll.kt @@ -54,6 +54,8 @@ class SendQuizPoll internal constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) @@ -84,6 +86,7 @@ class SendQuizPoll internal constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -104,6 +107,7 @@ class SendQuizPoll internal constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -123,6 +127,7 @@ class SendQuizPoll internal constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -143,6 +148,7 @@ class SendQuizPoll internal constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -162,6 +168,7 @@ class SendQuizPoll internal constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -182,6 +189,7 @@ class SendQuizPoll internal constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -200,6 +208,7 @@ class SendQuizPoll internal constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -220,6 +229,7 @@ class SendQuizPoll internal constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -254,6 +264,7 @@ fun SendQuizPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( @@ -272,6 +283,7 @@ fun SendQuizPoll( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -290,6 +302,7 @@ fun SendQuizPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( @@ -307,6 +320,7 @@ fun SendQuizPoll( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -325,6 +339,7 @@ fun SendQuizPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( @@ -342,6 +357,7 @@ fun SendQuizPoll( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -359,6 +375,7 @@ fun SendQuizPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendQuizPoll( @@ -375,6 +392,7 @@ fun SendQuizPoll( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendRegularPoll.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendRegularPoll.kt index afd2935910..39c53dd708 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendRegularPoll.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/polls/SendRegularPoll.kt @@ -49,6 +49,8 @@ class SendRegularPoll private constructor( override val disableNotification: Boolean = false, @SerialName(protectContentField) override val protectContent: Boolean = false, + @SerialName(messageEffectIdField) + override val effectId: EffectId? = null, @SerialName(replyParametersField) override val replyParameters: ReplyParameters? = null, @SerialName(replyMarkupField) @@ -70,6 +72,7 @@ class SendRegularPoll private constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -87,6 +90,7 @@ class SendRegularPoll private constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -105,6 +109,7 @@ class SendRegularPoll private constructor( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) : this( @@ -122,6 +127,7 @@ class SendRegularPoll private constructor( businessConnectionId = businessConnectionId, disableNotification = disableNotification, protectContent = protectContent, + effectId = effectId, replyParameters = replyParameters, replyMarkup = replyMarkup ) @@ -149,24 +155,26 @@ fun SendRegularPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendRegularPoll( - chatId, - question, - options, - questionParseMode, - isAnonymous, - isClosed, - allowMultipleAnswers, - (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, - (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + question = question, + options = options, + questionParseMode = questionParseMode, + isAnonymous = isAnonymous, + isClosed = isClosed, + allowMultipleAnswers = allowMultipleAnswers, + openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, + closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) fun SendRegularPoll( @@ -181,23 +189,25 @@ fun SendRegularPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null ) = SendRegularPoll( - chatId, - questionTextSources, - options, - isAnonymous, - isClosed, - allowMultipleAnswers, - (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, - (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + questionEntities = questionTextSources, + options = options, + isAnonymous = isAnonymous, + isClosed = isClosed, + allowMultipleAnswers = allowMultipleAnswers, + openPeriod = (closeInfo as? ApproximateScheduledCloseInfo) ?.openPeriod, + closeDate = (closeInfo as? ExactScheduledCloseInfo) ?.closeDate, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) fun SendRegularPoll( @@ -211,21 +221,23 @@ fun SendRegularPoll( businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, disableNotification: Boolean = false, protectContent: Boolean = false, + effectId: EffectId? = null, replyParameters: ReplyParameters? = null, replyMarkup: KeyboardMarkup? = null, builder: EntitiesBuilderBody ) = SendRegularPoll( - chatId, - EntitiesBuilder().apply(builder).build(), - options, - closeInfo, - isAnonymous, - isClosed, - allowMultipleAnswers, - threadId, - businessConnectionId, - disableNotification, - protectContent, - replyParameters, - replyMarkup + chatId = chatId, + questionTextSources = EntitiesBuilder().apply(builder).build(), + options = options, + closeInfo = closeInfo, + isAnonymous = isAnonymous, + isClosed = isClosed, + allowMultipleAnswers = allowMultipleAnswers, + threadId = threadId, + businessConnectionId = businessConnectionId, + disableNotification = disableNotification, + protectContent = protectContent, + effectId = effectId, + replyParameters = replyParameters, + replyMarkup = replyMarkup ) \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index ffe238571b..9a97d60d58 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -123,6 +123,7 @@ const val disableWebPagePreviewField = "disable_web_page_preview" const val linkPreviewOptionsField = "link_preview_options" const val disableNotificationField = "disable_notification" const val protectContentField = "protect_content" +const val messageEffectIdField = "message_effect_id" const val removeCaptionField = "remove_caption" const val replyToMessageIdField = "reply_to_message_id" const val replyParametersField = "reply_parameters" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt index 0b30e720be..c9f0d1be13 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/PrivateContentMessageImpl.kt @@ -24,6 +24,7 @@ data class PrivateContentMessageImpl( override val senderBot: CommonBot?, override val mediaGroupId: MediaGroupId?, override val fromOffline: Boolean, + override val effectId: EffectId? ) : PrivateContentMessage { constructor( messageId: MessageId, @@ -39,7 +40,8 @@ data class PrivateContentMessageImpl( senderBot: CommonBot?, mediaGroupId: MediaGroupId?, fromOffline: Boolean, + effectId: EffectId, ) : this( - messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, mediaGroupId, fromOffline + messageId, from, chat, content, date, editDate, hasProtectedContent, forwardInfo.messageOrigin(), replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, senderBot, mediaGroupId, fromOffline, effectId ) } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt index a69ba0a14c..d369a13ae3 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/RawMessage.kt @@ -553,7 +553,8 @@ internal data class RawMessage( replyMarkup = reply_markup, senderBot = via_bot, mediaGroupId = media_group_id, - fromOffline = is_from_offline + fromOffline = is_from_offline, + effectId = effect_id ) } else { BusinessContentMessageImpl( diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyWithEffectMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyWithEffectMessage.kt new file mode 100644 index 0000000000..b7a65d5edc --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PossiblyWithEffectMessage.kt @@ -0,0 +1,5 @@ +package dev.inmo.tgbotapi.types.message.abstracts + +import dev.inmo.tgbotapi.abstracts.types.OptionallyWithEffectId + +interface PossiblyWithEffectMessage : Message, OptionallyWithEffectId \ No newline at end of file diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateContentMessage.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateContentMessage.kt index 094ac7eadf..4680553526 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateContentMessage.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/message/abstracts/PrivateContentMessage.kt @@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.message.abstracts import dev.inmo.tgbotapi.types.chat.PreviewPrivateChat import dev.inmo.tgbotapi.types.message.content.MessageContent -interface PrivateContentMessage : PossiblySentViaBotCommonMessage, FromUserMessage, PossiblyOfflineMessage { +interface PrivateContentMessage : PossiblySentViaBotCommonMessage, FromUserMessage, PossiblyOfflineMessage, PossiblyWithEffectMessage { override val chat: PreviewPrivateChat } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt index 9b240b470b..8ab288e989 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/extensions/MediaGroupContentMessageCreator.kt @@ -60,7 +60,8 @@ fun List>.asMedia sourceMessage.replyMarkup, sourceMessage.senderBot, sourceMessage.mediaGroupId, - sourceMessage.fromOffline + sourceMessage.fromOffline, + sourceMessage.effectId ) is AnonymousGroupContentMessage -> AnonymousGroupContentMessageImpl( sourceMessage.chat,