38 lines
1.2 KiB
Lua
38 lines
1.2 KiB
Lua
|
|
-- Read out the first ~5 keys + value previews; the rest is just a count.
|
||
|
|
-- TTS doesn't handle long enumerations well, so we keep it short and notify
|
||
|
|
-- the full dump as a Windows toast for visual scan.
|
||
|
|
|
||
|
|
local lang = jarvis.context.language
|
||
|
|
local facts = jarvis.memory.all() or {}
|
||
|
|
|
||
|
|
if #facts == 0 then
|
||
|
|
return jarvis.cmd.not_found(lang == "ru"
|
||
|
|
and "Память пуста, сэр."
|
||
|
|
or "Memory is empty, sir.")
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Sort by most-recently-used so the user hears what's actually fresh.
|
||
|
|
table.sort(facts, function(a, b) return (a.last_used_at or 0) > (b.last_used_at or 0) end)
|
||
|
|
|
||
|
|
local speak_lines = {}
|
||
|
|
local notify_lines = {}
|
||
|
|
for i, f in ipairs(facts) do
|
||
|
|
local v = (f.value or ""):sub(1, 60)
|
||
|
|
local line = f.key .. ": " .. v
|
||
|
|
table.insert(notify_lines, line)
|
||
|
|
if i <= 5 then
|
||
|
|
table.insert(speak_lines, f.key .. " — " .. v)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
jarvis.system.notify(
|
||
|
|
lang == "ru" and ("Память (" .. tostring(#facts) .. ")") or ("Memory (" .. tostring(#facts) .. ")"),
|
||
|
|
table.concat(notify_lines, "\n")
|
||
|
|
)
|
||
|
|
|
||
|
|
local preview = table.concat(speak_lines, ", ")
|
||
|
|
local extra = #facts > 5
|
||
|
|
and string.format(lang == "ru" and ". И ещё %d." or ". And %d more.", #facts - 5)
|
||
|
|
or "."
|
||
|
|
return jarvis.cmd.ok(preview .. extra)
|