mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
FlowsUpdatesFilter update
This commit is contained in:
parent
226b8dee21
commit
d8f830c60f
@ -6,6 +6,8 @@
|
|||||||
* `Version`:
|
* `Version`:
|
||||||
* `Klock`: `2.3.1` -> `2.3.3`
|
* `Klock`: `2.3.1` -> `2.3.3`
|
||||||
* `MicroUtils`: `0.5.19` -> `0.5.21`
|
* `MicroUtils`: `0.5.19` -> `0.5.21`
|
||||||
|
* `Core`:
|
||||||
|
* All `FlowsUpdatesFilter` flows have been renamed and updated
|
||||||
* `Utils`:
|
* `Utils`:
|
||||||
* Extensions `allSentMessagesFlow` and `allSentMediaGroupsFlow` have been deprecated
|
* Extensions `allSentMessagesFlow` and `allSentMediaGroupsFlow` have been deprecated
|
||||||
|
|
||||||
|
@ -14,24 +14,79 @@ interface FlowsUpdatesFilter : UpdatesFilter {
|
|||||||
val allUpdatesFlow: Flow<Update>
|
val allUpdatesFlow: Flow<Update>
|
||||||
val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update>
|
val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update>
|
||||||
|
|
||||||
|
val messagesFlow: Flow<MessageUpdate>
|
||||||
|
val messageMediaGroupsFlow: Flow<MessageMediaGroupUpdate>
|
||||||
|
val editedMessagesFlow: Flow<EditMessageUpdate>
|
||||||
|
val editedMessageMediaGroupsFlow: Flow<EditMessageMediaGroupUpdate>
|
||||||
|
val channelPostsFlow: Flow<ChannelPostUpdate>
|
||||||
|
val channelPostMediaGroupsFlow: Flow<ChannelPostMediaGroupUpdate>
|
||||||
|
val editedChannelPostsFlow: Flow<EditChannelPostUpdate>
|
||||||
|
val editedChannelPostMediaGroupsFlow: Flow<EditChannelPostMediaGroupUpdate>
|
||||||
|
val chosenInlineResultsFlow: Flow<ChosenInlineResultUpdate>
|
||||||
|
val inlineQueriesFlow: Flow<InlineQueryUpdate>
|
||||||
|
val callbackQueriesFlow: Flow<CallbackQueryUpdate>
|
||||||
|
val shippingQueriesFlow: Flow<ShippingQueryUpdate>
|
||||||
|
val preCheckoutQueriesFlow: Flow<PreCheckoutQueryUpdate>
|
||||||
|
val pollsFlow: Flow<PollUpdate>
|
||||||
|
val pollAnswersFlow: Flow<PollAnswerUpdate>
|
||||||
|
val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate>
|
||||||
|
val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate>
|
||||||
|
val unknownUpdatesFlow: Flow<UnknownUpdate>
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("messagesFlow"))
|
||||||
val messageFlow: Flow<MessageUpdate>
|
val messageFlow: Flow<MessageUpdate>
|
||||||
|
get() = messagesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("messageMediaGroupsFlow"))
|
||||||
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate>
|
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate>
|
||||||
|
get() = messageMediaGroupsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("editedMessagesFlow"))
|
||||||
val editedMessageFlow: Flow<EditMessageUpdate>
|
val editedMessageFlow: Flow<EditMessageUpdate>
|
||||||
|
get() = editedMessagesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("editedMessageMediaGroupsFlow"))
|
||||||
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate>
|
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate>
|
||||||
|
get() = editedMessageMediaGroupsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("channelPostsFlow"))
|
||||||
val channelPostFlow: Flow<ChannelPostUpdate>
|
val channelPostFlow: Flow<ChannelPostUpdate>
|
||||||
|
get() = channelPostsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("channelPostMediaGroupsFlow"))
|
||||||
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate>
|
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate>
|
||||||
|
get() = channelPostMediaGroupsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("editedChannelPostsFlow"))
|
||||||
val editedChannelPostFlow: Flow<EditChannelPostUpdate>
|
val editedChannelPostFlow: Flow<EditChannelPostUpdate>
|
||||||
|
get() = editedChannelPostsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("editedChannelPostMediaGroupsFlow"))
|
||||||
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate>
|
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate>
|
||||||
|
get() = editedChannelPostMediaGroupsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("chosenInlineResultsFlow"))
|
||||||
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate>
|
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate>
|
||||||
|
get() = chosenInlineResultsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("inlineQueriesFlow"))
|
||||||
val inlineQueryFlow: Flow<InlineQueryUpdate>
|
val inlineQueryFlow: Flow<InlineQueryUpdate>
|
||||||
|
get() = inlineQueriesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("callbackQueriesFlow"))
|
||||||
val callbackQueryFlow: Flow<CallbackQueryUpdate>
|
val callbackQueryFlow: Flow<CallbackQueryUpdate>
|
||||||
|
get() = callbackQueriesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("shippingQueriesFlow"))
|
||||||
val shippingQueryFlow: Flow<ShippingQueryUpdate>
|
val shippingQueryFlow: Flow<ShippingQueryUpdate>
|
||||||
|
get() = shippingQueriesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("preCheckoutQueriesFlow"))
|
||||||
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate>
|
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate>
|
||||||
|
get() = preCheckoutQueriesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("pollsFlow"))
|
||||||
val pollFlow: Flow<PollUpdate>
|
val pollFlow: Flow<PollUpdate>
|
||||||
|
get() = pollsFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("pollAnswersFlow"))
|
||||||
val pollAnswerFlow: Flow<PollAnswerUpdate>
|
val pollAnswerFlow: Flow<PollAnswerUpdate>
|
||||||
|
get() = pollAnswersFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("chatMemberUpdatesFlow"))
|
||||||
val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate>
|
val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate>
|
||||||
|
get() = chatMemberUpdatesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("myChatMemberUpdatesFlow"))
|
||||||
val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate>
|
val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate>
|
||||||
|
get() = myChatMemberUpdatesFlow
|
||||||
|
@Deprecated("Renamed", ReplaceWith("unknownUpdatesFlow"))
|
||||||
val unknownUpdateTypeFlow: Flow<UnknownUpdate>
|
val unknownUpdateTypeFlow: Flow<UnknownUpdate>
|
||||||
|
get() = unknownUpdatesFlow
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,22 +118,22 @@ class DefaultFlowsUpdatesFilter(
|
|||||||
updatesSharedFlow.emit(it)
|
updatesSharedFlow.emit(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
override val messagesFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
override val messageMediaGroupsFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val editedMessageFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
override val editedMessagesFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
override val editedMessageMediaGroupsFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val channelPostFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
override val channelPostsFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
override val channelPostMediaGroupsFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val editedChannelPostFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
override val editedChannelPostsFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
override val editedChannelPostMediaGroupsFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
override val chosenInlineResultsFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val inlineQueryFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
override val inlineQueriesFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val callbackQueryFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
override val callbackQueriesFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val shippingQueryFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
override val shippingQueriesFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
override val preCheckoutQueriesFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val pollFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
override val pollsFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val pollAnswerFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
override val pollAnswersFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val chatMemberUpdatedFlow: Flow<CommonChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
override val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val myChatMemberUpdatedFlow: Flow<MyChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
override val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
override val unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
override val unknownUpdatesFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.merge
|
import kotlinx.coroutines.flow.merge
|
||||||
|
|
||||||
@Deprecated("Will be removed soon", ReplaceWith("messageFlow + channelPostFlow"))
|
@Deprecated("Will be removed soon", ReplaceWith("messagesFlow + channelPostsFlow"))
|
||||||
val FlowsUpdatesFilter.allSentMessagesFlow: Flow<BaseSentMessageUpdate>
|
val FlowsUpdatesFilter.allSentMessagesFlow: Flow<BaseSentMessageUpdate>
|
||||||
get() = merge(
|
get() = merge(
|
||||||
messagesFlow,
|
messagesFlow,
|
||||||
channelPostsFlow
|
channelPostsFlow
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated("Will be removed soon", ReplaceWith("messageMediaGroupFlow + channelPostMediaGroupFlow"))
|
@Deprecated("Will be removed soon", ReplaceWith("messageMediaGroupsFlow + channelPostMediaGroupsFlow"))
|
||||||
val FlowsUpdatesFilter.allSentMediaGroupsFlow: Flow<SentMediaGroupUpdate>
|
val FlowsUpdatesFilter.allSentMediaGroupsFlow: Flow<SentMediaGroupUpdate>
|
||||||
get() = merge(
|
get() = merge(
|
||||||
messageMediaGroupsFlow,
|
messageMediaGroupsFlow,
|
||||||
|
@ -14,21 +14,21 @@ import kotlinx.coroutines.flow.mapNotNull
|
|||||||
|
|
||||||
@RiskFeature("Use with caution")
|
@RiskFeature("Use with caution")
|
||||||
inline fun FlowsUpdatesFilter.events(): Flow<ChatEventMessage<*>> {
|
inline fun FlowsUpdatesFilter.events(): Flow<ChatEventMessage<*>> {
|
||||||
return channelPostFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messageFlow.mapNotNull { it.data as? ChatEventMessage<*> }
|
return channelPostsFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messagesFlow.mapNotNull { it.data as? ChatEventMessage<*> }
|
||||||
}
|
}
|
||||||
|
|
||||||
@RiskFeature("Use with caution")
|
@RiskFeature("Use with caution")
|
||||||
inline fun FlowsUpdatesFilter.channelEvents(): Flow<ChannelEventMessage<*>> = channelPostFlow.mapNotNull {
|
inline fun FlowsUpdatesFilter.channelEvents(): Flow<ChannelEventMessage<*>> = channelPostsFlow.mapNotNull {
|
||||||
it.data as? ChannelEventMessage<*>
|
it.data as? ChannelEventMessage<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
@RiskFeature("Use with caution")
|
@RiskFeature("Use with caution")
|
||||||
inline fun FlowsUpdatesFilter.groupEvents(): Flow<GroupEventMessage<*>> = messageFlow.mapNotNull {
|
inline fun FlowsUpdatesFilter.groupEvents(): Flow<GroupEventMessage<*>> = messagesFlow.mapNotNull {
|
||||||
it.data as? GroupEventMessage<*>
|
it.data as? GroupEventMessage<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
@RiskFeature("Use with caution")
|
@RiskFeature("Use with caution")
|
||||||
inline fun FlowsUpdatesFilter.supergroupEvents(): Flow<SupergroupEventMessage<*>> = messageFlow.mapNotNull {
|
inline fun FlowsUpdatesFilter.supergroupEvents(): Flow<SupergroupEventMessage<*>> = messagesFlow.mapNotNull {
|
||||||
it.data as? SupergroupEventMessage<*>
|
it.data as? SupergroupEventMessage<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ inline fun <reified T : MediaGroupContent> Flow<SentMediaGroupUpdate>.filterMedi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too.
|
* @param scopeToIncludeChannels This parameter is required when you want to include [textMessages] for channels too.
|
||||||
* In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and
|
* In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messagesFlow] and
|
||||||
* [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping
|
* [FlowsUpdatesFilter.channelPostsFlow]. In case it is null will be used [Flow]s mapping
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||||
@ -58,16 +58,16 @@ inline fun <reified T: MessageContent> FlowsUpdatesFilter.filterContentMessages(
|
|||||||
return (scopeToIncludeChannels ?.let { scope ->
|
return (scopeToIncludeChannels ?.let { scope ->
|
||||||
aggregateFlows(
|
aggregateFlows(
|
||||||
scope,
|
scope,
|
||||||
messageFlow,
|
messagesFlow,
|
||||||
channelPostFlow
|
channelPostsFlow
|
||||||
)
|
)
|
||||||
} ?: messageFlow).filterContentMessages()
|
} ?: messagesFlow).filterContentMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param scopeToIncludeChannels This parameter is required when you want to include [SentMediaGroupUpdate] for channels
|
* @param scopeToIncludeChannels This parameter is required when you want to include [SentMediaGroupUpdate] for channels
|
||||||
* too. In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messageFlow] and
|
* too. In this case will be created new channel which will aggregate messages from [FlowsUpdatesFilter.messagesFlow] and
|
||||||
* [FlowsUpdatesFilter.channelPostFlow]. In case it is null will be used [Flow]s mapping
|
* [FlowsUpdatesFilter.channelPostsFlow]. In case it is null will be used [Flow]s mapping
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||||
@ -77,10 +77,10 @@ inline fun <reified T: MediaGroupContent> FlowsUpdatesFilter.filterMediaGroupMes
|
|||||||
return (scopeToIncludeChannels ?.let { scope ->
|
return (scopeToIncludeChannels ?.let { scope ->
|
||||||
aggregateFlows(
|
aggregateFlows(
|
||||||
scope,
|
scope,
|
||||||
messageMediaGroupFlow,
|
messageMediaGroupsFlow,
|
||||||
channelPostMediaGroupFlow
|
channelPostMediaGroupsFlow
|
||||||
)
|
)
|
||||||
} ?: messageMediaGroupFlow).filterMediaGroupMessages()
|
} ?: messageMediaGroupsFlow).filterMediaGroupMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun FlowsUpdatesFilter.sentMessages(
|
fun FlowsUpdatesFilter.sentMessages(
|
||||||
|
Loading…
Reference in New Issue
Block a user