commonMain.dev.inmo.tgbotapi.extensions.utils.WithEvent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tgbotapi.utils Show documentation
Show all versions of tgbotapi.utils 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.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.abstracts.*
inline fun ChatEventMessage<*>.withEvent() = if (chatEvent is T) { this as ChatEventMessage } else { null }
inline fun ChatEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun GroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as GroupEventMessage } else { null }
inline fun GroupEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun SupergroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as SupergroupEventMessage } else { null }
inline fun SupergroupEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun PrivateEventMessage<*>.withEvent() = if (chatEvent is T) { this as PrivateEventMessage } else { null }
inline fun PrivateEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun ChannelEventMessage<*>.withEvent() = if (chatEvent is T) { this as ChannelEventMessage } else { null }
inline fun ChannelEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun CommonGroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as CommonGroupEventMessage } else { null }
inline fun CommonGroupEventMessage<*>.requireWithEvent() = withEvent()!!
inline fun CommonSupergroupEventMessage<*>.withEvent() = if (chatEvent is T) { this as CommonSupergroupEventMessage } else { null }
inline fun CommonSupergroupEventMessage<*>.requireWithEvent() = withEvent()!!