need a little coding assistance with sending image with pushover message from lua and curl
Posted: Thursday 23 August 2018 21:26
Can someone help me out getting curl correctly into my lua script?
I send a pushover message with lua function below:
I would like to have a photo as attachment to the pushover message, which is possible according to the pushover help
the code provided as an example for that is:
how do I integrate the attachment piece of code : -F "attachment=@/path/to/your/image.jpg" \
into my function?
I send a pushover message with lua function below:
Code: Select all
function My.NotifyMe(iMode, sTitle, sBody, sSound, sDevice)
-- iPriority = -2,-1,0,1,2
-- sTitle = title of message
-- sBody = message
-- sSound = sound, empty is default sound
-- sDevice = your device name, empty is all devices
-- Check for optional sound and device parameter
if sSound == nil then sSound = '' end
if sDevice == nil then sDevice = '' end
local iPriority
local sUserKey
local sToken ='aaaaaaa'
--choose which receipient group and priority
if iMode == 'Plant' then
iPriority = '0'
sUserKey = 'xxxxxxx'
elseif iMode == 'Alarm' then
iPriority = '2'
sUserKey = 'yyyyyy'
else
iPriority = '0'
sUserKey = 'zzzzzz'
end
-- Replace any percent signs with their ascii values, as they are special characters
sTitle = string.gsub(sTitle, '%%', '%%25')
sBody = string.gsub(sBody, '%%', '%%25')
local sMsg = 'curl --data "token=' .. sToken .. '&user=' .. sUserKey .. '&title=' ..
sTitle .. '&message=' .. sBody .. '&priority=' .. tostring(iPriority) .. '&sound=' ..
sSound .. '&device=' .. sDevice .. '" https://api.pushover.net/1/messages.json'
os.execute(sMsg)
end
the code provided as an example for that is:
Code: Select all
curl -s \
--form-string "token=APP_TOKEN" \
--form-string "user=USER_KEY" \
--form-string "message=here is an image attachment" \
-F "attachment=@/path/to/your/image.jpg" \
https://api.pushover.net/1/messages.json
into my function?