From 039dc1279e234d5bcb6f85ebb4ac3761ee599277 Mon Sep 17 00:00:00 2001 From: "Maksim Pischulenok (aider)" Date: Thu, 29 May 2025 14:15:35 +0300 Subject: [PATCH] refactor: extract confirm commands to list and rename variables --- .../memestv/bot/handler/ThisCommandHandlerService.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/pischule/memestv/bot/handler/ThisCommandHandlerService.kt b/src/main/kotlin/com/pischule/memestv/bot/handler/ThisCommandHandlerService.kt index 8e82e24..3da3202 100644 --- a/src/main/kotlin/com/pischule/memestv/bot/handler/ThisCommandHandlerService.kt +++ b/src/main/kotlin/com/pischule/memestv/bot/handler/ThisCommandHandlerService.kt @@ -17,6 +17,8 @@ class ThisCommandHandlerService( private val botProps: BotProps, private val fileUploaderService: FileUploaderService, ) { + private val confirmCommands = listOf("this", "soxok!") + suspend fun create(env: MessageHandlerEnvironment) { if (!shouldHandleMessage(env)) return @@ -35,9 +37,10 @@ class ThisCommandHandlerService( private fun shouldHandleMessage(env: MessageHandlerEnvironment): Boolean { val isFromTargetChat = env.message.chat.id == botProps.destinationChatId - val isThisCommand = env.message.text?.lowercase() == "this" + val command = env.message.text?.lowercase() + val isConfirmCommand = command in confirmCommands val hasPhotoReply = env.message.replyToMessage?.photo?.isNotEmpty() == true - return isFromTargetChat && isThisCommand && hasPhotoReply + return isFromTargetChat && isConfirmCommand && hasPhotoReply } private suspend fun reactToMessage(env: MessageHandlerEnvironment, emoji: String) {