69 lines
2.1 KiB
Lua
69 lines
2.1 KiB
Lua
|
|
local lang = jarvis.context.language
|
|||
|
|
local phrase = (jarvis.context.phrase or ""):lower()
|
|||
|
|
|
|||
|
|
local triggers = {
|
|||
|
|
"завершить процесс", "выруби процесс", "убей процесс", "kill процесс",
|
|||
|
|
"закрой программу",
|
|||
|
|
"kill process", "close program", "terminate process",
|
|||
|
|
"вбий процес", "закрий програму", "заверши процес",
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
local name = phrase
|
|||
|
|
for _, t in ipairs(triggers) do
|
|||
|
|
local s, e = string.find(name, t, 1, true)
|
|||
|
|
if s == 1 then
|
|||
|
|
name = name:sub(e + 1)
|
|||
|
|
break
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
name = name:gsub("^%s+", ""):gsub("%s+$", "")
|
|||
|
|
|
|||
|
|
local aliases = {
|
|||
|
|
["хром"] = "chrome", ["хрома"] = "chrome",
|
|||
|
|
["спотифай"] = "spotify",
|
|||
|
|
["едж"] = "msedge", ["эдж"] = "msedge", ["edge"] = "msedge",
|
|||
|
|
["файрфокс"] = "firefox", ["фаерфокс"] = "firefox",
|
|||
|
|
["вскод"] = "code", ["vs code"] = "code",
|
|||
|
|
["дискорд"] = "discord",
|
|||
|
|
["телега"] = "telegram", ["телеграм"] = "telegram",
|
|||
|
|
["стим"] = "steam",
|
|||
|
|
["обс"] = "obs64",
|
|||
|
|
["проводник"] = "explorer",
|
|||
|
|
["блокнот"] = "notepad",
|
|||
|
|
["калькулятор"] = "calculatorapp",
|
|||
|
|
["диспетчер задач"] = "taskmgr",
|
|||
|
|
}
|
|||
|
|
local target = aliases[name] or name
|
|||
|
|
|
|||
|
|
if target == "" then
|
|||
|
|
jarvis.system.notify(
|
|||
|
|
lang == "ru" and "Kill" or "Kill",
|
|||
|
|
lang == "ru" and "Какой процесс?" or "Which process?"
|
|||
|
|
)
|
|||
|
|
jarvis.audio.play_error()
|
|||
|
|
return { chain = false }
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
local exe = target:match("%.exe$") and target or (target .. ".exe")
|
|||
|
|
|
|||
|
|
local cmd = string.format('taskkill /F /IM "%s"', exe)
|
|||
|
|
local res = jarvis.system.exec(cmd)
|
|||
|
|
|
|||
|
|
if res.success then
|
|||
|
|
jarvis.log("info", "killed: " .. exe)
|
|||
|
|
jarvis.system.notify(
|
|||
|
|
lang == "ru" and "Завершён" or "Killed",
|
|||
|
|
exe
|
|||
|
|
)
|
|||
|
|
jarvis.audio.play_ok()
|
|||
|
|
else
|
|||
|
|
jarvis.log("warn", "taskkill failed for " .. exe .. ": " .. tostring(res.stderr))
|
|||
|
|
jarvis.system.notify(
|
|||
|
|
lang == "ru" and "Не нашёл процесс" or "Process not found",
|
|||
|
|
exe
|
|||
|
|
)
|
|||
|
|
jarvis.audio.play_not_found()
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
return { chain = false }
|