kpcyrd/notify-signal
function run(arg)
local secret = getopt('secret')
if not secret then return '-o secret= missing' end
local to = getopt('to')
if not secret then return '-o to= missing' end
local url = getopt('url')
if not url then
url = 'http://127.0.0.1:4321/api/v0/send'
end
local text = arg['subject']
if arg['body'] then
text = '**' .. text .. '**\n\n' .. arg['body']
end
local session = http_mksession()
local headers = {}
headers['x-signal-auth'] = secret
local req = http_request(session, 'POST', url, {
headers=headers,
json={
to=to,
body=text,
},
})
local r = http_fetch(req)
debug(r)
end