38 lines
1.4 KiB
Lua
38 lines
1.4 KiB
Lua
|
|
local lang = jarvis.context.language
|
||
|
|
local cmd_id = jarvis.context.command_id
|
||
|
|
|
||
|
|
local offsets = { today = 0, tomorrow = 1, yesterday = -1 }
|
||
|
|
local offset = offsets[cmd_id] or 0
|
||
|
|
|
||
|
|
local ps = string.format(
|
||
|
|
[[$ru = [System.Globalization.CultureInfo]::GetCultureInfo('ru-RU'); $d = (Get-Date).AddDays(%d); $d.ToString('dddd, dd MMMM yyyy', $ru)]],
|
||
|
|
offset
|
||
|
|
)
|
||
|
|
local res = jarvis.system.exec(string.format('powershell -NoProfile -Command "%s"', ps:gsub('"', '\\"')))
|
||
|
|
local text = (res.stdout or ""):gsub("[\r\n]+$", "")
|
||
|
|
|
||
|
|
if text == "" then
|
||
|
|
jarvis.audio.play_error()
|
||
|
|
return { chain = false }
|
||
|
|
end
|
||
|
|
|
||
|
|
local labels = {
|
||
|
|
today = lang == "ru" and "Сегодня" or "Today",
|
||
|
|
tomorrow = lang == "ru" and "Завтра" or "Tomorrow",
|
||
|
|
yesterday = lang == "ru" and "Вчера" or "Yesterday",
|
||
|
|
}
|
||
|
|
local prefix = labels[cmd_id] or ""
|
||
|
|
|
||
|
|
jarvis.system.notify(prefix, text)
|
||
|
|
|
||
|
|
local say = prefix .. ", " .. text
|
||
|
|
local sapi = say:gsub("'", "''")
|
||
|
|
local sps = string.format(
|
||
|
|
[[Add-Type -AssemblyName System.Speech; $s = New-Object System.Speech.Synthesis.SpeechSynthesizer; foreach ($v in $s.GetInstalledVoices()) { if ($v.VoiceInfo.Culture.TwoLetterISOLanguageName -eq 'ru') { try { $s.SelectVoice($v.VoiceInfo.Name); break } catch {} } } $s.Speak('%s')]],
|
||
|
|
sapi
|
||
|
|
)
|
||
|
|
jarvis.system.exec(string.format('powershell -NoProfile -Command "%s"', sps:gsub('"', '\\"')))
|
||
|
|
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
return { chain = false }
|