--[[endator 2007-04-13 logs chat to file, it keeps all lines in a table and saves it to file on each interval of "autosaveinterval" check out the comments below to configure it to your liking --]] --The file to save the log to chatlog = "/home/mainchat.log" --Set this to "yes" if you want to filter out commands from entering the log, else set it to "no" filter="yes" lf = "\n" count=1 chatlogtable = {} function EventChat(nick,msg) local st=string.len(nick)+4 local test = string.sub(msg,st,st) if (filter=="yes" and (test=="!" or test=="+")) then return end local date = os.date ("*t") chatlogtable[count]=("["..date.year.."-"..formatTF(date.month).."-"..formatTF(date.day).." "..formatTF(date.hour)..":"..formatTF(date.min)..":"..formatTF(date.sec).."] "..msg..lf) count=count+1 return 1 end function formatTF(field) if (tonumber(field)<10 and string.len(field)==1) then field = "0"..field end return field end function EventSave() -- purpose of this function is to save the log to file every now and then local date = os.date ("*t") chatlogfile = io.open(chatlog, "a+") for i in ipairs(chatlogtable) do chatlogfile:write(chatlogtable[i]) end io.flush(chatlogfile) io.close(chatlogfile) count=1 chatlogtable = {} end