23 lines
584 B
Lua
23 lines
584 B
Lua
local function download_file(url)
|
|
local result, response = pcall(internet.request, url)
|
|
--print(response)
|
|
local res = ""
|
|
if result then
|
|
local result, reason = pcall(function()
|
|
for chunk in response do
|
|
res = res .. chunk
|
|
end
|
|
end)
|
|
if not result then
|
|
return nil, reason -- for programs using wget as a function
|
|
end
|
|
else
|
|
return nil, response -- for programs using wget as a function
|
|
end
|
|
return res
|
|
end
|
|
|
|
local function github_download(repo, file)
|
|
local url = string.format("https://raw.githubusercontent.com/%s/%s", repo, file)
|
|
return download_file(url)
|
|
end |