Skip to content

Commit

Permalink
make compatible with newer luasec/luasocket and incorporate andsve#1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmens committed Apr 2, 2019
1 parent 61f1ccf commit 1bd165e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pushover.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Dependencies: LuaSocket and luasec ( https://github.com/brunoos/luasec/ )
require("https")

ssl = require "ssl.https"

-- Usage: successbool, errstring = pushover( { a table with keys and values corresponding to pushover API } )
function pushover( request )
Expand All @@ -13,13 +14,13 @@ function pushover( request )
data_str = table.concat(data_str, "&")

-- send request
local res, code, headers, status = ssl.https.request(pushover_url, data_str)
local res, code, headers, status = ssl.request(pushover_url, data_str)

-- check for errors
if (code ~= 200) then
local errstr = "Error while sending request. Status code: " .. tostring(code) .. ", Body: " .. tostring(res)
return false, errstr
elseif (res ~= '{"status":1}') then
elseif not string.match(res,'"status":1') then
local errstr = "Error from pushover: " .. tostring(res)
return false, errstr
end
Expand Down

0 comments on commit 1bd165e

Please sign in to comment.