Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function get(url, noCancel)
- http.request(url)
- while true do
- local e, rUrl, rmsg = os.pullEvent()
- if (e == "http_success") and (rUrl == url) then
- if rmsg then
- local data = rmsg.readAll()
- rmsg.close()
- if (data ~= "") and data then
- return "success", data
- else
- http.request(url)
- end
- else
- http.request(url)
- end
- elseif (e == "http_failure") and (rUrl == url) then
- return "failure"
- elseif (e == "chat_command") and ((trimText(rUrl:lower()) == "cancel") or (trimText(rUrl:lower()) == "home")) and not(noCancel) then
- return "cancel"
- end
- end
- end
- local tArgs = {...}
- if not tArgs[1] then
- print("Snipt hash ID required!")
- elseif not tArgs[2] then
- print("Snipt save location required!")
- else
- print("Retrieving Snipt...")
- local resp, data = get("https://snipt.net/raw/"..tArgs[1].."/", true)
- if resp ~= "success" then
- print("Failed!")
- else
- local f=io.open(tArgs[2],"w")
- f:write(data)
- f:close()
- print("Snipt saved!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement