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.
This commit is contained in:
Bossiara13 2026-05-16 00:56:10 +03:00
parent 4efe306b3a
commit 4d3d664abd
6 changed files with 233 additions and 0 deletions

View file

@ -0,0 +1,24 @@
# Windows Media Session — what's currently playing.
# Uses Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager
# via PowerShell. Works with Spotify, YouTube, Foobar, Yandex Music, anything
# that exposes SMTC.
[[commands]]
id = "now_playing"
type = "lua"
script = "now.lua"
sandbox = "full"
timeout = 8000
[commands.phrases]
ru = [
"что играет",
"что сейчас играет",
"что за музыка",
"что за песня",
"какой трек",
"какая песня",
"что слушаю",
]
en = ["what's playing", "current song", "now playing"]
ua = ["що грає", "що зараз грає"]

View file

@ -0,0 +1,46 @@
-- "Что играет" — query Windows SMTC.
-- Requires Windows 10 1803+ (Media Session API).
local ps = [[
[Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager,Windows.Media.Control,ContentType=WindowsRuntime] | Out-Null
$mgr = [Windows.Media.Control.GlobalSystemMediaTransportControlsSessionManager]::RequestAsync()
while ($mgr.Status -eq 0) { Start-Sleep -Milliseconds 50 }
$session = $mgr.GetResults().GetCurrentSession()
if (-not $session) { Write-Output 'NONE'; exit }
$propsTask = $session.TryGetMediaPropertiesAsync()
while ($propsTask.Status -eq 0) { Start-Sleep -Milliseconds 50 }
$props = $propsTask.GetResults()
$artist = $props.Artist
$title = $props.Title
if ([string]::IsNullOrEmpty($artist) -and [string]::IsNullOrEmpty($title)) {
Write-Output 'EMPTY'
exit
}
Write-Output ("{0}|{1}" -f $artist, $title)
]]
local res = jarvis.system.exec(string.format(
'powershell -NoProfile -ExecutionPolicy Bypass -Command "%s"',
ps:gsub('"', '\\"'):gsub("\r?\n", "; ")
))
if not res.success then
return jarvis.cmd.error("Не получилось получить данные.")
end
local out = (res.stdout or ""):gsub("^%s+", ""):gsub("%s+$", "")
if out == "NONE" then
return jarvis.cmd.not_found("Сейчас ничего не играет.")
end
if out == "EMPTY" or out == "|" then
return jarvis.cmd.not_found("Что-то играет, но без названия.")
end
local artist, title = out:match("^([^|]*)|(.*)$")
if not title or title == "" then
return jarvis.cmd.not_found("Трек без названия.")
end
if artist and artist ~= "" then
return jarvis.cmd.ok(string.format("Сейчас играет: %s — %s.", artist, title))
end
return jarvis.cmd.ok(string.format("Сейчас играет: %s.", title))