mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +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.MediaGroupUpdates.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlinx.coroutines.flow.mapNotNull
|
|
||||||
|
|
||||||
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = mapNotNull {
|
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseSentMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseEditMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate]
|
* 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 onlySentMediaGroupUpdates
|
||||||
* @see onlyEditMediaGroupUpdates
|
* @see onlyEditMediaGroupUpdates
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = filterIsInstance()
|
||||||
it as? MediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = mapNotNull {
|
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = filterIsInstance()
|
||||||
it as? SentMediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = mapNotNull {
|
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = filterIsInstance()
|
||||||
it as? EditMediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user