1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-02 22:59:48 +00:00

fixes in UpdatesChatFilters

This commit is contained in:
2020-04-08 14:51:26 +06:00
parent ba76eaeb90
commit bd87938e9c
3 changed files with 9 additions and 14 deletions

View File

@@ -7,19 +7,13 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMes
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
fun <T : BaseMessageUpdate> Flow<T>.filterByChatId(chatId: ChatId): Flow<T> = filter {
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chatId: ChatId): Flow<T> = filter {
it.data.chat.id == chatId
}
fun <T : BaseMessageUpdate> Flow<T>.filterByChat(chat: Chat): Flow<T> = filterByChatId(chat.id)
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chat: Chat): Flow<T> = filterBaseMessageUpdates(chat.id)
fun <T : SentMediaGroupUpdate> Flow<T>.filterByChatId(chatId: ChatId): Flow<T> = filter {
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chatId: ChatId): Flow<T> = filter {
it.data.first().chat.id == chatId
}
fun <T : SentMediaGroupUpdate> Flow<T>.filterByChatId(chat: Chat): Flow<T> = filterByChatId(chat.id)
fun <T : EditMediaGroupUpdate> Flow<T>.filterByChatId(chatId: ChatId): Flow<T> = filter {
it.data.chat.id == chatId
}
fun <T : EditMediaGroupUpdate> Flow<T>.filterByChatId(chat: Chat): Flow<T> = filterByChatId(chat.id)
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chat: Chat): Flow<T> = filterSentMediaGroupUpdates(chat.id)