Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Pastebin API
- -- Created by Sir_Mr_Bman
- -- Copyright (c) 2014
- -- Feel free to redistribute this program as part of your own programs (if you give me credit)
- -- Light-Docs:
- -- RETURN CODES (downloader):
- -- 11: HTTP API is not enabled
- -- 12: Savefile exists
- -- 13: Could not connect. Is pastebin down?
- -- 2: Download complete!
- function downloader(paste, savefile)
- if not http then
- return 11
- end
- if fs.exists(textutils.urlEncode(savefile)) then
- return 12
- end
- local pastebin = http.get("http://www.pastebin.com/raw.php?i="..textutils.urlEncode(paste))
- if pastebin then
- local saveTo = pastebin.readAll()
- pastebin.close()
- local file = fs.open(savefile, "w")
- file.write(saveTo)
- file.close()
- return 2
- else
- return 13
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment