--Main Chat Logger 1.01 --By Mutor The Ugly 4/14/04 --Based on a script by Tezlo 1/17/04 --Logs all input to main chat, commands & chat. --Reports in PM on entry to Master [and/or profiles of your choosing] maxhistory = 125 -- maximum lines of chat to cache botname = "[MainLog]" dopm = 0 function Main() mainlog = dofile("mainlog.dat") or {} end function NewUserConnected(user) --if user.bOperator or user.iProfile == 2 then -- This would allow VIP's, Ops & Masters if dopm == 0 then return 1 end if user.iProfile == 0 then -- Report only to Master. Comment (--)this line if you use the one above local n = getn(mainlog) local str = "<----------------------------------------------------------------------[ Last ( "..n.." ) lines sent to main ]----------->\r\n" for i = 1, n do str = str.."\r\n"..mainlog[i] end user:SendPM(botname,str.."\r\n") user:SendPM(botname,"<------------------------------------------------------------------------[ End of main chat log ]------------------>") else return 1 end end OpConnected = NewUserConnected function DataArrival(user, data) if strsub(data, 1, 1) ~= "<" then return end tinsert(mainlog, date("[%H:%M] ")..strsub(data, 1, -2)) if getn(mainlog) > maxhistory then tremove(mainlog, 1) end savehistory() end function savehistory() local f = openfile("mainlog.dat", "w+") assert(f, "mainlog.dat") write(f, "return {\n") for i = 1, getn(mainlog) do write(f, "\t"..format("%q", mainlog[i])..",\n") end write(f, "}") closefile(f) end