feat(commands): analog-inspired tier-2 — news, currency, crypto, fun, wiki, power, help (33 packs)

Seven more portable Lua packs lifted from common voice-assistant
playbooks (Siri/Alexa/Алиса/Cortana). All sandbox=full, jarvis.http
+ jarvis.system.exec, zero new Rust code. cargo test still 3/3.

news/ — pulls Lenta.ru RSS (en switches to BBC), regex-extracts the
top 5 <title> entries (skipping the channel header), drops them into
the clipboard, then asks Groq for a 2-3 sentence summary at temp 0.4
and speaks it via SAPI. If GROQ_TOKEN is missing it falls back to
just reading the first three headlines.

currency/ — cbr-xml-daily.ru/daily_json.js. Picks USD/EUR/CNY/GBP/
JPY/KZT by keyword in the phrase, computes value / nominal, diffs
against Valute.Previous, says "X стоит N рублей, поднялся/опустился
на M" with ▲/▼ in the notify body.

crypto/ — CoinGecko simple/price with usd,rub and 24hr_change.
Recognises bitcoin / ethereum / solana / dogecoin / the-open-network.
Reports price + direction in plain Russian.

fun/ — joke / fact / quote / compliment, single ask.lua dispatched by
command_id. Per-command system prompt at temp 1.0; seeds with a
random integer so consecutive calls don't repeat.

wiki/ — ru.wikipedia opensearch → REST summary endpoint. If Groq is
available and extract > 350 chars, asks for a 2-3 sentence retell;
otherwise speaks the first 400 chars verbatim. Full extract goes to
clipboard.

power/ — shutdown_pc / restart_pc / sleep_pc / hibernate_pc /
logoff_user / cancel_shutdown. Single act.lua keyed by command_id.
shutdown/restart use shutdown.exe /s|/r /t 30 with a /c message —
30-second grace window so "отмени выключение" actually works.
sleep uses rundll32 powrprof,SetSuspendState, hibernate uses
shutdown.exe /h.

help/ — "что ты умеешь". Reads the parent commands/ dir via
jarvis.fs.list, sorts subdirs (pack names), pairs each with a
hardcoded Russian/English one-liner description, copies the full
list to clipboard and speaks a count + "see clipboard for full list".

Total command packs is now 33 (was 26).
This commit is contained in:
Bossiara13 2026-05-15 12:43:09 +03:00
parent dcee98bddf
commit 9d8b917149
14 changed files with 749 additions and 0 deletions

View file

@ -0,0 +1,51 @@
local phrase = (jarvis.context.phrase or ""):lower()
local coin_id, label
if phrase:find("эфир") or phrase:find("eth") or phrase:find("ethereum") then
coin_id, label = "ethereum", "Эфир"
elseif phrase:find("солан") or phrase:find("sol") then
coin_id, label = "solana", "Солана"
elseif phrase:find("doge") or phrase:find("дог") then
coin_id, label = "dogecoin", "Догикоин"
elseif phrase:find("ton") or phrase:find("тон") then
coin_id, label = "the-open-network", "TON"
else
coin_id, label = "bitcoin", "Биткоин"
end
local url = "https://api.coingecko.com/api/v3/simple/price?ids=" .. coin_id .. "&vs_currencies=usd,rub&include_24hr_change=true"
local res = jarvis.http.json(url)
if not res or type(res) ~= "table" or not res[coin_id] then
jarvis.system.notify("Crypto", "CoinGecko не ответил")
jarvis.audio.play_error()
return { chain = false }
end
local data = res[coin_id]
local usd = data.usd
local rub = data.rub
local ch = data.usd_24h_change or 0
local title = string.format("%s: $%s | %s ₽", label, tostring(usd), tostring(math.floor(rub or 0)))
local detail = string.format("за 24 часа %+.2f%%", ch)
jarvis.system.notify(title, detail)
jarvis.log("info", title .. " | " .. detail)
local say
if ch > 1 then
say = string.format("%s стоит %s долларов, за сутки вырос на %.1f процентов.", label, tostring(math.floor(usd)), ch)
elseif ch < -1 then
say = string.format("%s стоит %s долларов, за сутки упал на %.1f процентов.", label, tostring(math.floor(usd)), math.abs(ch))
else
say = string.format("%s стоит %s долларов, без существенных изменений.", label, tostring(math.floor(usd)))
end
local sapi = say:gsub("'", "''")
local ps = string.format(
[[Add-Type -AssemblyName System.Speech; $s = New-Object System.Speech.Synthesis.SpeechSynthesizer; foreach ($v in $s.GetInstalledVoices()) { if ($v.VoiceInfo.Culture.TwoLetterISOLanguageName -eq 'ru') { try { $s.SelectVoice($v.VoiceInfo.Name); break } catch {} } } $s.Speak('%s')]],
sapi
)
jarvis.system.exec(string.format('powershell -NoProfile -Command "%s"', ps:gsub('"', '\\"')))
jarvis.audio.play_ok()
return { chain = false }