mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-07-01 15:45:31 +00:00
improve richblocks api and let rich message content to be correctly resendable if there are no any media block inside
This commit is contained in:
@@ -34515,7 +34515,7 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockAnchor$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAnimation : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAnimation : dev/inmo/tgbotapi/types/rich/RichBlockMedia {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockAnimation$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
public fun <init> (Ldev/inmo/tgbotapi/types/files/AnimationFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)V
|
||||
@@ -34527,10 +34527,11 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockAnimation : dev/inmo/tg
|
||||
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/rich/RichBlockAnimation;Ldev/inmo/tgbotapi/types/files/AnimationFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/rich/RichBlockAnimation;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getAnimation ()Ldev/inmo/tgbotapi/types/files/AnimationFile;
|
||||
public final fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public final fun getHasSpoiler ()Ljava/lang/Boolean;
|
||||
public fun getHtml ()Ljava/lang/String;
|
||||
public fun getMarkdown ()Ljava/lang/String;
|
||||
public fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
public fun getType ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
@@ -34553,7 +34554,7 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockAnimation$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAudio : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockAudio : dev/inmo/tgbotapi/types/rich/RichBlockMedia {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockAudio$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
public fun <init> (Ldev/inmo/tgbotapi/types/files/AudioFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)V
|
||||
@@ -34564,9 +34565,10 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockAudio : dev/inmo/tgbota
|
||||
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/rich/RichBlockAudio;Ldev/inmo/tgbotapi/types/files/AudioFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/rich/RichBlockAudio;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getAudio ()Ldev/inmo/tgbotapi/types/files/AudioFile;
|
||||
public final fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getHtml ()Ljava/lang/String;
|
||||
public fun getMarkdown ()Ljava/lang/String;
|
||||
public fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
public fun getType ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
@@ -34798,6 +34800,11 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockFormattingKt {
|
||||
public static final fun toRichMarkdown (Ljava/util/List;)Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockKt {
|
||||
public static final fun getSubBlocks (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ljava/util/List;
|
||||
public static final fun search (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/types/rich/RichBlock;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockList : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockList$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
@@ -34952,6 +34959,16 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockMathematicalExpression$
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/types/rich/RichBlockMedia : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockMedia$Companion;
|
||||
public abstract fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public abstract fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockMedia$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockParagraph : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockParagraph$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
@@ -34985,7 +35002,7 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockParagraph$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockPhoto : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockPhoto : dev/inmo/tgbotapi/types/rich/RichBlockMedia {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockPhoto$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
public synthetic fun <init> (Ljava/util/List;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
@@ -34996,10 +35013,11 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockPhoto : dev/inmo/tgbota
|
||||
public final fun copy-OKnyJrA (Ljava/util/List;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ldev/inmo/tgbotapi/types/rich/RichBlockPhoto;
|
||||
public static synthetic fun copy-OKnyJrA$default (Ldev/inmo/tgbotapi/types/rich/RichBlockPhoto;Ljava/util/List;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/rich/RichBlockPhoto;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public final fun getHasSpoiler ()Ljava/lang/Boolean;
|
||||
public fun getHtml ()Ljava/lang/String;
|
||||
public fun getMarkdown ()Ljava/lang/String;
|
||||
public fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
public final fun getPhoto-bGlShw4 ()Ljava/util/List;
|
||||
public fun getType ()Ljava/lang/String;
|
||||
public fun hashCode ()I
|
||||
@@ -35281,7 +35299,7 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockThinking$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVideo : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVideo : dev/inmo/tgbotapi/types/rich/RichBlockMedia {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockVideo$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
public fun <init> (Ldev/inmo/tgbotapi/types/files/VideoFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)V
|
||||
@@ -35292,10 +35310,11 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockVideo : dev/inmo/tgbota
|
||||
public final fun copy (Ldev/inmo/tgbotapi/types/files/VideoFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ldev/inmo/tgbotapi/types/rich/RichBlockVideo;
|
||||
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/rich/RichBlockVideo;Ldev/inmo/tgbotapi/types/files/VideoFile;Ljava/lang/Boolean;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/rich/RichBlockVideo;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public final fun getHasSpoiler ()Ljava/lang/Boolean;
|
||||
public fun getHtml ()Ljava/lang/String;
|
||||
public fun getMarkdown ()Ljava/lang/String;
|
||||
public fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
public fun getType ()Ljava/lang/String;
|
||||
public final fun getVideo ()Ldev/inmo/tgbotapi/types/files/VideoFile;
|
||||
public fun hashCode ()I
|
||||
@@ -35319,7 +35338,7 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockVideo$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVoiceNote : dev/inmo/tgbotapi/types/rich/RichBlock {
|
||||
public final class dev/inmo/tgbotapi/types/rich/RichBlockVoiceNote : dev/inmo/tgbotapi/types/rich/RichBlockMedia {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/rich/RichBlockVoiceNote$Companion;
|
||||
public static final field TYPE Ljava/lang/String;
|
||||
public fun <init> (Ldev/inmo/tgbotapi/types/files/VoiceFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)V
|
||||
@@ -35329,9 +35348,10 @@ public final class dev/inmo/tgbotapi/types/rich/RichBlockVoiceNote : dev/inmo/tg
|
||||
public final fun copy (Ldev/inmo/tgbotapi/types/files/VoiceFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;)Ldev/inmo/tgbotapi/types/rich/RichBlockVoiceNote;
|
||||
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/rich/RichBlockVoiceNote;Ldev/inmo/tgbotapi/types/files/VoiceFile;Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/rich/RichBlockVoiceNote;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getCaption ()Ldev/inmo/tgbotapi/types/rich/RichBlockCaption;
|
||||
public fun getHtml ()Ljava/lang/String;
|
||||
public fun getMarkdown ()Ljava/lang/String;
|
||||
public fun getMedia ()Ldev/inmo/tgbotapi/types/files/TelegramMediaFile;
|
||||
public fun getType ()Ljava/lang/String;
|
||||
public final fun getVoiceNote ()Ldev/inmo/tgbotapi/types/files/VoiceFile;
|
||||
public fun hashCode ()I
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.requests.ForwardMessage
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
||||
import dev.inmo.tgbotapi.requests.send.SendRichMessage
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
@@ -9,8 +11,14 @@ import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.SuggestedPostParameters
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ChatContentMessage
|
||||
import dev.inmo.tgbotapi.types.rich.InputRichMessageMarkdown
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlock
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockAudio
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockMedia
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockPhoto
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockVideo
|
||||
import dev.inmo.tgbotapi.types.rich.RichTextInfo
|
||||
import dev.inmo.tgbotapi.types.rich.markdown
|
||||
import dev.inmo.tgbotapi.types.rich.search
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@@ -32,19 +40,39 @@ data class RichMessageContent(
|
||||
replyParameters: ReplyParameters?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<ChatContentMessage<RichMessageContent>> {
|
||||
return SendRichMessage(
|
||||
chatId = chatId,
|
||||
richMessage = InputRichMessageMarkdown(richMessage.markdown, isRtl = richMessage.isRtl),
|
||||
threadId = messageThreadId,
|
||||
directMessageThreadId = directMessageThreadId,
|
||||
businessConnectionId = businessConnectionId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
allowPaidBroadcast = allowPaidBroadcast,
|
||||
effectId = effectId,
|
||||
suggestedPostParameters = suggestedPostParameters,
|
||||
replyParameters = replyParameters,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
val isThereMedia = richMessage.blocks.any {
|
||||
it.search {
|
||||
this is RichBlockMedia
|
||||
} != null
|
||||
}
|
||||
return if (isThereMedia) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
ForwardMessage(
|
||||
chat.id,
|
||||
toChatId = chatId,
|
||||
messageId = messageId,
|
||||
threadId = messageThreadId,
|
||||
directMessageThreadId = directMessageThreadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
effectId = effectId,
|
||||
suggestedPostParameters = suggestedPostParameters,
|
||||
) as Request<ChatContentMessage<RichMessageContent>>
|
||||
} else {
|
||||
SendRichMessage(
|
||||
chatId = chatId,
|
||||
richMessage = InputRichMessageMarkdown(richMessage.markdown, isRtl = richMessage.isRtl),
|
||||
threadId = messageThreadId,
|
||||
directMessageThreadId = directMessageThreadId,
|
||||
businessConnectionId = businessConnectionId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
allowPaidBroadcast = allowPaidBroadcast,
|
||||
effectId = effectId,
|
||||
suggestedPostParameters = suggestedPostParameters,
|
||||
replyParameters = replyParameters,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.rich
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.typeField
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
@@ -30,6 +32,39 @@ sealed interface RichBlock {
|
||||
val html: String
|
||||
}
|
||||
|
||||
@Serializable(RichBlockSerializer::class)
|
||||
sealed interface RichBlockMedia : RichBlock {
|
||||
val media: TelegramMediaFile
|
||||
val caption: RichBlockCaption?
|
||||
}
|
||||
|
||||
/**
|
||||
* The nested [RichBlock]s directly contained by this block, or an empty list for leaf blocks. Container blocks
|
||||
* ([RichBlockList] via its [RichBlockListItem.blocks], [RichBlockBlockQuotation], [RichBlockCollage],
|
||||
* [RichBlockSlideshow] and [RichBlockDetails]) expose their children here.
|
||||
*/
|
||||
val RichBlock.subBlocks: List<RichBlock>
|
||||
get() = when (this) {
|
||||
is RichBlockList -> items.flatMap { it.blocks }
|
||||
is RichBlockBlockQuotation -> blocks
|
||||
is RichBlockCollage -> blocks
|
||||
is RichBlockSlideshow -> blocks
|
||||
is RichBlockDetails -> blocks
|
||||
else -> emptyList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks this [RichBlock] and all of its [subBlocks] recursively (depth-first, this block first) and returns the first
|
||||
* block for which [block] returns `true`, or `null` if none matches.
|
||||
*/
|
||||
fun RichBlock.search(block: RichBlock.() -> Boolean): RichBlock? {
|
||||
if (block()) return this
|
||||
for (child in subBlocks) {
|
||||
child.search(block)?.let { return it }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
object RichBlockSerializer : JsonContentPolymorphicSerializer<RichBlock>(RichBlock::class) {
|
||||
override fun selectDeserializer(element: JsonElement): DeserializationStrategy<RichBlock> {
|
||||
return when (val type = element.jsonObject[typeField]?.jsonPrimitive?.content) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.expressionField
|
||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.files.PhotoFile
|
||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
||||
import dev.inmo.tgbotapi.types.hasSpoilerField
|
||||
@@ -537,8 +538,8 @@ data class RichBlockAnimation(
|
||||
@SerialName(hasSpoilerField)
|
||||
val hasSpoiler: Boolean? = null,
|
||||
@SerialName(captionField)
|
||||
val caption: RichBlockCaption? = null
|
||||
) : RichBlock {
|
||||
override val caption: RichBlockCaption? = null
|
||||
) : RichBlockMedia {
|
||||
@EncodeDefault
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
@@ -546,6 +547,9 @@ data class RichBlockAnimation(
|
||||
override val markdown: String = markdown(animation, caption)
|
||||
override val html: String = html(animation, hasSpoiler, caption)
|
||||
|
||||
override val media: TelegramMediaFile
|
||||
get() = animation
|
||||
|
||||
companion object {
|
||||
const val TYPE = "animation"
|
||||
fun markdown(animation: AnimationFile, caption: RichBlockCaption?): String =
|
||||
@@ -565,14 +569,16 @@ data class RichBlockAudio(
|
||||
@SerialName(audioField)
|
||||
val audio: AudioFile,
|
||||
@SerialName(captionField)
|
||||
val caption: RichBlockCaption? = null
|
||||
) : RichBlock {
|
||||
override val caption: RichBlockCaption? = null
|
||||
) : RichBlockMedia {
|
||||
@EncodeDefault
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String = markdown(audio, caption)
|
||||
override val html: String = html(audio, caption)
|
||||
override val media: TelegramMediaFile
|
||||
get() = audio
|
||||
|
||||
companion object {
|
||||
const val TYPE = "audio"
|
||||
@@ -595,14 +601,16 @@ data class RichBlockPhoto(
|
||||
@SerialName(hasSpoilerField)
|
||||
val hasSpoiler: Boolean? = null,
|
||||
@SerialName(captionField)
|
||||
val caption: RichBlockCaption? = null
|
||||
) : RichBlock {
|
||||
override val caption: RichBlockCaption? = null
|
||||
) : RichBlockMedia {
|
||||
@EncodeDefault
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String = markdown(photo, caption)
|
||||
override val html: String = html(photo, hasSpoiler, caption)
|
||||
override val media: TelegramMediaFile
|
||||
get() = photo
|
||||
|
||||
companion object {
|
||||
const val TYPE = "photo"
|
||||
@@ -625,14 +633,16 @@ data class RichBlockVideo(
|
||||
@SerialName(hasSpoilerField)
|
||||
val hasSpoiler: Boolean? = null,
|
||||
@SerialName(captionField)
|
||||
val caption: RichBlockCaption? = null
|
||||
) : RichBlock {
|
||||
override val caption: RichBlockCaption? = null
|
||||
) : RichBlockMedia {
|
||||
@EncodeDefault
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String = markdown(video, caption)
|
||||
override val html: String = html(video, hasSpoiler, caption)
|
||||
override val media: TelegramMediaFile
|
||||
get() = video
|
||||
|
||||
companion object {
|
||||
const val TYPE = "video"
|
||||
@@ -653,14 +663,16 @@ data class RichBlockVoiceNote(
|
||||
@SerialName(voiceNoteField)
|
||||
val voiceNote: VoiceFile,
|
||||
@SerialName(captionField)
|
||||
val caption: RichBlockCaption? = null
|
||||
) : RichBlock {
|
||||
override val caption: RichBlockCaption? = null
|
||||
) : RichBlockMedia {
|
||||
@EncodeDefault
|
||||
@SerialName(typeField)
|
||||
override val type: String = TYPE
|
||||
|
||||
override val markdown: String = markdown(voiceNote, caption)
|
||||
override val html: String = html(voiceNote, caption)
|
||||
override val media: TelegramMediaFile
|
||||
get() = voiceNote
|
||||
|
||||
companion object {
|
||||
const val TYPE = "voice_note"
|
||||
|
||||
@@ -2094,6 +2094,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
|
||||
public static final fun ifRichBlockList (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockMap (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockMathematicalExpression (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockMedia (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockParagraph (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockPhoto (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
public static final fun ifRichBlockPreformatted (Ldev/inmo/tgbotapi/types/rich/RichBlock;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
|
||||
@@ -2769,6 +2770,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
|
||||
public static final fun richBlockMapOrThrow (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockMap;
|
||||
public static final fun richBlockMathematicalExpressionOrNull (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockMathematicalExpression;
|
||||
public static final fun richBlockMathematicalExpressionOrThrow (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockMathematicalExpression;
|
||||
public static final fun richBlockMediaOrNull (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockMedia;
|
||||
public static final fun richBlockMediaOrThrow (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockMedia;
|
||||
public static final fun richBlockParagraphOrNull (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockParagraph;
|
||||
public static final fun richBlockParagraphOrThrow (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockParagraph;
|
||||
public static final fun richBlockPhotoOrNull (Ldev/inmo/tgbotapi/types/rich/RichBlock;)Ldev/inmo/tgbotapi/types/rich/RichBlockPhoto;
|
||||
|
||||
@@ -562,6 +562,7 @@ import dev.inmo.tgbotapi.types.rich.RichBlockFooter
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockList
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockMap
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockMathematicalExpression
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockMedia
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockParagraph
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockPhoto
|
||||
import dev.inmo.tgbotapi.types.rich.RichBlockPreformatted
|
||||
@@ -3629,6 +3630,12 @@ public inline fun RichBlock.richBlockThinkingOrThrow(): RichBlockThinking = this
|
||||
|
||||
public inline fun <T> RichBlock.ifRichBlockThinking(block: (RichBlockThinking) -> T): T? = richBlockThinkingOrNull() ?.let(block)
|
||||
|
||||
public inline fun RichBlock.richBlockMediaOrNull(): RichBlockMedia? = this as? dev.inmo.tgbotapi.types.rich.RichBlockMedia
|
||||
|
||||
public inline fun RichBlock.richBlockMediaOrThrow(): RichBlockMedia = this as dev.inmo.tgbotapi.types.rich.RichBlockMedia
|
||||
|
||||
public inline fun <T> RichBlock.ifRichBlockMedia(block: (RichBlockMedia) -> T): T? = richBlockMediaOrNull() ?.let(block)
|
||||
|
||||
public inline fun BotAction.typingActionOrNull(): TypingAction? = this as? dev.inmo.tgbotapi.types.actions.TypingAction
|
||||
|
||||
public inline fun BotAction.typingActionOrThrow(): TypingAction = this as dev.inmo.tgbotapi.types.actions.TypingAction
|
||||
|
||||
Reference in New Issue
Block a user