19 lines
713 B
Lua
19 lines
713 B
Lua
|
|
-- Get first non-loopback IPv4 address via PowerShell Get-NetIPAddress.
|
|||
|
|
local ps = "(Get-NetIPAddress -AddressFamily IPv4 | " ..
|
|||
|
|
"Where-Object {$_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.*'} | " ..
|
|||
|
|
"Select-Object -First 1).IPAddress"
|
|||
|
|
local res = jarvis.system.exec(string.format(
|
|||
|
|
'powershell -NoProfile -Command "%s"', ps
|
|||
|
|
))
|
|||
|
|
|
|||
|
|
if not res.success then
|
|||
|
|
return jarvis.cmd.error("Не получилось узнать IP.")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local ip = (res.stdout or ""):gsub("%s+", "")
|
|||
|
|
if ip == "" then
|
|||
|
|
return jarvis.cmd.not_found("Нет активного сетевого подключения.")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return jarvis.cmd.ok("Локальный адрес: " .. ip .. ".")
|