commonMain.dev.inmo.tgbotapi.extensions.utils.WithContent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tgbotapi.utils-jvm Show documentation
Show all versions of tgbotapi.utils-jvm Show documentation
Additional extensions for core part of tgbotapi
@file:Suppress("UNCHECKED_CAST")
package dev.inmo.tgbotapi.extensions.utils
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.MessageContent
inline fun ContentMessage<*>.withContent() = if (content is T) { this as ContentMessage } else { null }
inline fun ContentMessage<*>.requireWithContent() = withContent()!!
inline fun CommonMessage<*>.withContent() = if (content is T) { this as CommonMessage } else { null }
inline fun CommonMessage<*>.requireWithContent() = withContent()!!
inline fun PossiblySentViaBotCommonMessage<*>.withContent() = if (content is T) { this as PossiblySentViaBotCommonMessage
} else { null }
inline fun PossiblySentViaBotCommonMessage<*>.requireWithContent() = withContent()!!
inline fun ChannelContentMessage<*>.withContent() = if (content is T) { this as ChannelContentMessage } else { null }
inline fun ChannelContentMessage<*>.requireWithContent() = withContent()!!
inline fun PrivateContentMessage<*>.withContent() = if (content is T) { this as PrivateContentMessage } else { null }
inline fun PrivateContentMessage<*>.requireWithContent() = withContent()!!
inline fun BusinessContentMessage<*>.withContent() = if (content is T) { this as BusinessContentMessage } else { null }
inline fun BusinessContentMessage<*>.requireWithContent() = withContent()!!
inline fun PublicContentMessage<*>.withContent() = if (content is T) { this as PublicContentMessage } else { null }
inline fun PublicContentMessage<*>.requireWithContent() = withContent()!!
inline fun GroupContentMessage<*>.withContent() = if (content is T) { this as GroupContentMessage } else { null }
inline fun GroupContentMessage<*>.requireWithContent() = withContent()!!
inline fun FromChannelGroupContentMessage<*>.withContent() = if (content is T) { this as FromChannelGroupContentMessage } else { null }
inline fun FromChannelGroupContentMessage<*>.requireWithContent() = withContent()!!
inline fun AnonymousGroupContentMessage<*>.withContent() = if (content is T) { this as AnonymousGroupContentMessage } else { null }
inline fun AnonymousGroupContentMessage<*>.requireWithContent() = withContent()!!
inline fun CommonGroupContentMessage<*>.withContent() = if (content is T) { this as CommonGroupContentMessage } else { null }
inline fun CommonGroupContentMessage<*>.requireWithContent() = withContent()!!