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

commonMain.dev.inmo.tgbotapi.extensions.utils.WithEvent.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.*
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()!!




© 2015 - 2024 Weber Informatics LLC | Privacy Policy