mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
fixes in updateHandlerWithMediaGroupsAdaptation
This commit is contained in:
parent
90ad34f114
commit
2b8e728559
@ -1,5 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
|
package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafely
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
|
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||||
@ -29,15 +31,18 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
|
|||||||
)
|
)
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
launch {
|
launchSafelyWithoutExceptions {
|
||||||
for (update in updatesChannel) {
|
for (update in updatesChannel) {
|
||||||
when (val data = update.data) {
|
val data = update.data
|
||||||
is PossiblyMediaGroupMessage<*> -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
|
when {
|
||||||
|
data is PossiblyMediaGroupMessage<*> && data.mediaGroupId != null -> {
|
||||||
|
mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
|
||||||
|
}
|
||||||
else -> output(update)
|
else -> output(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
launch {
|
launchSafelyWithoutExceptions {
|
||||||
for ((_, mediaGroup) in mediaGroupAccumulatedChannel) {
|
for ((_, mediaGroup) in mediaGroupAccumulatedChannel) {
|
||||||
mediaGroup.convertWithMediaGroupUpdates().forEach {
|
mediaGroup.convertWithMediaGroupUpdates().forEach {
|
||||||
output(it)
|
output(it)
|
||||||
|
@ -41,10 +41,9 @@ fun Route.includeWebhookHandlingInRoute(
|
|||||||
post {
|
post {
|
||||||
try {
|
try {
|
||||||
runCatchingSafely {
|
runCatchingSafely {
|
||||||
val asJson = nonstrictJsonFormat.parseToJsonElement(call.receiveText())
|
val update = nonstrictJsonFormat.decodeFromString(
|
||||||
val update = nonstrictJsonFormat.decodeFromJsonElement(
|
|
||||||
UpdateDeserializationStrategy,
|
UpdateDeserializationStrategy,
|
||||||
asJson
|
call.receiveText()
|
||||||
)
|
)
|
||||||
transformer(update)
|
transformer(update)
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
|
Loading…
Reference in New Issue
Block a user