Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make compatible with newer luasec/luasocket and incorporate #1 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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