Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local net = require("internet")
- local gpu = component.gpu
- local term = require("term")
- local event = require("event")
- local computer = require("computer")
- local unicode = require("unicode")
- local interval = 60
- local id, shortik, resp
- gpu.setResolution(27, 10)
- gpu.setBackground(0xFFFFFF)
- gpu.setForeground(0x000000)
- gpu.fill(1, 1, 27, 10, " ")
- term.setCursorBlink(false)
- function onTimer()
- term.clear()
- resp = net.request("http://shortiki.com/export/api.php?format=json&type=random&amount=1")
- for line in resp do
- line = string.gsub(line, '\\"', unicode.char(0x0027))
- id = string.match(line, 'id": "([^"]+)"')
- shortik = string.match(line, 'content": "([^"]+)"')
- shortik = string.gsub(shortik, unicode.char(0x0027), '"')
- term.write("Цитата номер "..id.."\n")
- term.setCursor(1, 3)
- term.write(shortik.."\n\n", true)
- term.setCursor(1, 10)
- term.write("Источник: shortiki.com")
- end
- end
- onTimer()
- event.timer(interval, onTimer, math.huge)
- while true do
- os.sleep(0)
- computer.freeMemory()
- event.pull()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement