Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 1.) list trending pastebin topics
- 2.) double_click opens them up for reading
- 3.)*include back button
- function required ->
- -listHTML >/
- -function convertList(string) : return table
- -function scrollTrends() : #use scrollWheel or arrowKeys to scroll up/down
- -user interface
- ]]
- local tArgs = { ... }
- local favorites = {}
- fs.open("console",'w')
- function log(string)
- h = fs.open("console",'a')
- h.writeLine(string)
- h.close()
- end
- function getApi(key,file)
- local h = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(tostring(key)))
- local code = h.readAll()
- h.close()
- local new = fs.open(tostring(file),"w")
- new.write(code)
- new.close()
- end
- function updateTrending()
- local response = http.post(
- "http://pastebin.com/api/api_post.php",
- "api_option=trends&"..
- "api_dev_key=ddfc115bf6e1cd0262ed53ee041c124b"
- )
- local html = response.readAll()
- return html
- end
- function addToFavorites(title,code,favorites)
- favorites[#favorites + 1] = {title,code}
- end
- function reader(key)
- local file = "temp"
- local h = http.get("http://pastebin.com/raw.php?i="..textutils.urlEncode(tostring(key)))
- local code = h.readAll()
- h.close()
- local new = fs.open(tostring(file),"w")
- new.write(code)
- new.close()
- end
- if tArgs[1] == "connur" then
- getApi('PZ2MTPk6','c')
- elseif tArgs[1] ~= "stale" then
- getApi('52Se9ZrZ','c')
- end
- os.loadAPI(shell.resolveProgram("c"))
- local html = updateTrending()
- local trends = c.convertList(html)
- --trends[i] = {"paste title",2hey6dF4, 245, 868}
- while true do
- term.clear()
- local key = c.displayTrends(trends)
- if key then
- reader(key)
- if tArgs[1] == "monitor" then
- term.redirect(peripheral.find("monitor"))
- parallel.waitForAny(
- function() shell.run("edit temp") end,
- function() sleep(.5) end
- )
- term.redirect(term.native())
- else
- shell.run("edit temp")
- end
- else
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement