add support of Story content and reply_to_story field

This commit is contained in:
InsanusMokrassar 2024-02-16 21:54:13 +06:00
parent a9a01e3154
commit a01ca43837
5 changed files with 35 additions and 2 deletions

View File

@ -45,6 +45,11 @@ value class CustomEmojiId(
val appLink
get() = "${internalTgAppLinksBeginning}emoji?id=$this"
}
@Serializable
@JvmInline
value class StoryId(
val long: Long
)
typealias Seconds = Int
typealias MilliSeconds = Long

View File

@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
import dev.inmo.tgbotapi.types.giveaway.Giveaway
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
@ -34,6 +33,14 @@ sealed interface ReplyInfo {
get() = message.metaInfo
}
@Serializable
data class ToStory(
val story: Story
): ReplyInfo {
override val messageMeta: Message.MetaInfo?
get() = null
}
@Serializable(External.Companion::class)
sealed interface External : ReplyInfo {
val origin: MessageOrigin

View File

@ -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 reply_to_story: Story? = null,
private val external_reply: ReplyInfo.External? = null,
private val quote: TextQuote? = null,
private val via_bot: CommonBot? = null,
@ -300,6 +301,7 @@ internal data class RawMessage(
reply_to_message != null -> ReplyInfo.Internal(
reply_to_message.asMessage
)
reply_to_story != null -> ReplyInfo.ToStory(reply_to_story)
external_reply != null -> external_reply
else -> null
}

View File

@ -1,7 +1,17 @@
package dev.inmo.tgbotapi.types.stories
import dev.inmo.tgbotapi.types.ReplyInfo
import dev.inmo.tgbotapi.types.StoryId
import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.chatField
import dev.inmo.tgbotapi.types.idField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
class Story : ReplyInfo.External.ContentVariant
class Story(
@SerialName(idField)
val id: StoryId,
@SerialName(chatField)
val chat: PreviewChat
) : ReplyInfo.External.ContentVariant

View File

@ -1631,6 +1631,15 @@ public inline fun ReplyInfo.internalOrThrow(): ReplyInfo.Internal = this as
public inline fun <T> ReplyInfo.ifInternal(block: (ReplyInfo.Internal) -> T): T? = internalOrNull()
?.let(block)
public inline fun ReplyInfo.toStoryOrNull(): ReplyInfo.ToStory? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.ToStory
public inline fun ReplyInfo.toStoryOrThrow(): ReplyInfo.ToStory = this as
dev.inmo.tgbotapi.types.ReplyInfo.ToStory
public inline fun <T> ReplyInfo.ifToStory(block: (ReplyInfo.ToStory) -> T): T? = toStoryOrNull()
?.let(block)
public inline fun BotAction.typingActionOrNull(): TypingAction? = this as?
dev.inmo.tgbotapi.types.actions.TypingAction