J.A.R.V.I.S-rust/resources/commands/ics_event/create.lua

78 lines
2.5 KiB
Lua
Raw Permalink Normal View History

feat: Wave 1 — 10 new packs (75 → 85 rust packs) User picked from the fishki roadmap; this commit ships the 10 easy/medium ones in one batch. No Rust core changes — all pure Lua + jarvis.* APIs. Pack catalog magic_8ball - "ответь да или нет" / "магический шар" / "что скажешь" - 15 канонических ответов, random pick. Pure fun. github_issues (2 cmds) - "какие issues" / "открытые issues" — gh issue list по сохранённому репо - "мои issues" / "что мне назначено" — gh issue list --assignee @me weather_extended (2 cmds, Open-Meteo, no key) - "погода завтра" — temp min/max + conditions + rain note - "прогноз на неделю" — общий диапазон температур - Auto-detects location via ipinfo.io if not in memory; stores lat/lon/city. rss_reader (3 cmds) - "добавь rss <url>" — extracts URL, persists via memory под ключом "rss.<domain>" - "что в ленте" — fetches first feed, parses <title> tags, speaks top 3 - "какие у меня rss" — lists subscribed feed domains ics_event - "добавь встречу завтра в 15:00 обсудить проект" - Parses time (HH:MM или "в HH") + date keywords (сегодня/завтра/послезавтра) - Writes valid iCalendar v2.0 file to ~/Documents/jarvis-events/ - jarvis.system.open → дефолтный handler (Outlook/Mail/whatever) backup - "сделай бекап" — PowerShell Compress-Archive всех state files из APPDATA/Jarvis - Outputs to ~/Documents/jarvis-backup-<YYYYMMDD-HHMMSS>.zip - Bundles: long_term_memory, schedule, macros, profiles/, active_profile, llm_backend, settings clip_history (3 cmds, 20-slot rolling buffer) - "запиши буфер" — push current clipboard onto memory keys clip.0..clip.19 - "что я копировал" — speak preview of last 3 - "верни первый/второй/третий буфер" — restore clip.N to clipboard notif_queue (2 cmds) - "что я пропустил" — enumerate memory keys "notif.*", speak last 5 by recency - "очисти уведомления" — purge all notif.* keys - Producers (scheduler/macros/llm) can later push to memory[notif.<ts>] = text password_vault (3 cmds, Windows DPAPI) - "сохрани пароль от GitHub" — encrypts current clipboard content via DPAPI (CurrentUser scope), base64-stored in memory[vault.GitHub]. Clears clipboard. Password is NEVER spoken or written to disk in plaintext. - "пароль от GitHub" — decrypts via DPAPI, restores to clipboard for 30 sec, schedules auto-clear via jarvis.scheduler. Speaks only "Пароль от X в буфере." - "какие у меня пароли" — list of stored service names. habit_streaks (2 cmds, integrates with habit_nudge) - "сколько дней подряд" / "статистика привычек" — reads memory keys "habit_streak.<habit>.<YYYY-MM-DD>", computes consecutive-day streak per habit. - "я попил воды" / "отметь привычку" — marks today's check-in. Maps voice to habit: воды→water, размял/зарядк→stretch, глаз→eyes. Tests: 6 commands tests pass (auto-validate the 10 new packs).
2026-05-16 01:04:23 +03:00
-- "Добавь встречу завтра в 15:00 обсудить проект"
-- Heuristic parsing: extracts time + body, defaults to tomorrow.
local phrase = (jarvis.context.phrase or "")
local body = jarvis.text.strip_trigger(phrase:lower(), {
"добавь встречу",
"создай событие",
"создай встречу",
"запиши встречу",
"новая встреча",
"add meeting",
"create event",
})
body = body:gsub("^[%s,:%.]+", ""):gsub("%s+$", "")
if body == "" then
return jarvis.cmd.error("Опишите встречу.")
end
-- Find time HH:MM or "в HH"
local h, m = body:match("(%d%d?)[:%-%s](%d%d)")
if not h then
h = body:match("в%s+(%d%d?)")
m = "00"
end
local hh = tonumber(h) or 9
local mm = tonumber(m) or 0
-- Date: "сегодня" / "завтра" / default to tomorrow
local today = jarvis.context.time
local year, month, day = today.year, today.month, today.day
if body:find("сегодня") then
-- leave as-is
elseif body:find("послезавтра") then
day = day + 2
else
-- default tomorrow
day = day + 1
end
-- ICS uses UTC if Z suffix or local with TZID. We'll use local naive.
local dt_start = string.format("%04d%02d%02dT%02d%02d00", year, month, day, hh, mm)
local dt_end = string.format("%04d%02d%02dT%02d%02d00", year, month, day, hh + 1, mm)
local now_stamp = string.format("%04d%02d%02dT%02d%02d00",
today.year, today.month, today.day, today.hour, today.minute)
-- Clean summary (strip the time tokens)
local summary = body:gsub("%d%d?[:%-%s]%d%d", ""):gsub("в%s+%d%d?", "")
:gsub("сегодня", ""):gsub("послезавтра", ""):gsub("завтра", "")
:gsub("^[%s,]+", ""):gsub("%s+$", "")
if summary == "" then summary = "Встреча" end
local uid = string.format("jarvis-%s-%d", now_stamp, math.random(1000, 9999))
local ics = string.format(
[[BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//J.A.R.V.I.S.//EN
BEGIN:VEVENT
UID:%s
DTSTAMP:%s
DTSTART:%s
DTEND:%s
SUMMARY:%s
END:VEVENT
END:VCALENDAR]],
uid, now_stamp, dt_start, dt_end, summary
)
local userprofile = jarvis.system.env("USERPROFILE") or "C:\\Users\\Public"
local dir = userprofile .. "\\Documents\\jarvis-events"
jarvis.fs.mkdir(dir)
local path = dir .. "\\event-" .. now_stamp .. ".ics"
jarvis.fs.write(path, ics)
-- Open via default handler (Outlook / Mail).
jarvis.system.open(path)
return jarvis.cmd.ok(string.format("Встреча создана: %s в %02d:%02d.", summary, hh, mm))