aboutsummaryrefslogtreecommitdiff
path: root/contrib/pop.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-08-29 01:32:24 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-08-29 01:32:24 +0200
commit88c3d0c11ef6e68e8a11a394b338fe84682b22ae (patch)
tree7f1d09cf02483492602fbeaf6cb3c59ab9d2476a /contrib/pop.lua
parentb200a8073d6c74094784cfea8cf6ab2b0ab73407 (diff)
downloadvicious-legacy-88c3d0c11ef6e68e8a11a394b338fe84682b22ae.tar.xz
contrib: use pcall for luasocket in pop
Diffstat (limited to 'contrib/pop.lua')
-rw-r--r--contrib/pop.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/contrib/pop.lua b/contrib/pop.lua
index 7b87eab..78e0bcb 100644
--- a/contrib/pop.lua
+++ b/contrib/pop.lua
@@ -10,9 +10,11 @@
---------------------------------------------------
-- {{{ Grab environment
-local setmetatable = setmetatable
-local socket = require("socket")
local tonumber = tonumber
+local setmetatable = setmetatable
+local sock_avail, socket = pcall(function()
+ return require("socket")
+end)
-- }}}
@@ -22,7 +24,7 @@ module("vicious.contrib.pop")
-- {{{ POP3 count widget type
local function worker(format, warg)
- if not warg or #warg ~= 4 then
+ if not sock_avail or (not warg or #warg ~= 4) then
return {"N/A"}
end