Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local key = settings.get "govos.key"
- if not key then error "GovOS RDS key not found." end
- local ws, err = http.websocket("wss://osmarks.tk/wsthing/GovOS/admin", {
- authorization = "Key " .. key
- })
- if err then
- error(err)
- else
- print "Connected"
- end
- local msg = ""
- local template = [[
- peripheral.find("monitor", function(_, o) o.setCursorPos(1, 1); o.setBackgroundColor(colors.green); o.clearLine(); o.setTextColor(colors.white); o.clearLine(); o.write(%q) end)
- ]]
- function broadcast()
- while true do
- local ok = pcall(ws.send, template:format(msg))
- if not ok then
- print "Disconnected"
- connect()
- sleep(0.5)
- broadcast()
- end
- sleep(1)
- end
- end
- function set_text()
- local hist = {}
- while true do
- write "|> "
- local input = read(nil, hist)
- table.insert(hist, input)
- msg = input
- end
- end
- parallel.waitForAll(set_text, broadcast)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement