25 lines
962 B
Lua
25 lines
962 B
Lua
|
|
-- Mark a habit done today.
|
||
|
|
local phrase = (jarvis.context.phrase or ""):lower()
|
||
|
|
|
||
|
|
local habit = nil
|
||
|
|
if phrase:find("воды") or phrase:find("воду") then habit = "water"
|
||
|
|
elseif phrase:find("размял") or phrase:find("зарядк") then habit = "stretch"
|
||
|
|
elseif phrase:find("глаз") then habit = "eyes"
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Fallback: pick first word after "выполнил"/"отметь"
|
||
|
|
if not habit then
|
||
|
|
habit = jarvis.text.strip_trigger(phrase, {
|
||
|
|
"отметь привычку", "выполнил привычку", "выполнил", "отметь",
|
||
|
|
"check in habit",
|
||
|
|
}):gsub("^[%s,:%.]+", ""):gsub("%s+$", "")
|
||
|
|
if habit == "" then habit = "general" end
|
||
|
|
end
|
||
|
|
|
||
|
|
local t = jarvis.context.time
|
||
|
|
local date_str = string.format("%04d-%02d-%02d", t.year, t.month, t.day)
|
||
|
|
local key = "habit_streak." .. habit .. "." .. date_str
|
||
|
|
|
||
|
|
jarvis.memory.remember(key, "1")
|
||
|
|
return jarvis.cmd.ok("Отметил " .. habit .. " за сегодня.")
|