From 2e797f5f75b3ef3487cf69b6b81c4e9a863792d4 Mon Sep 17 00:00:00 2001 From: erius0 <63460770+erius0@users.noreply.github.com> Date: Fri, 8 Jan 2021 04:24:12 +0300 Subject: [PATCH] Update linkedGet.lua --- linkedGet.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/linkedGet.lua b/linkedGet.lua index 760077c..efa3ec1 100644 --- a/linkedGet.lua +++ b/linkedGet.lua @@ -20,21 +20,31 @@ function os.dateRL(format) end function handleMessage(msg) - if message == "help" then + if msg == "help" then return success - elseif message == "rain" then + elseif msg == "rain" then return success else return fail end end +function getUser(from) + if from == "b7585fb7-1ae4-4f94-b1a2-05e1cef76a1f" then + return "erius" + elseif from == "0952a2dd-23fa-4dd2-aefe-92e7cd6c77ce" then + return "DummyWalrus" + else + return "???" + end +end + while true do local _, _, from, _, _, message = event.pull("modem_message") - local log = "["..os.dateRL("%x %X").."]".." "..from..": "..message.."/n"..handleMessage(message) + local log = "["..os.dateRL("%x %X").."]".." "..getUser(from)..": "..message.."\n"..handleMessage(message) print(log) local f = io.open("logs.txt", "a") - f:write(log.."/n") + f:write(log.."\n") f:close() tunnel.send("succes!") end