diff --git a/src/main/kotlin/com/github/djaler/evilbot/clients/YandexGptClient.kt b/src/main/kotlin/com/github/djaler/evilbot/clients/YandexGptClient.kt index 9490d18..39c7a92 100644 --- a/src/main/kotlin/com/github/djaler/evilbot/clients/YandexGptClient.kt +++ b/src/main/kotlin/com/github/djaler/evilbot/clients/YandexGptClient.kt @@ -90,8 +90,10 @@ data class VideoSummaryResult( val keypoints: List? ) +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class Keypoint( val content: String, + val startTime: Long, val theses: List, ) 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 0b873b2..68c28ad 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 @@ -16,10 +16,12 @@ import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextMessage import dev.inmo.tgbotapi.utils.boldln import dev.inmo.tgbotapi.utils.buildEntities +import dev.inmo.tgbotapi.utils.regular import dev.inmo.tgbotapi.utils.regularln import org.apache.logging.log4j.LogManager import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Component +import java.time.Duration @Component @Conditional(YandexApiCondition::class) @@ -90,7 +92,8 @@ class TlDrHandler( messageToReply, buildEntities { for (keypoint in videoKeypoints) { - boldln(keypoint.content) + regular(buildTimeCode(keypoint.startTime)) + boldln(" ${keypoint.content}") for (thesis in keypoint.theses) { regularln("• ${thesis.content}") } @@ -99,6 +102,18 @@ class TlDrHandler( ) } + private fun buildTimeCode(startTime: Long): String { + val duration = Duration.ofSeconds(startTime) + val seconds = duration.toSecondsPart() + val minutes = duration.toMinutesPart() + val hours = duration.toHoursPart() + return if (hours != 0) { + String.format("%02d:%02d:%02d", hours, minutes, seconds); + } else { + String.format("%02d:%02d", minutes, seconds); + } + } + private suspend fun replyWithArticleThesis(link: String, messageToReply: Message) { val thesis = yandexGptService.generateLinkThesis(link) if (thesis != null) {