conversion
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

conversion

Started by kunal, 20 October, 2005, 16:54:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kunal

--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

bastya_elvtars

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
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk