J.A.R.V.I.S-rust/resources/commands/daily_quote/quote.lua
Bossiara13 4d3d664abd feat: Now Playing + World Clock + Daily Quote packs (72 → 75 rust packs)
Three small daily-driver packs mirrored with python (commit 02ab8a4 or similar).

now_playing
  - "что играет" / "что за песня" / "какой трек" / "что слушаю"
  - Reads Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager
    via PowerShell — works with Spotify/YouTube/Foobar/Winamp/Yandex Music
    (anything that exposes Windows SMTC, Win10 1803+).
  - Speaks "Сейчас играет: <Artist> — <Title>" or just "<Title>" if no artist.

world_clock
  - "сколько времени в Токио" / "время в Лондоне"
  - 21+ pre-mapped Russian/world city names → IANA timezones.
  - Fetches worldtimeapi.org (free, no key, no rate-limit headers exposed).
  - Parses ISO 8601 datetime, speaks "В <city> сейчас HH:MM."

daily_quote
  - "цитата дня" / "вдохнови меня"
  - zenquotes.io (free, no key) → English quote.
  - LLM translates to Russian via active backend (Groq or Ollama).
  - Falls back to LLM-generated quote if zenquotes is unreachable.
  - Speaks "<translated quote> — <author>."

Tests: 6 commands tests pass (no_duplicate_ids / no_empty_phrases /
all_lua_scripts_exist auto-validate the 3 new packs).
Pack count: 72 → 75.
2026-05-16 00:56:10 +03:00

31 lines
1.4 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- "Цитата дня" — random quote.
-- Source: zenquotes.io (free, no key, returns JSON array)
local data = jarvis.http.json("https://zenquotes.io/api/random")
if not data or type(data) ~= "table" or #data == 0 then
-- Fallback to LLM if API fails
local llm_quote = jarvis.llm({
{ role = "system", content = "Выдай одну короткую мотивирующую цитату. По-русски. Без вступлений." },
{ role = "user", content = "Цитата дня." }
}, { max_tokens = 100, temperature = 0.9 })
if llm_quote and llm_quote ~= "" then
return jarvis.cmd.ok(llm_quote)
end
return jarvis.cmd.error("Не получилось получить цитату.")
end
local q = data[1]
local quote_en = q.q or ""
local author = q.a or "Аноним"
if quote_en == "" then
return jarvis.cmd.error("Пустая цитата.")
end
-- Translate to Russian via LLM (the API returns English).
local translated = jarvis.llm({
{ role = "system", content = "Переведи английскую цитату на русский. Без вступлений. Только перевод." },
{ role = "user", content = quote_en }
}, { max_tokens = 200, temperature = 0.2 })
local text = (translated and translated ~= "") and translated or quote_en
return jarvis.cmd.ok(text .. "" .. author .. ".")