basic Lua 5.4 implementation with few example commands
This commit is contained in:
parent
11c2500d9c
commit
7440baa1b2
35 changed files with 2554 additions and 460 deletions
32
resources/commands/weather/set_city.lua
Normal file
32
resources/commands/weather/set_city.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
-- set city for weather command
|
||||
|
||||
local phrase = jarvis.context.phrase
|
||||
local lang = jarvis.context.language
|
||||
|
||||
-- try to extract city name from phrase
|
||||
-- this is a simple example - you might want better parsing
|
||||
local city = phrase:match("город%s+(.+)") or phrase:match("city%s+(.+)")
|
||||
|
||||
if city then
|
||||
city = city:gsub("^%s*(.-)%s*$", "%1") -- trim
|
||||
|
||||
-- save to state (shared with weather command)
|
||||
jarvis.state.set("city", city)
|
||||
|
||||
local msg = lang == "ru"
|
||||
and "Город установлен: " .. city
|
||||
or "City set to: " .. city
|
||||
|
||||
jarvis.log("info", msg)
|
||||
jarvis.system.notify("Jarvis", msg)
|
||||
jarvis.audio.play_ok()
|
||||
else
|
||||
local msg = lang == "ru"
|
||||
and "Не удалось определить город"
|
||||
or "Could not determine city"
|
||||
|
||||
jarvis.log("warn", msg)
|
||||
jarvis.audio.play_not_found()
|
||||
end
|
||||
|
||||
return { chain = false }
|
||||
Loading…
Add table
Add a link
Reference in a new issue