1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-29 04:47:48 +00:00

add base support of effects

This commit is contained in:
InsanusMokrassar 2024-05-30 21:58:47 +06:00
parent 4dec85ee60
commit 7a5c9c7ef8
27 changed files with 362 additions and 188 deletions

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.abstracts.types
import dev.inmo.tgbotapi.types.EffectId
interface OptionallyWithEffectId {
val effectId: EffectId?
}

View File

@ -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
)

View File

@ -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<ContentMessage<DiceContent>>, WithReplyParameters, DisableNotification,
) : SendContentMessageRequest<ContentMessage<DiceContent>>, ReplyingMarkupSendMessageRequest<ContentMessage<DiceContent>>, WithReplyParameters, DisableNotification,
OptionallyBusinessConnectionRequest {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()

View File

@ -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)

View File

@ -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)

View File

@ -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
)

View File

@ -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<T : Any> : OptionallyWithEffectId, Request<T>

View File

@ -2,4 +2,4 @@ package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.abstracts.types.OptionallyBusinessConnectionRequest
interface SendContentMessageRequest<T: Any> : SendMessageRequest<T>, OptionallyBusinessConnectionRequest
interface SendContentMessageRequest<T: Any> : SendMessageRequest<T>, OptionallyBusinessConnectionRequest, OptionallyWithEffectRequest<T>

View File

@ -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)

View File

@ -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<ContentMessage<AnimationContent>> {
@ -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<ContentMessage<AnimationContent>> {
@ -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)

View File

@ -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<ContentMessage<AudioContent>> {
@ -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<ContentMessage<AudioContent>> {
@ -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)

View File

@ -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)

View File

@ -37,8 +37,8 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyParameters: ReplyParameters? = null,
allowSendingWithoutReply: Boolean? = null
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
): Request<ContentMessage<MediaGroupContent<T>>> {
if (media.size !in mediaCountInMediaGroup) {
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
@ -56,13 +56,14 @@ fun <T : MediaGroupPartContent> 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<AudioContent>(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply)
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
) = SendMediaGroup<AudioContent>(
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<DocumentContent>(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply)
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null
) = SendMediaGroup<DocumentContent>(
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<VisualMediaGroupPartContent>(chatId, media, threadId, businessConnectionId, disableNotification, protectContent, replyParameters, allowSendingWithoutReply)
) = SendMediaGroup<VisualMediaGroupPartContent>(
chatId = chatId,
media = media,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters
)
private object MessagesListSerializer: KSerializer<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass<PossiblySentViaBotCommonMessage<MediaGroupPartContent>>())
@ -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<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>,

View File

@ -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<ContentMessage<PhotoContent>> {
@ -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<ContentMessage<PhotoContent>> {
@ -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)

View File

@ -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<ContentMessage<StickerContent>> = 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)

View File

@ -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<ContentMessage<VideoContent>> {
@ -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<ContentMessage<VideoContent>> {
@ -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)

View File

@ -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<ContentMessage<VideoNoteContent>> {
@ -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)

View File

@ -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<ContentMessage<VoiceContent>> {
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<ContentMessage<VoiceContent>> {
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)

View File

@ -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<ContentMessage<InvoiceContent>> {
SendMessageRequest<ContentMessage<InvoiceContent>>,
OptionallyWithEffectRequest<ContentMessage<InvoiceContent>> {
override fun method(): String = "sendInvoice"
override val resultDeserializer: DeserializationStrategy<ContentMessage<InvoiceContent>>
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
)

View File

@ -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
)

View File

@ -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
)

View File

@ -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"

View File

@ -24,6 +24,7 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
override val effectId: EffectId?
) : PrivateContentMessage<T> {
constructor(
messageId: MessageId,
@ -39,7 +40,8 @@ data class PrivateContentMessageImpl<T: MessageContent>(
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
)
}

View File

@ -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(

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.abstracts.types.OptionallyWithEffectId
interface PossiblyWithEffectMessage : Message, OptionallyWithEffectId

View File

@ -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<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, FromUserMessage, PossiblyOfflineMessage {
interface PrivateContentMessage<T: MessageContent> : PossiblySentViaBotCommonMessage<T>, FromUserMessage, PossiblyOfflineMessage, PossiblyWithEffectMessage {
override val chat: PreviewPrivateChat
}

View File

@ -60,7 +60,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
sourceMessage.replyMarkup,
sourceMessage.senderBot,
sourceMessage.mediaGroupId,
sourceMessage.fromOffline
sourceMessage.fromOffline,
sourceMessage.effectId
)
is AnonymousGroupContentMessage -> AnonymousGroupContentMessageImpl(
sourceMessage.chat,