migration onto 2.0.0 and several improvements

This commit is contained in:
InsanusMokrassar 2022-05-22 12:57:53 +06:00
parent 7fb308ea4b
commit 0bf7e33df3
3 changed files with 5 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.first
sealed interface BotState : State sealed interface BotState : State
data class ExpectContentOrStopState(override val context: ChatId, val sourceMessage: CommonMessage<TextContent>) : BotState data class ExpectContentOrStopState(override val context: ChatId, val sourceMessage: CommonMessage<TextContent>) : BotState

View File

@ -1,3 +1,4 @@
import dev.inmo.micro_utils.common.filesize
import dev.inmo.tgbotapi.bot.ktor.telegramBot import dev.inmo.tgbotapi.bot.ktor.telegramBot
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.bot.getMe
@ -64,9 +65,9 @@ suspend fun main(args: Array<String>) {
val chosen = mutableListOf<File>() val chosen = mutableListOf<File>()
while (left > 0) { while (left > 0) {
left-- val picked = pickFile() ?.takeIf { it.filesize > 0 } ?: continue
val picked = pickFile() ?: continue
chosen.add(picked) chosen.add(picked)
left--
if (chosen.size >= mediaCountInMediaGroup.last) { if (chosen.size >= mediaCountInMediaGroup.last) {
sendFiles(message.chat, chosen) sendFiles(message.chat, chosen)
chosen.clear() chosen.clear()

View File

@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx768m
kotlin_version=1.6.21 kotlin_version=1.6.21
telegram_bot_api_version=1.1.3 telegram_bot_api_version=2.0.0
micro_utils_version=0.10.5 micro_utils_version=0.10.5
serialization_version=1.3.3 serialization_version=1.3.3
ktor_version=2.0.1 ktor_version=2.0.1