mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-02 22:59:48 +00:00
final refactor, fixes and upfilling of changelog
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
internal fun <T> CoroutineScope.wrapWithLaunch(
|
||||
block: suspend (T) -> Unit
|
||||
): suspend (T) -> Unit = {
|
||||
launchSafelyWithoutExceptions {
|
||||
block(it)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T> CoroutineScope.optionallyWrapWithLaunch(
|
||||
wrap: Boolean,
|
||||
block: suspend (T) -> Unit
|
||||
): suspend (T) -> Unit = if (wrap) {
|
||||
wrapWithLaunch(block)
|
||||
} else {
|
||||
block
|
||||
}
|
@@ -1,7 +1,15 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
|
||||
object ByChatMessageMarkerFactory : MarkerFactory<Message, Any> {
|
||||
override suspend fun invoke(data: Message) = data.chat
|
||||
}
|
||||
|
||||
object ByUserMessageMarkerFactory : MarkerFactory<Message, Any> {
|
||||
override suspend fun invoke(data: Message) = when (data) {
|
||||
is FromUserMessage -> data.user
|
||||
is FromChannelGroupContentMessage<*> -> data.channel
|
||||
else -> data.chat // including anonymous
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user