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:
parent
4efe306b3a
commit
4d3d664abd
6 changed files with 233 additions and 0 deletions
18
resources/commands/world_clock/command.toml
Normal file
18
resources/commands/world_clock/command.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# World clock — query time in another city/timezone.
|
||||
|
||||
[[commands]]
|
||||
id = "world_clock"
|
||||
type = "lua"
|
||||
script = "time_in.lua"
|
||||
sandbox = "full"
|
||||
timeout = 10000
|
||||
|
||||
[commands.phrases]
|
||||
ru = [
|
||||
"сколько времени в",
|
||||
"который час в",
|
||||
"сколько часов в",
|
||||
"время в",
|
||||
]
|
||||
en = ["time in", "what time in"]
|
||||
ua = ["котра година у", "скільки часу в"]
|
||||
95
resources/commands/world_clock/time_in.lua
Normal file
95
resources/commands/world_clock/time_in.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
-- "Сколько времени в Токио" — uses worldtimeapi.org public API.
|
||||
local phrase = (jarvis.context.phrase or "")
|
||||
local city = jarvis.text.strip_trigger(phrase:lower(), {
|
||||
"сколько времени в",
|
||||
"который час в",
|
||||
"сколько часов в",
|
||||
"время в",
|
||||
"time in",
|
||||
"what time in",
|
||||
"котра година у",
|
||||
"скільки часу в",
|
||||
})
|
||||
city = city:gsub("^[%s,:%.]+", ""):gsub("%s+$", "")
|
||||
|
||||
if city == "" then
|
||||
return jarvis.cmd.error("В каком городе?")
|
||||
end
|
||||
|
||||
-- Map common Russian city names → timezone slugs.
|
||||
local TZ_MAP = {
|
||||
-- Russia
|
||||
["москва"] = "Europe/Moscow",
|
||||
["спб"] = "Europe/Moscow",
|
||||
["петербург"] = "Europe/Moscow",
|
||||
["санкт-петербург"] = "Europe/Moscow",
|
||||
["новосибирск"] = "Asia/Novosibirsk",
|
||||
["екатеринбург"] = "Asia/Yekaterinburg",
|
||||
["казань"] = "Europe/Moscow",
|
||||
["владивосток"] = "Asia/Vladivostok",
|
||||
["хабаровск"] = "Asia/Vladivostok",
|
||||
["омск"] = "Asia/Omsk",
|
||||
["красноярск"] = "Asia/Krasnoyarsk",
|
||||
-- World
|
||||
["лондон"] = "Europe/London",
|
||||
["нью-йорк"] = "America/New_York",
|
||||
["нью йорк"] = "America/New_York",
|
||||
["сан-франциско"] = "America/Los_Angeles",
|
||||
["сан франциско"] = "America/Los_Angeles",
|
||||
["лос-анджелес"] = "America/Los_Angeles",
|
||||
["лос анджелес"] = "America/Los_Angeles",
|
||||
["токио"] = "Asia/Tokyo",
|
||||
["пекин"] = "Asia/Shanghai",
|
||||
["шанхай"] = "Asia/Shanghai",
|
||||
["гонконг"] = "Asia/Hong_Kong",
|
||||
["сингапур"] = "Asia/Singapore",
|
||||
["сидней"] = "Australia/Sydney",
|
||||
["дубай"] = "Asia/Dubai",
|
||||
["париж"] = "Europe/Paris",
|
||||
["берлин"] = "Europe/Berlin",
|
||||
["мадрид"] = "Europe/Madrid",
|
||||
["рим"] = "Europe/Rome",
|
||||
["амстердам"] = "Europe/Amsterdam",
|
||||
["варшава"] = "Europe/Warsaw",
|
||||
["прага"] = "Europe/Prague",
|
||||
["стамбул"] = "Europe/Istanbul",
|
||||
["киев"] = "Europe/Kyiv",
|
||||
["минск"] = "Europe/Minsk",
|
||||
["ереван"] = "Asia/Yerevan",
|
||||
["тбилиси"] = "Asia/Tbilisi",
|
||||
["алматы"] = "Asia/Almaty",
|
||||
["астана"] = "Asia/Almaty",
|
||||
["баку"] = "Asia/Baku",
|
||||
["ташкент"] = "Asia/Tashkent",
|
||||
["сеул"] = "Asia/Seoul",
|
||||
["мехико"] = "America/Mexico_City",
|
||||
["рио"] = "America/Sao_Paulo",
|
||||
["буэнос-айрес"] = "America/Argentina/Buenos_Aires",
|
||||
}
|
||||
|
||||
local tz = nil
|
||||
for stem, zone in pairs(TZ_MAP) do
|
||||
if city:find(stem, 1, true) then
|
||||
tz = zone
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not tz then
|
||||
return jarvis.cmd.not_found("Не знаю такого города. Попробуйте Москва, Токио, Лондон.")
|
||||
end
|
||||
|
||||
-- worldtimeapi.org has rate limits but is free with no key.
|
||||
local url = "https://worldtimeapi.org/api/timezone/" .. tz
|
||||
local data = jarvis.http.json(url)
|
||||
if not data or not data.datetime then
|
||||
return jarvis.cmd.error("Не получилось узнать время.")
|
||||
end
|
||||
|
||||
-- datetime is ISO 8601: "2026-05-15T14:32:11.123456+09:00"
|
||||
local hh, mm = data.datetime:match("T(%d%d):(%d%d)")
|
||||
if not hh then
|
||||
return jarvis.cmd.error("Не понял ответ сервиса.")
|
||||
end
|
||||
|
||||
return jarvis.cmd.ok(string.format("В %s сейчас %s:%s.", city, hh, mm))
|
||||
Loading…
Add table
Add a link
Reference in a new issue