basic Lua 5.4 implementation with few example commands
This commit is contained in:
parent
c9b9482cc8
commit
c4a774b5cf
35 changed files with 2554 additions and 460 deletions
29
resources/commands/weather/script.lua
Normal file
29
resources/commands/weather/script.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- weather command using wttr.in API
|
||||
|
||||
local lang = jarvis.context.language
|
||||
|
||||
-- get saved city or use default
|
||||
local city = jarvis.state.get("city") or "Moscow"
|
||||
|
||||
jarvis.log("info", "Fetching weather for: " .. city)
|
||||
|
||||
-- build URL
|
||||
local url = "https://wttr.in/" .. city .. "?format=3&lang=" .. lang
|
||||
|
||||
-- make request
|
||||
local response = jarvis.http.get(url)
|
||||
|
||||
if response.ok then
|
||||
jarvis.log("info", "Weather: " .. response.body)
|
||||
|
||||
-- show notification
|
||||
local title = lang == "ru" and "Погода" or "Weather"
|
||||
jarvis.system.notify(title, response.body)
|
||||
|
||||
jarvis.audio.play_ok()
|
||||
else
|
||||
jarvis.log("error", "Failed to fetch weather: " .. (response.error or "unknown error"))
|
||||
jarvis.audio.play_error()
|
||||
end
|
||||
|
||||
return { chain = false }
|
||||
Loading…
Add table
Add a link
Reference in a new issue