-- "Сколько свободно на диске C" / "сколько места" local phrase = (jarvis.context.phrase or ""):upper() local letter = phrase:match("([A-Z])%s*ДИСК") or phrase:match("ДИСК%s*([A-Z])") or phrase:match("DRIVE%s*([A-Z])") or "C" local ps = string.format( "$d = Get-PSDrive %s -ErrorAction SilentlyContinue; " .. "if ($d) { '{0}|{1}' -f " .. "[math]::Round($d.Free/1GB,1), " .. "[math]::Round(($d.Free + $d.Used)/1GB,0) } else { 'NONE' }", letter ) local res = jarvis.system.exec(string.format( 'powershell -NoProfile -Command "%s"', ps:gsub('"', '\\"') )) if not res.success then return jarvis.cmd.error("Не получилось.") end local out = (res.stdout or ""):gsub("%s+", "") if out == "NONE" or out == "" then return jarvis.cmd.not_found("Диск " .. letter .. " не найден.") end local free_gb, total_gb = out:match("([%d%.]+)|(%d+)") if not free_gb then return jarvis.cmd.error("Не понял ответ системы.") end local pct = math.floor(tonumber(free_gb) / tonumber(total_gb) * 100 + 0.5) return jarvis.cmd.ok(string.format( "На диске %s свободно %s гигабайт из %s, это %d процентов.", letter, free_gb, total_gb, pct ))