
commonMain.dev.inmo.tgbotapi.extensions.utils.ContentCastsNew.kt Maven / Gradle / Ivy
@file:Suppress("UNCHECKED_CAST")
package dev.inmo.tgbotapi.extensions.utils
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.MessageContent
inline fun ContentMessage<*>.withContentOrNull() = if (content is T) { this as ContentMessage } else { null }
inline fun ContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun CommonMessage<*>.withContentOrNull() = if (content is T) { this as CommonMessage } else { null }
inline fun CommonMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun PossiblySentViaBotCommonMessage<*>.withContentOrNull() = if (content is T) { this as PossiblySentViaBotCommonMessage
} else { null }
inline fun PossiblySentViaBotCommonMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun ChannelContentMessage<*>.withContentOrNull() = if (content is T) { this as ChannelContentMessage } else { null }
inline fun ChannelContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun PrivateContentMessage<*>.withContentOrNull() = if (content is T) { this as PrivateContentMessage } else { null }
inline fun PrivateContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun PublicContentMessage<*>.withContentOrNull() = if (content is T) { this as PublicContentMessage } else { null }
inline fun PublicContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun GroupContentMessage<*>.withContentOrNull() = if (content is T) { this as GroupContentMessage } else { null }
inline fun GroupContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun FromChannelGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as FromChannelGroupContentMessage } else { null }
inline fun FromChannelGroupContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun AnonymousGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as AnonymousGroupContentMessage } else { null }
inline fun AnonymousGroupContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
inline fun CommonGroupContentMessage<*>.withContentOrNull() = if (content is T) { this as CommonGroupContentMessage } else { null }
inline fun CommonGroupContentMessage<*>.withContentOrThrow() = withContentOrNull()!!
© 2015 - 2025 Weber Informatics LLC | Privacy Policy