--//Mail Bot by Phatty v1 Mail = "Daemon" mcmd = "!" function NewUserConnected(user) Mailer(user) end function OpConnected(user) Mailer(user) end function Mailer(user) handle2=openfile("messages/"..user.sName..".msg","r") if (handle2==nil) then else line = read(handle2,"*a") line=strsub(line,1,strlen(line)-1) linearray=tokenize(line,"§") for i=1,linearray.n do user:SendPM(Bot,linearray[i]) end closefile(handle2) end a,b=remove("messages/"..user.sName..".msg") end function tokenize (inString,token) _WORDS = {} local matcher = "([^§"..token.."]+)" gsub(inString, matcher, function (w) tinsert(_WORDS,w) end) return _WORDS end function DataArrival(user,data) if strsub(data, 1, 1) == "<" then data=strsub(data,1,strlen(data)-1) local s,e,cmd = strfind(data,"%b<>%s+(%S+)") if cmd ==mcmd.."checkmail" then Mailer(user) elseif (cmd==mcmd.."mail") then s,e,cmd,arg,arg2 = strfind(data,"%s+(%S+)%s+(%S+)%s+(.*)") if arg == nil or arg2 == nil then user:SendData(Mail,"What you gonna send?") return 1 else local handle=openfile("messages/"..arg..".msg","a") write(handle,"("..user.sName..") :"..arg2.."§") user:SendPM(Mail,"Message sent") closefile(handle) mailing = GetItemByName(arg) if mailing == nil then else mailing:SendPM(Mail,"You have mail, use checkmail to read it") end end end end end