Files
aiolauncher_scripts/samples/shttp-text.lua
2025-05-03 09:45:26 +08:00

27 lines
629 B
Lua

-- name = "Chuck Norris jokes (sync)"
-- description = "icndb.com"
-- data_source = "icndb.com"
-- type = "widget"
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
-- version = "1.0"
function on_alarm()
local response = shttp:get("http://api.icndb.com/jokes/random")
if response.error ~= nil then
ui:show_text(response.error)
return
end
if response.code >= 200 and response.code < 300 then
joke = ajson:read(response.body, "object object:value string:joke")
ui:show_text(joke)
end
end
function on_click()
if joke ~= nil then
system:to_clipboard(joke)
end
end