local event = require("event") local keyboard = require("keyboard") local component = require("component") local fs = require("filesystem") local tunnel = component.tunnel local success = "console: команда выполнена успешно" local fail = "console: неизвестная команда - пиши help" function os.dateRL(format) if not fs.get("/").isReadOnly() then local time = io.open("/tmp/.time", "w") time:write() time:close() os.sleep(0.01) return os.date(format, fs.lastModified("/tmp/.time") / 1002.7) else return os.date(format) end end function handleMessage(msg) if msg == "help" then return success 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 answer = handleMessage(tostring(message) local log = "["..os.dateRL("%x %X").."] "..getUser(tostring(from))..": "..message.."\n".."["..os.dateRL("%x %X").."] "..answer) print(log) local f = io.open("logs.txt", "a") f:write(log.."\n") f:close() tunnel.send(answer) end