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

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

There is a newer version: 20.0.1
Show newest version
@file:Suppress("unused")

package dev.inmo.tgbotapi.extensions.utils.updates

import dev.inmo.tgbotapi.types.message.PassportMessage
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.mapNotNull

/**
 * Will map incoming [BaseSentMessageUpdate]s to [ContentMessage] from [BaseSentMessageUpdate.data]
 */
fun  Flow.asContentMessagesFlow() = mapNotNull {
    it.data as? ContentMessage<*>
}

/**
 * Will map incoming [BaseSentMessageUpdate]s to [CommonMessage] from [BaseSentMessageUpdate.data]
 */
fun  Flow.asCommonMessagesFlow() = mapNotNull {
    it.data as? CommonMessage<*>
}

@Suppress("NOTHING_TO_INLINE")
inline fun  Flow.chatEvents() = mapNotNull {
    it.data as? ChatEventMessage<*>
}

@Suppress("NOTHING_TO_INLINE")
inline fun  Flow.passportMessages() = mapNotNull {
    it.data as? PassportMessage
}

/**
 * Will map incoming [BaseSentMessageUpdate]s to [UnknownMessageType] from [BaseSentMessageUpdate.data]
 */
fun  Flow.asUnknownMessagesFlow() = mapNotNull {
    it.data as? UnknownMessageType
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy