Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --default for the "oculus quest 2"-
- --------------CONFIG---------------
- local webURL = "https://www.oculus.com/quest-2/"
- local checker = "<type<:<button<,<product<:<quest-2-128<,<text<:<Notify Me<}},<children<:[{<type<:<OCPlutoButton<,<props<:{<data-testid<:<quest-2-128_notify-me<,<ariaLabel<" --< means "
- local checkDelay = 20
- local updateFile = 2
- -----------------------------------
- print("stock checker by 9551Dev\n")
- if ccemux then
- if not peripheral.wrap("top") then ccemux.attach("top", "speaker") end
- local s = peripheral.wrap("top")
- end
- local data, match, str, count = nil, nil, nil, 2
- if not fs.exists("./stock.history") then fs.open("./stock.history", "w").close() end
- local ends = function()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- end
- local updateWeb = function()
- print("updating web")
- web, err = http.get(webURL)
- end
- local updateData = function()
- print("updating data")
- data = web.readAll()
- end
- local updateStr = function()
- print("filtering STR")
- str = data:gsub('"', "<")
- end
- local updateMatch = function()
- print("matching")
- match = str:find(checker, 1, true)
- end
- local errs = function(...)
- web.close()
- print(...)
- end
- local avaible = function()
- local lives = true
- local stop = function()
- os.pullEvent("key")
- lives = false
- end
- local blink = function()
- while lives do
- term.setBackgroundColor(colors.red)
- term.clear()
- sleep(.2)
- term.setBackgroundColor(colors.green)
- term.clear()
- sleep(.2)
- end
- end
- local sound = function()
- if ccemux then
- while lives do
- s.playNote("bell", 3, 24)
- sleep(.05)
- end
- end
- end
- parallel.waitForAll(stop, sound, blink)
- end
- local updateTime = function()
- count = count + 1
- if count >= updateFile then
- print("updating stock.history file")
- local av = false
- if not match then av = true end
- local of = fs.open("./stock.history", "r")
- local od = of.readAll()
- of.close()
- local file = fs.open("./stock.history", "w")
- local strs = (od or "") .. "\n" .. os.date() .. " avaibility: " .. tostring(av)
- file.write(strs)
- file.close()
- count = 0
- end
- end
- local main = function()
- while true do
- updateWeb()
- if web then
- updateData()
- updateStr()
- updateMatch()
- updateTime()
- if not match then
- print("item detected !!")
- sleep(2)
- avaible()
- break
- end
- print("done. nothing found\nstarting over in " .. tostring(checkDelay) .. " seconds..\n")
- local posX, posY = term.getCursorPos()
- print(("\173"):rep(checkDelay))
- for i = 1, checkDelay do
- term.setCursorPos(1, posY)
- term.write(("\140"):rep(i))
- sleep(1)
- end
- print()
- else
- print("Web error... trying again")
- end
- end
- end
- local ok, err = pcall(main)
- if not ok then
- errs()
- ends()
- error(err, 0)
- end
- ends()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement