1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 20:18:45 +00:00

Merge pull request #38 from InsanusMokrassar/0.16.1

0.16.1
This commit is contained in:
InsanusMokrassar 2019-06-28 19:00:50 +08:00 committed by GitHub
commit 46a4e7ea27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 87 additions and 52 deletions

View File

@ -9,6 +9,12 @@
* `String#asUsername` method renamed to `String#toUsername` * `String#asUsername` method renamed to `String#toUsername`
* Several `toChatId` extensions added * Several `toChatId` extensions added
### 0.16.1
* Now old uncommon `CaptionedMediaContent` and `CaptionedInputMedia` are replaced by almost the same
interfaces `CaptionedInput` and `CaptionedOutput`. They are both implementing `Captioned` interface
* `AnimationContent` now is `CaptionedInput`
## 0.15.0 ## 0.15.0
* Old `UpdatesPoller` removed (was deprecated) * Old `UpdatesPoller` removed (was deprecated)

View File

@ -1,4 +1,4 @@
project.version = "0.16.0" project.version = "0.16.1"
project.group = "com.github.insanusmokrassar" project.group = "com.github.insanusmokrassar"
buildscript { buildscript {

View File

@ -1,8 +1,16 @@
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
interface Captioned { interface Captioned {
val caption: String? val caption: String?
}
interface CaptionedOutput : Captioned {
val parseMode: ParseMode? val parseMode: ParseMode?
} }
interface CaptionedInput : Captioned {
val captionEntities: List<MessageEntity>
}

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.audio package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.audio
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.WithInputMessageContentInlineQueryResult
const val inlineQueryResultAudioType = "audio" const val inlineQueryResultAudioType = "audio"
interface InlineQueryResultAudioCommon : InlineQueryResult, interface InlineQueryResultAudioCommon : InlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.document package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.document
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultDocumentType = "document" const val inlineQueryResultDocumentType = "document"
@ -8,5 +8,5 @@ const val inlineQueryResultDocumentType = "document"
interface InlineQueryResultDocumentCommon : InlineQueryResult, interface InlineQueryResultDocumentCommon : InlineQueryResult,
TitledInlineQueryResult, TitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.gif package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.gif
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultGifType = "gif" const val inlineQueryResultGifType = "gif"
interface InlineQueryResultGifCommon : InlineQueryResult, interface InlineQueryResultGifCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.mpeg4gif
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultMpeg4GifType = "mpeg4_gif" const val inlineQueryResultMpeg4GifType = "mpeg4_gif"
interface InlineQueryResultMpeg4GifCommon : InlineQueryResult, interface InlineQueryResultMpeg4GifCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.photo package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.photo
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultPhotoType = "photo" const val inlineQueryResultPhotoType = "photo"
@ -8,5 +8,5 @@ const val inlineQueryResultPhotoType = "photo"
interface InlineQueryResultPhotoCommon : InlineQueryResult, interface InlineQueryResultPhotoCommon : InlineQueryResult,
OptionallyTitledInlineQueryResult, OptionallyTitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.video
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultVideoType = "video" const val inlineQueryResultVideoType = "video"
@ -8,5 +8,5 @@ const val inlineQueryResultVideoType = "video"
interface InlineQueryResultVideoCommon : InlineQueryResult, interface InlineQueryResultVideoCommon : InlineQueryResult,
TitledInlineQueryResult, TitledInlineQueryResult,
DescribedInlineQueryResult, DescribedInlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult WithInputMessageContentInlineQueryResult

View File

@ -1,11 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.results.voice
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.*
const val inlineQueryResultVoiceType = "voice" const val inlineQueryResultVoiceType = "voice"
interface InlineQueryResultVoiceCommon : InlineQueryResult, interface InlineQueryResultVoiceCommon : InlineQueryResult,
Captioned, CaptionedOutput,
WithInputMessageContentInlineQueryResult, WithInputMessageContentInlineQueryResult,
TitledInlineQueryResult TitledInlineQueryResult

View File

@ -1,6 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Captioned import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableWebPagePreview
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
@ -18,4 +18,4 @@ data class InputTextMessageContent(
override val parseMode: ParseMode? = null, override val parseMode: ParseMode? = null,
@SerialName(disableWebPagePreviewField) @SerialName(disableWebPagePreviewField)
override val disableWebPagePreview: Boolean? = null override val disableWebPagePreview: Boolean? = null
) : Captioned, DisableWebPagePreview, InputMessageContent ) : CaptionedOutput, DisableWebPagePreview, InputMessageContent

View File

@ -1,8 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
interface CaptionedInputMedia: InputMedia { @Deprecated(
val caption: String? "Deprecated due to replace by common type CaptionedOutput",
val parseMode: ParseMode? ReplaceWith("CaptionedOutput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput")
} )
typealias CaptionedInputMedia = CaptionedOutput

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
@ -17,7 +18,7 @@ data class InputMediaAnimation(
override val height: Int? = null, override val height: Int? = null,
override val duration: Long? = null, override val duration: Long? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedOutput {
override val type: String = "animation" override val type: String = "animation"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Performerable
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
@ -18,7 +19,7 @@ data class InputMediaAudio(
override val performer: String? = null, override val performer: String? = null,
override val title: String? = null, override val title: String? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedInputMedia, Performerable { ) : InputMedia, DuratedInputMedia, ThumbedInputMedia, TitledInputMedia, CaptionedOutput, Performerable {
override val type: String = "audio" override val type: String = "audio"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.* import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
@ -14,7 +15,7 @@ data class InputMediaDocument(
@SerialName(parseModeField) @SerialName(parseModeField)
override val parseMode: ParseMode? = null, override val parseMode: ParseMode? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, ThumbedInputMedia, CaptionedInputMedia { ) : InputMedia, ThumbedInputMedia, CaptionedOutput {
override val type: String = "document" override val type: String = "document"
@SerialName(mediaField) @SerialName(mediaField)

View File

@ -13,7 +13,7 @@ data class InputMediaPhoto(
override val caption: String? = null, override val caption: String? = null,
@SerialName(parseModeField) @SerialName(parseModeField)
override val parseMode: ParseMode? = null override val parseMode: ParseMode? = null
) : InputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { ) : InputMedia, MediaGroupMemberInputMedia {
override val type: String = "photo" override val type: String = "photo"
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)

View File

@ -16,7 +16,7 @@ data class InputMediaVideo(
override val height: Int? = null, override val height: Int? = null,
override val duration: Long? = null, override val duration: Long? = null,
override val thumb: InputFile? = null override val thumb: InputFile? = null
) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, CaptionedInputMedia, MediaGroupMemberInputMedia { ) : InputMedia, SizedInputMedia, DuratedInputMedia, ThumbedInputMedia, MediaGroupMemberInputMedia {
override val type: String = "video" override val type: String = "video"
override fun serialize(format: StringFormat): String = format.stringify(serializer(), this) override fun serialize(format: StringFormat): String = format.stringify(serializer(), this)

View File

@ -1,10 +1,11 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedOutput
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.StringFormat import kotlinx.serialization.StringFormat
@Serializable(MediaGroupMemberInputMediaSerializer::class) @Serializable(MediaGroupMemberInputMediaSerializer::class)
interface MediaGroupMemberInputMedia: InputMedia { interface MediaGroupMemberInputMedia : InputMedia, CaptionedOutput {
fun serialize(format: StringFormat): String fun serialize(format: StringFormat): String
val arguments: Map<String, Any?> val arguments: Map<String, Any?>
} }

View File

@ -122,7 +122,12 @@ data class RawMessage(
caption, caption,
adaptedCaptionEntities adaptedCaptionEntities
) )
animation != null -> AnimationContent(animation, document) animation != null -> AnimationContent(
animation,
document,
caption,
adaptedCaptionEntities
)
sticker != null -> StickerContent(sticker) sticker != null -> StickerContent(sticker)
game != null -> GameContent(game) game != null -> GameContent(game)
video_note != null -> VideoNoteContent(video_note) video_note != null -> VideoNoteContent(video_note)

View File

@ -1,8 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
interface CaptionedMediaContent { @Deprecated(
val caption: String? "Deprecated due to replace by common type CaptionedInput",
val captionEntities: List<MessageEntity> ReplaceWith("CaptionedInput", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput")
} )
typealias CaptionedMediaContent = CaptionedInput

View File

@ -1,7 +1,8 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
interface MediaGroupContent : MediaContent { interface MediaGroupContent : MediaContent, CaptionedInput {
fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia
} }

View File

@ -1,27 +1,34 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
data class AnimationContent( data class AnimationContent(
override val media: AnimationFile, override val media: AnimationFile,
val includedDocument: DocumentFile? val includedDocument: DocumentFile?,
) : MediaContent { override val caption: String?,
override val captionEntities: List<MessageEntity>
) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,
replyToMessageId: MessageIdentifier?, replyToMessageId: MessageIdentifier?,
replyMarkup: KeyboardMarkup? replyMarkup: KeyboardMarkup?
): Request<RawMessage> = createResend(chatId, null, null, disableNotification, replyToMessageId, replyMarkup) ): Request<RawMessage> = createResend(chatId, toHtmlCaptions().firstOrNull(), HTMLParseMode, disableNotification, replyToMessageId, replyMarkup)
@Deprecated("Will be fully replaced by default method")
fun createResend( fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
caption: String?, caption: String?,

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -17,7 +18,7 @@ data class AudioContent(
override val media: AudioFile, override val media: AudioFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -9,7 +10,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
@ -17,7 +17,7 @@ data class DocumentContent(
override val media: DocumentFile, override val media: DocumentFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -19,7 +19,7 @@ data class PhotoContent(
override val mediaCollection: List<PhotoSize>, override val mediaCollection: List<PhotoSize>,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaCollectionContent<PhotoSize>, CaptionedMediaContent, MediaGroupContent { ) : MediaCollectionContent<PhotoSize>, MediaGroupContent {
override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content") override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content")
override fun createResend( override fun createResend(

View File

@ -19,7 +19,7 @@ data class VideoContent(
override val media: VideoFile, override val media: VideoFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : CaptionedMediaContent, MediaGroupContent { ) : MediaGroupContent {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.media
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
@ -17,7 +18,7 @@ data class VoiceContent(
override val media: VoiceFile, override val media: VoiceFile,
override val caption: String? = null, override val caption: String? = null,
override val captionEntities: List<MessageEntity> = emptyList() override val captionEntities: List<MessageEntity> = emptyList()
) : MediaContent, CaptionedMediaContent { ) : MediaContent, CaptionedInput {
override fun createResend( override fun createResend(
chatId: ChatIdentifier, chatId: ChatIdentifier,
disableNotification: Boolean, disableNotification: Boolean,

View File

@ -1,12 +1,12 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RegularTextMessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.* import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
fun CaptionedMediaContent.fullEntitiesList(): List<MessageEntity> = caption ?.let { fun CaptionedInput.fullEntitiesList(): List<MessageEntity> = caption ?.let {
convertToFullMessageEntityList(it, captionEntities) convertToFullMessageEntityList(it, captionEntities)
} ?: emptyList() } ?: emptyList()

View File

@ -1,10 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
fun createHtmlText( fun createHtmlText(
@ -12,7 +12,7 @@ fun createHtmlText(
partLength: Int = 4096 partLength: Int = 4096
): List<String> = createFormattedText(entities, partLength, HTMLParseMode) ): List<String> = createFormattedText(entities, partLength, HTMLParseMode)
fun CaptionedMediaContent.toHtmlCaptions(): List<String> = createHtmlText( fun CaptionedInput.toHtmlCaptions(): List<String> = createHtmlText(
fullEntitiesList(), fullEntitiesList(),
captionLength.endInclusive + 1 captionLength.endInclusive + 1
) )

View File

@ -1,10 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.utils package com.github.insanusmokrassar.TelegramBotAPI.utils
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength import com.github.insanusmokrassar.TelegramBotAPI.types.captionLength
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
import com.github.insanusmokrassar.TelegramBotAPI.types.textLength import com.github.insanusmokrassar.TelegramBotAPI.types.textLength
@Deprecated( @Deprecated(
@ -31,9 +31,9 @@ fun createMarkdownText(
"com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions" "com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions"
) )
) )
fun CaptionedMediaContent.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull() fun CaptionedInput.toMarkdownCaption(): String? = toMarkdownCaptions().firstOrNull()
fun CaptionedMediaContent.toMarkdownCaptions(): List<String> = createMarkdownText( fun CaptionedInput.toMarkdownCaptions(): List<String> = createMarkdownText(
fullEntitiesList(), fullEntitiesList(),
captionLength.endInclusive + 1 captionLength.endInclusive + 1
) )