65 lines
2.2 KiB
Lua
65 lines
2.2 KiB
Lua
|
|
-- The actual briefing body. Called either directly ("утренний брифинг") OR
|
||
|
|
-- by the scheduler at the configured daily time.
|
||
|
|
local t = jarvis.context.time
|
||
|
|
local lang = jarvis.context.language or "ru"
|
||
|
|
|
||
|
|
-- 1) Greeting + time
|
||
|
|
local hour = t.hour
|
||
|
|
local greeting
|
||
|
|
if hour >= 5 and hour < 12 then greeting = "Доброе утро."
|
||
|
|
elseif hour >= 12 and hour < 18 then greeting = "Добрый день."
|
||
|
|
elseif hour >= 18 and hour < 23 then greeting = "Добрый вечер."
|
||
|
|
else greeting = "Сэр." end
|
||
|
|
|
||
|
|
jarvis.speak(greeting .. string.format(" Сейчас %d:%02d.", hour, t.minute))
|
||
|
|
jarvis.sleep(300)
|
||
|
|
|
||
|
|
-- 2) Profile-aware tone
|
||
|
|
local prof = jarvis.profile.active()
|
||
|
|
if prof and prof.name and prof.name ~= "default" then
|
||
|
|
jarvis.speak("Активный режим: " .. prof.name .. ".")
|
||
|
|
jarvis.sleep(200)
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 3) Scheduled tasks ahead today
|
||
|
|
local tasks = jarvis.scheduler.list()
|
||
|
|
if tasks and #tasks > 0 then
|
||
|
|
local count = 0
|
||
|
|
for _, task in ipairs(tasks) do
|
||
|
|
if task.action and task.action.type == "speak" then
|
||
|
|
count = count + 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
if count > 0 then
|
||
|
|
jarvis.speak(string.format("Запланировано задач: %d.", count))
|
||
|
|
jarvis.sleep(200)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 4) Memory recap (most recently used 3)
|
||
|
|
local memos = jarvis.memory.all()
|
||
|
|
if memos and #memos > 0 then
|
||
|
|
local sample = math.min(2, #memos)
|
||
|
|
local line = "Из памяти: "
|
||
|
|
for i = 1, sample do
|
||
|
|
line = line .. memos[i].key .. " — " .. memos[i].value
|
||
|
|
if i < sample then line = line .. "; " end
|
||
|
|
end
|
||
|
|
line = line .. "."
|
||
|
|
jarvis.speak(line)
|
||
|
|
jarvis.sleep(200)
|
||
|
|
end
|
||
|
|
|
||
|
|
-- 5) Closing nudge from LLM if available
|
||
|
|
local nudge = jarvis.llm({
|
||
|
|
{ role = "system", content = "Ты — Джарвис. Одна короткая фраза-мотиватор на день. По-русски. 5-10 слов." },
|
||
|
|
{ role = "user", content = string.format("Сейчас %d часов %02d минут, режим: %s.", hour, t.minute, prof and prof.name or "default") }
|
||
|
|
}, { max_tokens = 60, temperature = 0.8 })
|
||
|
|
|
||
|
|
if nudge and nudge ~= "" then
|
||
|
|
jarvis.speak(nudge)
|
||
|
|
end
|
||
|
|
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
return { chain = false }
|