mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
sentMessages extension for FlowsUpdatesFilter
This commit is contained in:
parent
790959ea49
commit
d2228e274c
@ -56,6 +56,8 @@
|
|||||||
* Extensions for `FlowUpdatesFilter` were added:
|
* Extensions for `FlowUpdatesFilter` were added:
|
||||||
* `FlowsUpdatesFilter#allSentMessagesFlow` (combination of `messageFlow` and `channelPostFlow`)
|
* `FlowsUpdatesFilter#allSentMessagesFlow` (combination of `messageFlow` and `channelPostFlow`)
|
||||||
* `FlowsUpdatesFilter#allSentMediaGroupsFlow` (combination of `messageMediaGroupFlow` and `channelPostMediaGroupFlow`)
|
* `FlowsUpdatesFilter#allSentMediaGroupsFlow` (combination of `messageMediaGroupFlow` and `channelPostMediaGroupFlow`)
|
||||||
|
* `FlowsUpdatesFilter#sentMessages`
|
||||||
|
* `FlowsUpdatesFilter#sentMessagesWithMediaGroups`
|
||||||
* `FlowsUpdatesFilter#photoMessagesWithMediaGroups`
|
* `FlowsUpdatesFilter#photoMessagesWithMediaGroups`
|
||||||
* `FlowsUpdatesFilter#imageMessagesWithMediaGroups`
|
* `FlowsUpdatesFilter#imageMessagesWithMediaGroups`
|
||||||
* `FlowsUpdatesFilter#videoMessagesWithMediaGroups`
|
* `FlowsUpdatesFilter#videoMessagesWithMediaGroups`
|
||||||
|
@ -29,3 +29,11 @@ fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T, R> Flow<T>.flatMap(mapper: (T) -> Iterable<R>): Flow<R> = flow {
|
||||||
|
collect {
|
||||||
|
mapper(it).forEach {
|
||||||
|
emit(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -75,6 +75,18 @@ inline fun <reified T: MediaGroupContent> FlowsUpdatesFilter.filterMediaGroupMes
|
|||||||
} ?: messageMediaGroupFlow).filterMediaGroupMessages()
|
} ?: messageMediaGroupFlow).filterMediaGroupMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun FlowsUpdatesFilter.sentMessages(
|
||||||
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
): Flow<ContentMessage<MessageContent>> = filterContentMessages(scopeToIncludeChannels)
|
||||||
|
fun FlowsUpdatesFilter.sentMessagesWithMediaGroups(
|
||||||
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
): Flow<ContentMessage<MessageContent>> = merge(
|
||||||
|
sentMessages(scopeToIncludeChannels),
|
||||||
|
mediaGroupMessages(scopeToIncludeChannels).flatMap {
|
||||||
|
it.mapNotNull { it as? ContentMessage<MessageContent> }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
fun Flow<BaseSentMessageUpdate>.animationMessages() = filterContentMessages<AnimationContent>()
|
fun Flow<BaseSentMessageUpdate>.animationMessages() = filterContentMessages<AnimationContent>()
|
||||||
fun FlowsUpdatesFilter.animationMessages(
|
fun FlowsUpdatesFilter.animationMessages(
|
||||||
scopeToIncludeChannels: CoroutineScope? = null
|
scopeToIncludeChannels: CoroutineScope? = null
|
||||||
|
Loading…
Reference in New Issue
Block a user