Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(8)
- function Listen()
- while true do
- local event, a, b, c, d, e, f, g = os.pullEvent()
- local Res
- local MSG
- if event == "rednet_message" then
- Res = CheckProtocols(a)
- elseif event == "modem_message" then
- MSG = CheckAuthority(2)
- end
- if Res ~= nil then ShareMessage(Res,b) elseif MSG ~= nil then SysMSG(d) else os.queueEvent("pass") end
- end
- end
- function ShareMessages(Program,message)
- shell.run(Program,"message",message)
- end
- function SysMSG(message)
- if string.find(message,"Alert.") then
- os.queueEvent("system_notification","network message",string.sub(message,7,string.len(message)))
- else
- shell.run(string.sub(message,1,string.find("_")-1),"direct_message",string.sub(message,string.find(message,"_")+1,string.len(message)))
- end
- end
- function CheckProtocols(protocol)
- local Pro
- local Content
- local file = fs.open("os/Files/ProgramNetworkProtocols.txt","r")
- repeat
- Content = file.readLine()
- if Content ~= nil and string.find(Content,protocol) then Pro = string.sub(Content,1,string.find(Content,"=") - 1) end
- until Content == nil
- file.close()
- if Pro ~= nil then return Pro else return false end
- end
- function CheckAuthority(channel)
- if channel == 8 then
- return true
- end
- end
- Listen()
Add Comment
Please, Sign In to add comment