From c057b680e7cdf9a5bb99205f1ed484657e560b18 Mon Sep 17 00:00:00 2001 From: Kirill Romanov Date: Sun, 8 Sep 2024 13:45:59 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=80=D0=B0=D0=B7=D0=B1=D0=B8=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=B0=20/tl?= =?UTF-8?q?dr=20=D0=BD=D0=B0=20=D1=87=D0=B0=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evilbot/handlers/commands/TlDrHandler.kt | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/github/djaler/evilbot/handlers/commands/TlDrHandler.kt b/src/main/kotlin/com/github/djaler/evilbot/handlers/commands/TlDrHandler.kt index 1ac2877..b97b7c5 100644 --- a/src/main/kotlin/com/github/djaler/evilbot/handlers/commands/TlDrHandler.kt +++ b/src/main/kotlin/com/github/djaler/evilbot/handlers/commands/TlDrHandler.kt @@ -14,6 +14,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextMessage +import dev.inmo.tgbotapi.types.message.textsources.splitForText import dev.inmo.tgbotapi.utils.boldln import dev.inmo.tgbotapi.utils.buildEntities import dev.inmo.tgbotapi.utils.regular @@ -26,14 +27,14 @@ import java.time.Duration @Component @Conditional(YandexApiCondition::class) class TlDrHandler( - private val requestsExecutor: RequestsExecutor, - private val yandexGptService: YandexGptService, - private val sentryClient: SentryClient, - botInfo: ExtendedBot + private val requestsExecutor: RequestsExecutor, + private val yandexGptService: YandexGptService, + private val sentryClient: SentryClient, + botInfo: ExtendedBot ) : CommandHandler( - botInfo, - command = arrayOf("tldr"), - commandDescription = "пересказать содержимое по ссылке" + botInfo, + command = arrayOf("tldr"), + commandDescription = "пересказать содержимое по ссылке" ) { companion object { private val log = LogManager.getLogger() @@ -41,8 +42,8 @@ class TlDrHandler( } override suspend fun handleCommand( - message: TextMessage, - args: String? + message: TextMessage, + args: String? ) { val messageToReply: Message val link: String? @@ -88,18 +89,22 @@ class TlDrHandler( return } - requestsExecutor.reply( - messageToReply, - buildEntities { - for (keypoint in videoKeypoints) { - regular(buildTimeCode(keypoint.startTime)) - boldln(" ${keypoint.content}") - for (thesis in keypoint.theses) { - regularln("• ${thesis.content}") - } + val messageContent = buildEntities { + for (keypoint in videoKeypoints) { + regular(buildTimeCode(keypoint.startTime)) + boldln(" ${keypoint.content}") + for (thesis in keypoint.theses) { + regularln("• ${thesis.content}") } } - ) + } + + messageContent.splitForText().forEach { part -> + requestsExecutor.reply( + messageToReply, + part + ) + } } private fun buildTimeCode(startTime: Long): String {