--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 = 1
function Main()
mainlog = dofile("mainlog.dat") or {}
end
function NewUserConnected(user)
if dopm == 0 then return 1 end
--if user.bOperator or user.iProfile == 2 then -- This would allow VIP's, Ops & Masters
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
The use of 'please' is not forbidden in here.
--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]
-- Converted to LUA5 by bastya_elvtars
maxhistory = 125 -- maximum lines of chat to cache
botname = "[MainLog]"
dopm = 1
function Main()
mainlog = loadfile("mainlog.dat") or {}
end
function NewUserConnected(user)
if dopm ~= 0 then
--if user.bOperator or user.iProfile == 2 then -- This would allow VIP's, Ops & Masters
if user.iProfile == 0 then -- Report only to Master. Comment (--)this line if you use the one above
local n = table.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 ]------------------>")
end
end
end
OpConnected = NewUserConnected
function ChatArrival(user, data)
table.insert(mainlog, date("[%H:%M] ")..string.sub(data, 1, -2))
if table.getn(mainlog) > maxhistory then table.remove(mainlog, 1) end
savehistory()
end
function savehistory()
local f = io.open("mainlog.dat", "w+")
if f then
f:write("return {\n")
for _,line in ipairs(table.getn(mainlog)) do
f:write(f, "\t"..string.format("%q", line)..",\n")
end
f:write(f, "}") f:close()
end
end