-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmail.lua
19 lines (16 loc) · 809 Bytes
/
gmail.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
local gmail = {}
function gmail.mailCount(username, password, url, cb)
hs.http.asyncGet(url, {Authorization = "Basic " .. hs.base64.encode(username .. ":" .. password)}, function(status, body, headers)
if status == 200 then
local mailCount = string.match(body, "<fullcount>([0-9]*)")
cb(tonumber(mailCount))
else
print("gmail call failed with status code: " .. status)
print("Please log an issue with the below information to https://github.com/andrewhampton/dotfiles")
print(hs.inspect.inspect(headers))
print(body)
cb(0)
end
end)
end
return gmail