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
14
resources/commands/hello/command.toml
Normal file
14
resources/commands/hello/command.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[[commands]]
|
||||
id = "hello"
|
||||
type = "lua"
|
||||
script = "script.lua"
|
||||
sandbox = "minimal"
|
||||
timeout = 5000
|
||||
phrases.ru = [
|
||||
"привет",
|
||||
"здравствуй",
|
||||
]
|
||||
phrases.en = [
|
||||
"hello",
|
||||
"hi",
|
||||
]
|
||||
21
resources/commands/hello/script.lua
Normal file
21
resources/commands/hello/script.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- simple test hello command
|
||||
|
||||
local lang = jarvis.context.language
|
||||
local hour = tonumber(jarvis.context.time.hour)
|
||||
|
||||
-- determine greeting based on time
|
||||
local greeting
|
||||
if hour >= 5 and hour < 12 then
|
||||
greeting = lang == "ru" and "Доброе утро" or "Good morning"
|
||||
elseif hour >= 12 and hour < 17 then
|
||||
greeting = lang == "ru" and "Добрый день" or "Good afternoon"
|
||||
elseif hour >= 17 and hour < 22 then
|
||||
greeting = lang == "ru" and "Добрый вечер" or "Good evening"
|
||||
else
|
||||
greeting = lang == "ru" and "Доброй ночи" or "Good night"
|
||||
end
|
||||
|
||||
jarvis.log("info", "Greeting user: " .. greeting)
|
||||
jarvis.audio.play_reply()
|
||||
|
||||
return { chain = true }
|
||||
Loading…
Add table
Add a link
Reference in a new issue