commonMain.com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.SentMessageUpdatesConversations.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TelegramBotAPI-extensions-utils-js Show documentation
Show all versions of TelegramBotAPI-extensions-utils-js Show documentation
Util extensions for more useful work with updates and other things
The newest version!
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.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<*>
}
/**
* Will map incoming [BaseSentMessageUpdate]s to [ChatEventMessage] from [BaseSentMessageUpdate.data]
*/
fun Flow.asChatEventsFlow() = mapNotNull {
it.data as? ChatEventMessage
}
/**
* Will map incoming [BaseSentMessageUpdate]s to [UnknownMessageType] from [BaseSentMessageUpdate.data]
*/
fun Flow.asUnknownMessagesFlow() = mapNotNull {
it.data as? UnknownMessageType
}