Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if #arg < 2 then
- print("ERROR: Debilu, trzeba 2 argumenty: gist name i file name")
- return
- end
- local gist_name, file_name = ...
- local answer, error = http.get("https://api.github.com/users/ENCIOK/gists")
- local gists_list_text = answer.readAll()
- local gists_table = textutils.unserialiseJSON(gists_list_text)
- answer.close()
- local url
- for i, table in ipairs(gists_table) do
- if table.files[gist_name] then
- url = table.files[gist_name].raw_url
- break
- end
- end
- if url == nil then
- print("ERROR: Nie ma tekiego gistu, ciołku -_-")
- return
- end
- answer, error = http.get(url)
- local code = answer.readAll()
- fs.delete(file_name)
- local file = fs.open(file_name, "w")
- file.write(code)
- file.close()
- answer.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement