--// vim:ts=4:sw=4:noet --// history.lua -- Made for BCDC++, tested with 0.401b current svn (svn402) --// history.lua -- This script stores the last x lines of the main chat and send it in PM if -history command is sent into the chat --// history.lua -- Rev 4: Jun 4, 2004 --// history.lua -- FleetCommand, molnihun@netscape.net ----------------------------------- -- Settings / Beállítások: ----------------------------------- -- historymaxlines változó adja meg, hogy hány sort tároljon a script (hubonként) -- the historymaxlines variable sets how many messages to store (per hub) historymaxlines = 100 -- historydefault adja meg, hogy hány sort küldjön el priviben, ha nincs megadva paraméter -- historydefault sets how many lines should be sent in PM if no parameter is given historydefault = 50 --// Do not edit below this line //-- dcpp:setListener("connected", "historyconn", function (hub) if not hub.history then hub.history = {} hub.history.chat = {} hub.history.started = os.date("%Y. %m. %d - %H:%M:%S") end end ) dcpp:setListener( "chat", "history", function( hub, user, text ) local s = string.lower( text ) local allofthem = "" if string.sub(s, 1,8) == "-history" then local parameter = tonumber ( string.sub ( text, 10, string.len(text) ) ) if (not parameter) then parameter = historydefault elseif (parameter < 1) or (parameter > historymaxlines) then allofthem = allofthem .. "\r\nWrong parameter (should be between 1 and ".. historymaxlines .."), using " .. historydefault .. " as default.\r\n" parameter = historydefault end local histnum = historymaxlines - parameter +1 allofthem = allofthem .. "\r\nHistory of the latest ".. parameter .. " messages:" while (histnum <= historymaxlines) do if (hub.history.chat[histnum] ~= nil) then allofthem = allofthem .. "\r\n" .. hub.history.chat[histnum] end histnum = histnum +1 end user:sendPrivMsgFmt( allofthem, true) elseif string.find(text, "is kicking .+ because:") then -- don't save kick-messages elseif ( string.sub(s, 1,8) == "-scripts" ) and ( user:isOp() ) then hub:sendChat("history.lua: Running on this hub since: " .. hub.history.started) else local message = "" local histnum = 1 while (histnum < historymaxlines) do hub.history.chat[histnum] = hub.history.chat[histnum+1] histnum = histnum + 1 end message = message .. "["..os.date("%H:%M:%S") .."] <".. user:getNick() .. "> " .. text hub.history.chat[historymaxlines] = message end end ) DC():PrintDebug( " ** Loaded history.lua **" )