mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-23 00:57:13 +00:00
add support of external_reply in RawMessage
This commit is contained in:
parent
95011e2b3e
commit
f3b05bbffd
@ -16,4 +16,4 @@ data class Contact(
|
||||
val userId: UserId? = null,
|
||||
@SerialName(vcardField)
|
||||
override val vcard: String? = null
|
||||
) : CommonContactData, ExternalReplyInfo.ContentVariant
|
||||
) : CommonContactData, ReplyInfo.External.ContentVariant
|
||||
|
@ -1,166 +0,0 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.SpoilerableData
|
||||
import dev.inmo.tgbotapi.types.chat.SuperPublicChat
|
||||
import dev.inmo.tgbotapi.types.dice.Dice
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.games.Game
|
||||
import dev.inmo.tgbotapi.types.games.RawGame
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.MessageOrigin
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.payments.Invoice
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(ExternalReplyInfo.Companion::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface ExternalReplyInfo {
|
||||
val origin: MessageOrigin
|
||||
val chat: SuperPublicChat?
|
||||
val messageMeta: Message.MetaInfo?
|
||||
|
||||
interface ContentVariant
|
||||
|
||||
@Serializable
|
||||
data class Text(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
val linkPreviewOptions: LinkPreviewOptions?
|
||||
) : ExternalReplyInfo
|
||||
|
||||
@Serializable(ExternalReplyInfo.Companion::class)
|
||||
sealed interface Content : ExternalReplyInfo {
|
||||
val content: ContentVariant
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Simple(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
override val content: ContentVariant
|
||||
) : Content
|
||||
|
||||
@Serializable
|
||||
data class Media<T>(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
override val spoilered: Boolean,
|
||||
override val content: T
|
||||
) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
val origin: MessageOrigin,
|
||||
val chat: SuperPublicChat? = null,
|
||||
val message_id: MessageId? = null,
|
||||
val link_preview_options: LinkPreviewOptions? = null,
|
||||
val has_media_spoiler: Boolean? = null,
|
||||
private val story: Story? = null,
|
||||
private val audio: AudioFile? = null,
|
||||
private val document: DocumentFile? = null,
|
||||
private val animation: AnimationFile? = null,
|
||||
private val game: RawGame? = null,
|
||||
@Serializable(PhotoSerializer::class)
|
||||
private val photo: Photo? = null,
|
||||
private val sticker: Sticker? = null,
|
||||
private val video: VideoFile? = null,
|
||||
private val voice: VoiceFile? = null,
|
||||
private val video_note: VideoNoteFile? = null,
|
||||
private val contact: Contact? = null,
|
||||
private val location: Location? = null,
|
||||
private val venue: Venue? = null,
|
||||
private val poll: Poll? = null,
|
||||
private val invoice: Invoice? = null,
|
||||
private val dice: Dice? = null,
|
||||
private val giveaway: ScheduledGiveaway? = null,
|
||||
private val giveaway_winners: GiveawayPublicResults? = null,
|
||||
) {
|
||||
val asExternalReplyInfo: ExternalReplyInfo
|
||||
get() {
|
||||
val messageMeta = chat ?.let {
|
||||
message_id ?.let {
|
||||
Message.MetaInfo(
|
||||
chat.id,
|
||||
message_id
|
||||
)
|
||||
}
|
||||
}
|
||||
val content: ContentVariant? = when {
|
||||
story != null -> story
|
||||
audio != null -> audio
|
||||
video != null -> video
|
||||
video_note != null -> video_note
|
||||
animation != null -> animation
|
||||
document != null -> document
|
||||
voice != null -> voice
|
||||
photo != null -> photo
|
||||
sticker != null -> sticker
|
||||
dice != null -> dice
|
||||
game != null -> game.asGame
|
||||
contact != null -> contact
|
||||
location != null -> location
|
||||
venue != null -> venue
|
||||
poll != null -> poll
|
||||
invoice != null -> invoice
|
||||
giveaway != null -> giveaway
|
||||
giveaway_winners != null -> giveaway_winners
|
||||
else -> null
|
||||
}
|
||||
|
||||
return content ?.let {
|
||||
when (it) {
|
||||
is TelegramMediaFile -> {
|
||||
Content.Media(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
has_media_spoiler == true,
|
||||
it
|
||||
)
|
||||
}
|
||||
else -> Content.Simple(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
it
|
||||
)
|
||||
}
|
||||
} ?: Text(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
link_preview_options
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@RiskFeature("This serializer currently support only deserialization, but not serialization")
|
||||
companion object : KSerializer<ExternalReplyInfo> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ExternalReplyInfo {
|
||||
return Surrogate.serializer().deserialize(decoder).asExternalReplyInfo
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ExternalReplyInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.SpoilerableData
|
||||
import dev.inmo.tgbotapi.types.chat.SuperPublicChat
|
||||
import dev.inmo.tgbotapi.types.dice.Dice
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.games.RawGame
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.ScheduledGiveaway
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.MessageOrigin
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.payments.Invoice
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface ReplyInfo {
|
||||
val messageMeta: Message.MetaInfo?
|
||||
|
||||
data class Internal(
|
||||
val message: AccessibleMessage
|
||||
): ReplyInfo {
|
||||
override val messageMeta: Message.MetaInfo
|
||||
get() = message.metaInfo
|
||||
}
|
||||
|
||||
@Serializable(External.Companion::class)
|
||||
sealed interface External : ReplyInfo {
|
||||
val origin: MessageOrigin
|
||||
val chat: SuperPublicChat?
|
||||
|
||||
interface ContentVariant
|
||||
|
||||
@Serializable
|
||||
data class Text(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
val linkPreviewOptions: LinkPreviewOptions?
|
||||
) : External
|
||||
|
||||
@Serializable(External.Companion::class)
|
||||
sealed interface Content : External {
|
||||
val content: ContentVariant
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Simple(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
override val content: ContentVariant
|
||||
) : Content
|
||||
|
||||
@Serializable
|
||||
data class Media<T>(
|
||||
override val origin: MessageOrigin,
|
||||
override val chat: SuperPublicChat?,
|
||||
override val messageMeta: Message.MetaInfo?,
|
||||
override val spoilered: Boolean,
|
||||
override val content: T
|
||||
) : Content, SpoilerableData where T: ContentVariant, T : TelegramMediaFile
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
val origin: MessageOrigin,
|
||||
val chat: SuperPublicChat? = null,
|
||||
val message_id: MessageId? = null,
|
||||
val link_preview_options: LinkPreviewOptions? = null,
|
||||
val has_media_spoiler: Boolean? = null,
|
||||
private val story: Story? = null,
|
||||
private val audio: AudioFile? = null,
|
||||
private val document: DocumentFile? = null,
|
||||
private val animation: AnimationFile? = null,
|
||||
private val game: RawGame? = null,
|
||||
@Serializable(PhotoSerializer::class)
|
||||
private val photo: Photo? = null,
|
||||
private val sticker: Sticker? = null,
|
||||
private val video: VideoFile? = null,
|
||||
private val voice: VoiceFile? = null,
|
||||
private val video_note: VideoNoteFile? = null,
|
||||
private val contact: Contact? = null,
|
||||
private val location: Location? = null,
|
||||
private val venue: Venue? = null,
|
||||
private val poll: Poll? = null,
|
||||
private val invoice: Invoice? = null,
|
||||
private val dice: Dice? = null,
|
||||
private val giveaway: ScheduledGiveaway? = null,
|
||||
private val giveaway_winners: GiveawayPublicResults? = null,
|
||||
) {
|
||||
val asExternalReplyInfo: External
|
||||
get() {
|
||||
val messageMeta = chat ?.let {
|
||||
message_id ?.let {
|
||||
Message.MetaInfo(
|
||||
chat.id,
|
||||
message_id
|
||||
)
|
||||
}
|
||||
}
|
||||
val content: ContentVariant? = when {
|
||||
story != null -> story
|
||||
audio != null -> audio
|
||||
video != null -> video
|
||||
video_note != null -> video_note
|
||||
animation != null -> animation
|
||||
document != null -> document
|
||||
voice != null -> voice
|
||||
photo != null -> photo
|
||||
sticker != null -> sticker
|
||||
dice != null -> dice
|
||||
game != null -> game.asGame
|
||||
contact != null -> contact
|
||||
location != null -> location
|
||||
venue != null -> venue
|
||||
poll != null -> poll
|
||||
invoice != null -> invoice
|
||||
giveaway != null -> giveaway
|
||||
giveaway_winners != null -> giveaway_winners
|
||||
else -> null
|
||||
}
|
||||
|
||||
return content ?.let {
|
||||
when (it) {
|
||||
is TelegramMediaFile -> {
|
||||
Content.Media(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
has_media_spoiler == true,
|
||||
it
|
||||
)
|
||||
}
|
||||
else -> Content.Simple(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
it
|
||||
)
|
||||
}
|
||||
} ?: Text(
|
||||
origin,
|
||||
chat,
|
||||
messageMeta,
|
||||
link_preview_options
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@RiskFeature("This serializer currently support only deserialization, but not serialization")
|
||||
companion object : KSerializer<External> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): External {
|
||||
return Surrogate.serializer().deserialize(decoder).asExternalReplyInfo
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: External) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,4 +10,4 @@ data class Dice(
|
||||
val value: DiceResult,
|
||||
@SerialName(emojiField)
|
||||
val animationType: DiceAnimationType
|
||||
) : ExternalReplyInfo.ContentVariant
|
||||
) : ReplyInfo.External.ContentVariant
|
||||
|
@ -24,4 +24,4 @@ data class AnimationFile(
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, CustomNamedMediaFile, SizedMediaFile,
|
||||
ExternalReplyInfo.ContentVariant
|
||||
ReplyInfo.External.ContentVariant
|
||||
|
@ -28,6 +28,6 @@ data class AudioFile(
|
||||
@SerialName(thumbnailField)
|
||||
override val thumbnail: PhotoSize? = null
|
||||
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile,
|
||||
Performerable, ExternalReplyInfo.ContentVariant
|
||||
Performerable, ReplyInfo.External.ContentVariant
|
||||
|
||||
fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize)
|
||||
|
@ -20,7 +20,7 @@ data class DocumentFile(
|
||||
override val mimeType: MimeType? = null,
|
||||
@SerialName(fileNameField)
|
||||
override val fileName: String? = null
|
||||
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ExternalReplyInfo.ContentVariant
|
||||
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, CustomNamedMediaFile, ReplyInfo.External.ContentVariant
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun TelegramMediaFile.asDocumentFile() = if (this is DocumentFile) {
|
||||
|
@ -12,7 +12,7 @@ import kotlin.jvm.JvmInline
|
||||
@JvmInline
|
||||
value class Photo(
|
||||
val photos: List<PhotoSize>
|
||||
) : List<PhotoSize> by photos, ExternalReplyInfo.ContentVariant
|
||||
) : List<PhotoSize> by photos, ReplyInfo.External.ContentVariant
|
||||
|
||||
fun Photo.biggest(): PhotoSize? = maxByOrNull {
|
||||
it.resolution
|
||||
|
@ -34,7 +34,7 @@ data class StickerSurrogate(
|
||||
|
||||
// TODO:: Serializer
|
||||
@Serializable(StickerSerializer::class)
|
||||
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ExternalReplyInfo.ContentVariant {
|
||||
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile, ReplyInfo.External.ContentVariant {
|
||||
val emoji: String?
|
||||
val stickerSetName: StickerSetName?
|
||||
val stickerFormat: StickerFormat
|
||||
|
@ -30,7 +30,7 @@ data class VideoFile(
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile, CustomNamedMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile,
|
||||
ExternalReplyInfo.ContentVariant
|
||||
ReplyInfo.External.ContentVariant
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun VideoFile.toTelegramMediaVideo(
|
||||
|
@ -18,7 +18,7 @@ data class VideoNoteFile(
|
||||
override val thumbnail: PhotoSize? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ExternalReplyInfo.ContentVariant {
|
||||
) : TelegramMediaFile, ThumbedMediaFile, PlayableMediaFile, SizedMediaFile, ReplyInfo.External.ContentVariant {
|
||||
override val height: Int
|
||||
get() = width
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ data class VoiceFile(
|
||||
override val mimeType: MimeType? = null,
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ExternalReplyInfo.ContentVariant
|
||||
) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile, ReplyInfo.External.ContentVariant
|
||||
|
||||
fun VoiceFile.asAudioFile(
|
||||
performer: String? = null,
|
||||
|
@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.games
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.abstracts.Titled
|
||||
import dev.inmo.tgbotapi.types.ExternalReplyInfo
|
||||
import dev.inmo.tgbotapi.types.ReplyInfo
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.files.Photo
|
||||
@ -16,4 +16,4 @@ data class Game(
|
||||
override val text: String? = null,
|
||||
override val textSources: TextSourcesList = emptyList(),
|
||||
val animation: AnimationFile? = null
|
||||
) : Titled, TextedInput, ExternalReplyInfo.ContentVariant
|
||||
) : Titled, TextedInput, ReplyInfo.External.ContentVariant
|
||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(GiveawayPublicResults.Companion::class)
|
||||
sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId,
|
||||
ExternalReplyInfo.ContentVariant {
|
||||
ReplyInfo.External.ContentVariant {
|
||||
val count: Int
|
||||
val winners: List<PreviewUser>
|
||||
val additionalChats: Int
|
||||
|
@ -30,4 +30,4 @@ data class ScheduledGiveaway(
|
||||
val countries: List<IetfLang>? = null,
|
||||
@SerialName(premiumSubscriptionMonthCountField)
|
||||
override val premiumMonths: Int? = null
|
||||
) : GiveawayInfo, ExternalReplyInfo.ContentVariant
|
||||
) : GiveawayInfo, ReplyInfo.External.ContentVariant
|
@ -20,7 +20,7 @@ import kotlinx.serialization.json.JsonObject
|
||||
*/
|
||||
@Serializable(LocationSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Location : Locationed, HorizontallyAccured, ExternalReplyInfo.ContentVariant
|
||||
sealed interface Location : Locationed, HorizontallyAccured, ReplyInfo.External.ContentVariant
|
||||
|
||||
@Serializable
|
||||
data class StaticLocation(
|
||||
|
@ -16,7 +16,7 @@ data class ChannelContentMessageImpl<T: MessageContent>(
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val authorSignature: AuthorSignature?,
|
||||
|
@ -17,7 +17,7 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -52,7 +52,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -85,7 +85,7 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -118,7 +118,7 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -151,7 +151,7 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -186,7 +186,7 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
@ -221,7 +221,7 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val content: T,
|
||||
override val senderBot: CommonBot?,
|
||||
|
@ -19,7 +19,7 @@ data class PrivateContentMessageImpl<T: MessageContent>(
|
||||
override val editDate: DateTime?,
|
||||
override val hasProtectedContent: Boolean,
|
||||
override val forwardOrigin: MessageOrigin?,
|
||||
override val replyTo: AccessibleMessage?,
|
||||
override val replyInfo: ReplyInfo?,
|
||||
override val replyMarkup: InlineKeyboardMarkup?,
|
||||
override val senderBot: CommonBot?,
|
||||
override val mediaGroupId: MediaGroupIdentifier?,
|
||||
|
@ -54,6 +54,7 @@ internal data class RawMessage(
|
||||
private val is_topic_message: Boolean? = null,
|
||||
private val is_automatic_forward: Boolean? = null,
|
||||
private val reply_to_message: RawMessage? = null,
|
||||
private val external_reply: ReplyInfo.External? = null,
|
||||
private val via_bot: CommonBot? = null,
|
||||
private val edit_date: TelegramDate? = null,
|
||||
private val has_protected_content: Boolean? = null,
|
||||
@ -282,7 +283,15 @@ internal data class RawMessage(
|
||||
)
|
||||
else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)")
|
||||
}
|
||||
} ?: content?.let { content -> when (chat) {
|
||||
} ?: content?.let { content ->
|
||||
val replyInfo: ReplyInfo? = when {
|
||||
reply_to_message != null -> ReplyInfo.Internal(
|
||||
reply_to_message.asMessage
|
||||
)
|
||||
external_reply != null -> external_reply
|
||||
else -> null
|
||||
}
|
||||
when (chat) {
|
||||
is PreviewPublicChat -> when (chat) {
|
||||
is PreviewChannelChat -> ChannelContentMessageImpl(
|
||||
messageId,
|
||||
@ -292,7 +301,7 @@ internal data class RawMessage(
|
||||
edit_date?.asDate,
|
||||
has_protected_content == true,
|
||||
forward_origin,
|
||||
reply_to_message?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
author_signature,
|
||||
@ -316,7 +325,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -331,7 +340,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -347,7 +356,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -365,7 +374,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -381,7 +390,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -396,7 +405,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -411,7 +420,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -429,7 +438,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -445,7 +454,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -460,7 +469,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -475,7 +484,7 @@ internal data class RawMessage(
|
||||
forward_origin,
|
||||
edit_date ?.asDate,
|
||||
has_protected_content == true,
|
||||
reply_to_message ?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
content,
|
||||
via_bot,
|
||||
@ -492,7 +501,7 @@ internal data class RawMessage(
|
||||
edit_date?.asDate,
|
||||
has_protected_content == true,
|
||||
forward_origin,
|
||||
reply_to_message?.asMessage,
|
||||
replyInfo,
|
||||
reply_markup,
|
||||
via_bot,
|
||||
media_group_id
|
||||
|
@ -1,5 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.ReplyInfo
|
||||
|
||||
interface PossiblyReplyMessage {
|
||||
val replyInfo: ReplyInfo?
|
||||
val replyTo: AccessibleMessage?
|
||||
get() = (replyInfo as? ReplyInfo.Internal) ?.message
|
||||
}
|
@ -17,4 +17,4 @@ data class Invoice(
|
||||
override val currency: Currency,
|
||||
@SerialName(totalAmountField)
|
||||
override val amount: Long
|
||||
) : Amounted, Currencied, ExternalReplyInfo.ContentVariant
|
||||
) : Amounted, Currencied, ReplyInfo.External.ContentVariant
|
||||
|
@ -49,7 +49,7 @@ val LongSeconds.asExactScheduledCloseInfo
|
||||
|
||||
@Serializable(PollSerializer::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Poll : ExternalReplyInfo.ContentVariant {
|
||||
sealed interface Poll : ReplyInfo.External.ContentVariant {
|
||||
val id: PollIdentifier
|
||||
val question: String
|
||||
val options: List<PollOption>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.stories
|
||||
|
||||
import dev.inmo.tgbotapi.types.ExternalReplyInfo
|
||||
import dev.inmo.tgbotapi.types.ReplyInfo
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class Story : ExternalReplyInfo.ContentVariant
|
||||
class Story : ReplyInfo.External.ContentVariant
|
||||
|
@ -23,4 +23,4 @@ data class Venue(
|
||||
override val googlePlaceId: GooglePlaceId? = null,
|
||||
@SerialName(googlePlaceTypeField)
|
||||
override val googlePlaceType: GooglePlaceType? = null
|
||||
) : CommonVenueData, Locationed by location, ExternalReplyInfo.ContentVariant
|
||||
) : CommonVenueData, Locationed by location, ReplyInfo.External.ContentVariant
|
||||
|
@ -40,7 +40,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
sourceMessage.senderBot,
|
||||
sourceMessage.authorSignature,
|
||||
@ -55,7 +55,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
sourceMessage.senderBot,
|
||||
sourceMessage.mediaGroupId
|
||||
@ -67,7 +67,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -82,7 +82,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -96,7 +96,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -111,7 +111,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -126,7 +126,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -142,7 +142,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
@ -157,7 +157,7 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
|
||||
sourceMessage.forwardOrigin,
|
||||
sourceMessage.editDate,
|
||||
sourceMessage.hasProtectedContent,
|
||||
sourceMessage.replyTo,
|
||||
sourceMessage.replyInfo,
|
||||
sourceMessage.replyMarkup,
|
||||
content,
|
||||
sourceMessage.senderBot,
|
||||
|
@ -51,7 +51,7 @@ inline val AccessibleMessage.is_automatic_forward: Boolean?
|
||||
get() = this is ConnectedFromChannelGroupContentMessage<*>
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val AccessibleMessage.reply_to_message: AccessibleMessage?
|
||||
get() = asPossiblyReplyMessage() ?.replyTo
|
||||
get() = asPossiblyReplyMessage() ?.replyInfo
|
||||
@RiskFeature(RawFieldsUsageWarning)
|
||||
inline val AccessibleMessage.via_bot: CommonBot?
|
||||
get() = asPossiblySentViaBotCommonMessage() ?.senderBot
|
||||
|
Loading…
Reference in New Issue
Block a user