Initial test of plugins handler

This commit is contained in:
yago
2014-12-24 01:38:41 +01:00
parent 8ca367e83b
commit d0a728e214
5 changed files with 97 additions and 27 deletions

View File

@ -67,6 +67,11 @@ function download_to_file( url , noremove )
return file_path
end
-- Callback to remove a file
function rmtmp_cb(file_path, success, result)
os.remove(file_path)
end
function vardump(value, depth, key)
local linePrefix = ""
local spaces = ""
@ -133,10 +138,34 @@ function is_sudo(msg)
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end