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..7b0cce0 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 @@ -20,6 +20,7 @@ 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 +91,7 @@ class TlDrHandler( messageToReply, buildEntities { for (keypoint in videoKeypoints) { - boldln(keypoint.content) + boldln("${buildTimeCode(keypoint.startTime)} ${keypoint.content}") for (thesis in keypoint.theses) { regularln("• ${thesis.content}") } @@ -99,6 +100,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) {