All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.dev.inmo.tgbotapi.extensions.utils.WithContent.kt Maven / Gradle / Ivy

There is a newer version: 20.0.1
Show newest version
@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()!!




© 2015 - 2024 Weber Informatics LLC | Privacy Policy