mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
add support of Story content and reply_to_story field
This commit is contained in:
parent
a9a01e3154
commit
a01ca43837
@ -45,6 +45,11 @@ value class CustomEmojiId(
|
|||||||
val appLink
|
val appLink
|
||||||
get() = "${internalTgAppLinksBeginning}emoji?id=$this"
|
get() = "${internalTgAppLinksBeginning}emoji?id=$this"
|
||||||
}
|
}
|
||||||
|
@Serializable
|
||||||
|
@JvmInline
|
||||||
|
value class StoryId(
|
||||||
|
val long: Long
|
||||||
|
)
|
||||||
|
|
||||||
typealias Seconds = Int
|
typealias Seconds = Int
|
||||||
typealias MilliSeconds = Long
|
typealias MilliSeconds = Long
|
||||||
|
@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
|||||||
import dev.inmo.tgbotapi.types.giveaway.Giveaway
|
import dev.inmo.tgbotapi.types.giveaway.Giveaway
|
||||||
import dev.inmo.tgbotapi.types.location.Location
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
import dev.inmo.tgbotapi.types.message.MessageOrigin
|
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.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.payments.Invoice
|
import dev.inmo.tgbotapi.types.payments.Invoice
|
||||||
import dev.inmo.tgbotapi.types.polls.Poll
|
import dev.inmo.tgbotapi.types.polls.Poll
|
||||||
@ -34,6 +33,14 @@ sealed interface ReplyInfo {
|
|||||||
get() = message.metaInfo
|
get() = message.metaInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ToStory(
|
||||||
|
val story: Story
|
||||||
|
): ReplyInfo {
|
||||||
|
override val messageMeta: Message.MetaInfo?
|
||||||
|
get() = null
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable(External.Companion::class)
|
@Serializable(External.Companion::class)
|
||||||
sealed interface External : ReplyInfo {
|
sealed interface External : ReplyInfo {
|
||||||
val origin: MessageOrigin
|
val origin: MessageOrigin
|
||||||
|
@ -54,6 +54,7 @@ internal data class RawMessage(
|
|||||||
private val is_topic_message: Boolean? = null,
|
private val is_topic_message: Boolean? = null,
|
||||||
private val is_automatic_forward: Boolean? = null,
|
private val is_automatic_forward: Boolean? = null,
|
||||||
private val reply_to_message: RawMessage? = null,
|
private val reply_to_message: RawMessage? = null,
|
||||||
|
private val reply_to_story: Story? = null,
|
||||||
private val external_reply: ReplyInfo.External? = null,
|
private val external_reply: ReplyInfo.External? = null,
|
||||||
private val quote: TextQuote? = null,
|
private val quote: TextQuote? = null,
|
||||||
private val via_bot: CommonBot? = null,
|
private val via_bot: CommonBot? = null,
|
||||||
@ -300,6 +301,7 @@ internal data class RawMessage(
|
|||||||
reply_to_message != null -> ReplyInfo.Internal(
|
reply_to_message != null -> ReplyInfo.Internal(
|
||||||
reply_to_message.asMessage
|
reply_to_message.asMessage
|
||||||
)
|
)
|
||||||
|
reply_to_story != null -> ReplyInfo.ToStory(reply_to_story)
|
||||||
external_reply != null -> external_reply
|
external_reply != null -> external_reply
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
package dev.inmo.tgbotapi.types.stories
|
package dev.inmo.tgbotapi.types.stories
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ReplyInfo
|
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
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class Story : ReplyInfo.External.ContentVariant
|
class Story(
|
||||||
|
@SerialName(idField)
|
||||||
|
val id: StoryId,
|
||||||
|
@SerialName(chatField)
|
||||||
|
val chat: PreviewChat
|
||||||
|
) : ReplyInfo.External.ContentVariant
|
||||||
|
@ -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()
|
public inline fun <T> ReplyInfo.ifInternal(block: (ReplyInfo.Internal) -> T): T? = internalOrNull()
|
||||||
?.let(block)
|
?.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?
|
public inline fun BotAction.typingActionOrNull(): TypingAction? = this as?
|
||||||
dev.inmo.tgbotapi.types.actions.TypingAction
|
dev.inmo.tgbotapi.types.actions.TypingAction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user