--Chat History On Entry 1.02 --By Mutor The Ugly 4/14/04 -- --Based on a script by Tezlo 1/17/04 --Send chat history to PM on entry ----See 'Chat History - main.lua' for main chat version ----------------------------------------------------------- --Changes --Fix by Tezlo 4/16/04, Now excludes only chat messages that begin with command modifier ie. !,+,? -- maxhistory = 20 -- maximum lines of chat to cache botname = "[Historian]" function Main() chathistory = dofile("chathistory.dat") or {} frmHub:RegBot(botname) -- Comment this line to not have bot appear in user list. Note: If botname is not registered, default dc++ settings will not allow pm's to pop up -- Enable Pop up messages from offline users / Disable ingnore messages from offline in client 'advanced dc settings'. To allow pop from unregistered botname. end function NewUserConnected(user) local n = getn(chathistory) local str = "<----------------------------------------------------------------------[ Last ( "..n.." ) chat messages ]----------->\r\n" for i = 1, n do str = str.."\r\n"..chathistory[i] end user:SendPM(botname,str.."\r\n") user:SendPM(botname,"<--------------------------------------------------------------------------[ End of chat history ]--------------->") end OpConnected = NewUserConnected -- -- Change from v1.01 (Fix By Tezlo ...thx) -- Now excludes only chat messages begining with command modifier ie. !,+,? -- function DataArrival(user, data) if strsub(data, 1, 1) ~= "<" then return end local s, e, pre = strfind(data, "^%b<> (.)") if pre == "!" or pre == "+" or pre == "?" then return end -- disallow command input to cached chat tinsert(chathistory, date("[%H:%M] ")..strsub(data, 1, -2)) if getn(chathistory) > maxhistory then tremove(chathistory, 1) end savehistory() end -- -- End Change -- function savehistory() local f = openfile("chathistory.dat", "w+") assert(f, "chathistory.dat") write(f, "return {\n") for i = 1, getn(chathistory) do write(f, "\t"..format("%q", chathistory[i])..",\r\n") end write(f, "}") closefile(f) end