mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
small refactor of BaseMessagesUpdatesConversations
This commit is contained in:
parent
5f7633a57e
commit
58943f2504
@ -2,26 +2,19 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.mapNotNull
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = mapNotNull {
|
||||
it as? BaseMessageUpdate
|
||||
}
|
||||
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = filterIsInstance()
|
||||
|
||||
/**
|
||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||
*/
|
||||
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = mapNotNull {
|
||||
it as? BaseSentMessageUpdate
|
||||
}
|
||||
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = filterIsInstance()
|
||||
|
||||
/**
|
||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||
*/
|
||||
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = mapNotNull {
|
||||
it as? BaseEditMessageUpdate
|
||||
}
|
||||
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = filterIsInstance()
|
||||
|
||||
/**
|
||||
* Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate]
|
||||
@ -30,20 +23,14 @@ fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate
|
||||
* @see onlySentMediaGroupUpdates
|
||||
* @see onlyEditMediaGroupUpdates
|
||||
*/
|
||||
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = mapNotNull {
|
||||
it as? MediaGroupUpdate
|
||||
}
|
||||
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = filterIsInstance()
|
||||
|
||||
/**
|
||||
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
||||
*/
|
||||
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = mapNotNull {
|
||||
it as? SentMediaGroupUpdate
|
||||
}
|
||||
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = filterIsInstance()
|
||||
|
||||
/**
|
||||
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
||||
*/
|
||||
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = mapNotNull {
|
||||
it as? EditMediaGroupUpdate
|
||||
}
|
||||
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = filterIsInstance()
|
||||
|
Loading…
Reference in New Issue
Block a user