-- "Выключи компьютер через 30 минут" → shutdown.exe /s /t -- Использует штатный shutdown с обратным таймером. local phrase = (jarvis.context.phrase or ""):lower() local n_str, unit = phrase:match("(%d+)%s+(%S+)") if not n_str then return jarvis.cmd.error("Не понял через сколько.") end local n = tonumber(n_str) local secs if unit:match("^минут") then secs = n * 60 elseif unit:match("^час") then secs = n * 3600 elseif unit:match("^секунд") then secs = n else return jarvis.cmd.error("Не понял единицу. Минуты или часы.") end if secs > 86400 then return jarvis.cmd.error("Слишком большое значение — максимум 24 часа.") end local cmd = string.format( 'shutdown.exe /s /t %d /c "Sleep timer fired"', secs ) local res = jarvis.system.exec(cmd) if not res.success then return jarvis.cmd.error("Не получилось поставить таймер.") end -- Pluralisation local label if unit:match("^минут") then local last = n % 10 if last == 1 and n % 100 ~= 11 then label = n .. " минуту" elseif last >= 2 and last <= 4 and (n % 100 < 10 or n % 100 >= 20) then label = n .. " минуты" else label = n .. " минут" end elseif unit:match("^час") then local last = n % 10 if last == 1 and n % 100 ~= 11 then label = n .. " час" elseif last >= 2 and last <= 4 and (n % 100 < 10 or n % 100 >= 20) then label = n .. " часа" else label = n .. " часов" end else label = n .. " секунд" end return jarvis.cmd.ok("Выключу компьютер через " .. label .. ". Скажите 'отмени таймер выключения' чтобы передумать.")