1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-25 19:48:43 +00:00

add several functions and changelog notes

This commit is contained in:
InsanusMokrassar 2020-11-12 22:23:10 +06:00
parent f6ec82b449
commit b0219389fc
3 changed files with 22 additions and 5 deletions

View File

@ -4,7 +4,7 @@
* `Common`: * `Common`:
* `Version`: * `Version`:
* `MicroUtils`: `0.3.1` -> `0.3.2` * `MicroUtils`: `0.3.1` -> `0.3.3`
* `Core`: * `Core`:
* `MultilevelTextSource#textSources` has been safely renamed to `subsources` * `MultilevelTextSource#textSources` has been safely renamed to `subsources`
* `TextContent#fullEntitiesList` has been deprecated * `TextContent#fullEntitiesList` has been deprecated
@ -14,7 +14,13 @@
* `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent` * `SupergroupEventMessage` now overrides `chatEvent` with type `SupergroupEvent`
* Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages) * Any `ChatEventMessage` now have generic type of its `chatEvent` (just like messages)
* `Utils`: * `Utils`:
* A lot of extensions for `Flow<ChatEventMessage>` has been added * Old extensions related to chat events are deprecated:
* `Flow<ChatEventMessage<*>>#divideBySource`
* `Flow<ChatEventMessage<*>>#onlyChannelEvents`
* `Flow<ChatEventMessage<*>>#onlyGroupEvents`
* `Flow<ChatEventMessage<*>>#onlySupergroupEvents`
* A lot of extensions for `Flow<ChatEventMessage>` has been added:
* `FlowsUpdatesFilter#channelEvents`
## 0.30.3 ## 0.30.3

View File

@ -12,7 +12,7 @@ klock_version=1.12.1
uuid_version=0.2.2 uuid_version=0.2.2
ktor_version=1.4.2 ktor_version=1.4.2
micro_utils_version=0.3.2 micro_utils_version=0.3.3
javax_activation_version=1.1.1 javax_activation_version=1.1.1

View File

@ -2,6 +2,7 @@
package dev.inmo.tgbotapi.extensions.utils.shortcuts package dev.inmo.tgbotapi.extensions.utils.shortcuts
import dev.inmo.micro_utils.coroutines.plus
import dev.inmo.tgbotapi.types.message.ChannelEventMessage import dev.inmo.tgbotapi.types.message.ChannelEventMessage
import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.* import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
@ -10,14 +11,24 @@ import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
@RiskFeature("Use with caution")
inline fun FlowsUpdatesFilter.events(): Flow<ChatEventMessage<*>> {
return channelPostFlow.mapNotNull { it.data as? ChatEventMessage<*> } + messageFlow.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<*>> = channelPostFlow.mapNotNull {
it.data as? ChannelEventMessage<*> it.data as? ChannelEventMessage<*>
} }
@RiskFeature("Use with caution") @RiskFeature("Use with caution")
inline fun <reified T: GroupEventMessage<*>> FlowsUpdatesFilter.groupEvents(): Flow<T> = messageFlow.mapNotNull { inline fun FlowsUpdatesFilter.groupEvents(): Flow<GroupEventMessage<*>> = messageFlow.mapNotNull {
it.data as? T it.data as? GroupEventMessage<*>
}
@RiskFeature("Use with caution")
inline fun FlowsUpdatesFilter.supergroupEvents(): Flow<SupergroupEventMessage<*>> = messageFlow.mapNotNull {
it.data as? SupergroupEventMessage<*>
} }
@RiskFeature("Use with caution") @RiskFeature("Use with caution")