1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-09-16 17:09:36 +00:00
This commit is contained in:
osmarks 2024-06-21 12:38:58 +01:00
commit 1e062135b3

View File

@ -1,5 +1,5 @@
local function update() local function update()
local h = http.get "https://pastebin.com/raw/L0ZKLBRG" local h = http.get "https://raw.githubusercontent.com/osmarks/misc/master/computercraft/lms.lua"
local f = fs.open(shell.getRunningProgram(), "w") local f = fs.open(shell.getRunningProgram(), "w")
f.write(h.readAll()) f.write(h.readAll())
f.close() f.close()
@ -109,7 +109,7 @@ local function send()
if preproc(msg) == "" then if preproc(msg) == "" then
print_message "Your message is considered spam." print_message "Your message is considered spam."
else else
add_message(msg, username) add_message(msg, username:sub(1, 16))
m.transmit(chan, chan, { message = msg, username = username }) m.transmit(chan, chan, { message = msg, username = username })
end end
end end
@ -119,7 +119,7 @@ end
local function recv() local function recv()
while true do while true do
local _, _, channel, _, message = os.pullEvent "modem_message" local _, _, channel, _, message = os.pullEvent "modem_message"
if channel == chan and type(message) == "table" and message.message and message.username then if channel == chan and type(message) == "table" and message.message and message.username and type(message.message) == "string" and type(message.username) == "string" then
notification_sound() notification_sound()
add_message(message.message, message.username) add_message(message.message, message.username)
end end
@ -127,4 +127,4 @@ local function recv()
end end
m.transmit(chan, chan, { username = username, message = "Connected." }) m.transmit(chan, chan, { username = username, message = "Connected." })
parallel.waitForAny(send, recv) parallel.waitForAny(send, recv)