From f11436da830937a579e5171a465f2cae39350278 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 30 Mar 2024 21:36:54 +0000 Subject: listener script --- listener.dat | 1 + listener.lua | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 listener.dat create mode 100644 listener.lua diff --git a/listener.dat b/listener.dat new file mode 100644 index 0000000..66f8dcd --- /dev/null +++ b/listener.dat @@ -0,0 +1 @@ +dep pm diff --git a/listener.lua b/listener.lua new file mode 100644 index 0000000..efb3eef --- /dev/null +++ b/listener.lua @@ -0,0 +1,19 @@ +local pm = require'pm' + +local ws = assert(http.websocket("wss://citrons.xyz/ws-echo/rebecca")) +function main() + while true do + local msg = ws.receive() + local parsed = assert(textutils.unserializeJSON(msg)) + if parsed.msg then + print("got msg",parsed.msg) + -- more sophisticated cmds later, maybe + local pkgname = parsed.msg + pm.dl(pkgname) + multishell.run(pkgname..'.lua') + end + end +end + +pcall(main) +print("all done") -- cgit v1.2.3