Merge branch 'master' of github.com:yagop/telegram-bot

This commit is contained in:
yago 2014-11-22 19:56:43 +01:00
commit a05d08b88b
2 changed files with 13 additions and 2 deletions

View File

@ -32,6 +32,11 @@
function ok_cb(extra, success, result) function ok_cb(extra, success, result)
end end
-- Callback to remove tmp files
function rmtmp_cb(file_path, success, result)
os.remove(file_path)
end
function msg_valid(msg) function msg_valid(msg)
if msg.text == nil then if msg.text == nil then
return false return false
@ -148,7 +153,7 @@
return result return result
end end
function download_to_file( url ) function download_to_file( url , noremove )
print("url to download: "..url) print("url to download: "..url)
req, c, h = http.request(url) req, c, h = http.request(url)
htype = h["content-type"] htype = h["content-type"]
@ -174,6 +179,11 @@
file = io.open(file_path, "w+") file = io.open(file_path, "w+")
file:write(req) file:write(req)
file:close() file:close()
if noremove == nil then
postpone(rmtmp_cb, file_path, config.rmtmp_delay)
end
return file_path return file_path
end end

View File

@ -1,4 +1,5 @@
{ {
"rmtmp_delay": 20,
"google_api_key": "", "google_api_key": "",
"log_file": "/var/www/html/log.txt", "log_file": "/var/www/html/log.txt",
"sh_enabled": false, "sh_enabled": false,