25 lines
790 B
Lua
25 lines
790 B
Lua
|
|
-- Take whatever's in the clipboard and push into history (memory keys clip.0..clip.19, rotated).
|
||
|
|
local content = jarvis.system.clipboard.get()
|
||
|
|
if not content or content == "" then
|
||
|
|
return jarvis.cmd.not_found("Буфер пуст.")
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Shift existing entries: clip.18 → clip.19, clip.17 → clip.18, etc.
|
||
|
|
for i = 19, 1, -1 do
|
||
|
|
local prev = jarvis.memory.recall("clip." .. (i - 1))
|
||
|
|
if prev then
|
||
|
|
jarvis.memory.remember("clip." .. i, prev)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Truncate if huge
|
||
|
|
local trimmed = content
|
||
|
|
if #trimmed > 2000 then
|
||
|
|
trimmed = trimmed:sub(1, 2000) .. "..."
|
||
|
|
end
|
||
|
|
jarvis.memory.remember("clip.0", trimmed)
|
||
|
|
|
||
|
|
-- Speak first 40 chars as confirmation
|
||
|
|
local preview = trimmed:sub(1, 40):gsub("\r?\n", " ")
|
||
|
|
return jarvis.cmd.ok("Запомнил: " .. preview .. ".")
|