package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.EditMediaGroupUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.SentMediaGroupUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter /** * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] */ fun Flow.filterByChatId(chatId: ChatId): Flow = filter { it.data.chat.id == chatId } /** * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat] */ fun Flow.filterByChat(chat: Chat): Flow = filterByChatId(chat.id) /** * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] */ @Deprecated("Renamed", ReplaceWith("filterByChatId")) fun Flow.filterBaseMessageUpdates(chatId: ChatId): Flow = filterByChatId(chatId) /** * [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat] */ @Deprecated("Renamed", ReplaceWith("filterByChat")) fun Flow.filterBaseMessageUpdates(chat: Chat): Flow = filterByChatId(chat.id) /** * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] */ fun Flow.filterByChatId(chatId: ChatId): Flow = filter { it.data.first().chat.id == chatId } /** * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat] */ fun Flow.filterByChat(chat: Chat): Flow = filterByChatId(chat.id) /** * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] */ @Deprecated("Renamed", ReplaceWith("filterByChatId")) fun Flow.filterSentMediaGroupUpdates(chatId: ChatId): Flow = filterByChatId(chatId) /** * [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat] */ @Deprecated("Renamed", ReplaceWith("filterByChat")) fun Flow.filterSentMediaGroupUpdates(chat: Chat): Flow = filterByChatId(chat.id)