Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require "component"
- local event = require "event"
- local computer = require "computer"
- local shell = require "shell"
- local fs = require "filesystem"
- local modem = component.modem
- local filesPath = "/usr/mail/"
- local users = {}
- local tArgs = {...}
- local function extractStr(path)
- if path:find("!") ~= nil then
- return path:sub(1,path:find("!")-1), path:sub(path:find("!")+1,path:len())
- else return path,path
- end
- end
- local function mailEventListener(_,message)
- local frag1, ufrag = extractStr(message)
- print(message)
- print(frag1)
- print(ufrag)
- if message:sub(1,3) == "put" then --put!subject!content
- local subject, content = extractStr(ufrag)
- print(subject)
- print(content)
- local path = filesPath..subject
- print(path)
- if fs.exists(path) then
- local fObj = io.open(path,"a")
- fObj:write(content)
- fObj:close()
- else
- local f = io.open(path,"w")
- f:write(content)
- f:close()
- end
- end
- end
- mailEventListener(nil,"put!derp!derp")
- event.listen("relay_message",mailEventListener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement