require "socket"
-- config begin
logmc = 1 -- log main chat, 1 = yes, 0 = no
mclogfile = "/mc.txt" -- direction to text file name for main chat log
maxsize = 51234
function replacechars (text)
text = string.gsub (text, "<", "<")
text = string.gsub (text, ">", ">")
text = string.gsub (text, string.char (10), string.char (10).."<br />- ")
return text
end
function writemclog (logstring)
logfile = assert (io.open (mclogfile, "a"))
if logfile then
logsize = logfile:seek ("end")
logstring = replacechars (logstring).."\r\n<br />"
if logsize >= maxsize then
logfile:close ()
os.rename (mclogfile, mclogfile.."."..os.date ("%Y.%m.%d.%H.%M.%S"))
logfile = assert (io.open (mclogfile, "a"))
logfile:write (logstring)
logfile:close ()
else
logfile:write (logstring)
logfile:close ()
end
end
end
function ChatArrival (user,data)
writemclog ("["..socket.gettime().."] <"..user.."> "..data)
end
It just logs the main chat to a file called mc.txt
Any pointers would be greatly appreciated :)