1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-01 23:45:25 +00:00
tgbotapi/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MessageMarkerFactories.kt

16 lines
586 B
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
import dev.inmo.tgbotapi.types.message.abstracts.*
2024-01-07 09:52:49 +00:00
object ByChatMessageMarkerFactory : MarkerFactory<AccessibleMessage, Any> {
override suspend fun invoke(data: AccessibleMessage) = data.chat
}
2024-01-07 09:52:49 +00:00
object ByUserMessageMarkerFactory : MarkerFactory<AccessibleMessage, Any> {
override suspend fun invoke(data: AccessibleMessage) = when (data) {
is FromUserMessage -> data.user
is FromChannelGroupContentMessage<*> -> data.channel
else -> data.chat // including anonymous
}
}