seen bot
 

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

seen bot

Started by damo, 20 May, 2005, 00:26:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

damo

can anyone help me finish converting this seen bot please.
can it be changed to send answers in pm please. heres the script

BotName = "LeonBot"

SeenTrigger = "!seen"



minLen = 2

maxLen = 20

seenArray={}



function Main()

frmHub:RegBot(BotName)

end



function NewUserConnected(curUser)

local boolDisc = 0

if string.len(curUser.sName) < minLen then

curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif string.len(curUser.sName) > maxLen then

curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif ( string.find (curUser.sName, " ", 1, 1) ) then

curUser:SendPM(BotName, "Spaces not allowed in nicknames!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

end

if (boolDisc == 0) then

seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")

end

end



function OpConnected(curUser)

seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")

end



function OpDisconnected(curUser)

seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")

end



function UserDisconnected(curUser)

seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")

end



function DataArrival(curUser, data)

seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")

if( string.sub(data, 1, 1) == "<" ) then

data=string.sub(data,1,string.len(data)-1)

_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )

if (cmd == SeenTrigger) then

if (arg == curUser.sName) then

SendToAll(BotName, "You should not do #seen's for yourself ;)" )

elseif (seenArray[arg] ~= nil) then

SendToAll(BotName, "User: "..seenArray[arg] )

else

SendToAll(BotName, "I have not seen "..arg.."!" )

end

end

end

end

Dessamator

[COLOR=red]function DataArrival(curUser, data) [/COLOR]  
seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.") 
	[COLOR=blue]if( string.sub(data, 1, 1) == "<" ) then[/COLOR] 
data=string.sub(data,1,string.len(data)-1) 
_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%+)" ) 
	if (cmd == SeenTrigger) then 
		if (arg == curUser.sName) then 
			[COLOR=red]SendToAll(BotName, "You should not do #seen's for yourself ;)" )  [/COLOR]  
		elseif (seenArray[arg] ~= nil) then 
			[COLOR=red]SendToAll(BotName, "User: "..seenArray[arg] )   [/COLOR]  
		else 
			[COLOR=red]SendToAll(BotName, "I have not seen "..arg.."!" ) [/COLOR]  
	[COLOR=blue]end [/COLOR]  
		end 
	end 

end


yap sure, change the lines in red as follows:
Change from DataArrival to ChatArrival
Change from SendToAll to curUser:SendPM
and delete the lines in blue

Good luck !
Ignorance is Bliss.

damo

changed and deleted lines but for some reason still dont wonna work. no errors comeing up to any thoughts

6Marilyn6Manson6

#3
try this [ not tested ]:

BotName = "LeonBot" 
SeenTrigger = "!seen" 

minLen = 2 
maxLen = 20 
seenArray={} 

function Main() 
	frmHub:RegBot(BotName) 
end

function NewUserConnected(curUser) 
	local boolDisc = 0 
		if string.len(curUser.sName) < minLen then 
			curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!") 
			curUser:SendPM(BotName, "Disconnecting...") 
			curUser:Disconnect() 
		boolDisc = 1 
				elseif string.len(curUser.sName) > maxLen then 
					curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!") 
					curUser:SendPM(BotName, "Disconnecting...") 
					curUser:Disconnect() 
				boolDisc = 1 
						elseif ( string.find (curUser.sName, " ", 1, 1) ) then 
							curUser:SendPM(BotName, "Spaces not allowed in nicknames!") 
							curUser:SendPM(BotName, "Disconnecting...") 
							curUser:Disconnect() 
						boolDisc = 1 
						end 
				if (boolDisc == 0) then 
					seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.") 
		end 
end

function OpConnected(curUser) 
	seenArray[curUser.sName]=os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.") 
end

function OpDisconnected(curUser) 
	seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.") 
end

function UserDisconnected(curUser) 
	seenArray[curUser.sName]=os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.") 
end

function ChatArrival(curUser, data) 
	seenArray[curUser.sName]=os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.") 
		data=string.sub(data,1,string.len(data)-1) 
			_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" ) 
			if (cmd == SeenTrigger) then 
				if (arg == curUser.sName) then 
					curUser:SendPM(BotName, "You should not do #seen's for yourself ;)" ) 
			elseif (seenArray[arg] ~= nil) then 
				curUser:SendPM(BotName, "User: "..seenArray[arg] ) 
			else				
			curUser:SendPM(BotName, "I have not seen "..arg.."!" ) 			
		end
	end 
end

c ya

damo

#4
thx for the help this script works but can i stop it from posting the command and who you are seeing in main
as i have users with nicks like [DH]damo then sends the pm like its suposed to but also sends the command and user name to main

Ubikk

Nice script. But can you guys also ad something like this?

howToSend = 2,       -- 1:Sends to all / 2:Sends to user / 3:PM to the user / 4:PM to the user and regs a bot.

:)

Thanks in advance :D

Madman

#6
-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo

BotName = "LeonBot"
SeenTrigger = "!seen"

minLen = 2
maxLen = 20
HowToSend = 3 -- 1: Send to all, 2: Send to user, 3: PM to the user

require("seen.dat")

function Main()
	if HowToSend == 3 then
		frmHub:RegBot(BotName)
	end
end

function NewUserConnected(curUser)
	local boolDisc = 0
	if string.len(curUser.sName) < minLen then
		curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif string.len(curUser.sName) > maxLen then
		curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif ( string.find (curUser.sName, " ", 1, 1) ) then
		curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	end
	if (boolDisc == 0) then
		if seenArray[curUser.sName] == nil then
			seenArray[curUser.sName] = {}
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
		else
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
		end
	end
end

function OpConnected(curUser)
	if seenArray[curUser.sName] == nil then
		seenArray[curUser.sName] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

function OpDisconnected(curUser)
	if seenArray[curUser.sName] == nil then
		seenArray[curUser.sName] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

UserDisconnected = OpDisconnected

function ChatArrival(curUser, data)
	if seenArray[curUser.sName] == nil then
		seenArray[curUser.sName] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
	data=string.sub(data,1,string.len(data)-1)
	_,_,cmd,arg = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
	if (cmd == SeenTrigger) then
		if (arg == curUser.sName) then
			if HowToSend == 1 then
				SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
			elseif HowToSend == 2 then
				curUser:SendData(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
			elseif HowToSend == 3 then
				curUser:SendPM(BotName, "You should not do #seen's for yourself " ..curUser.sName.. " ;)" )
			end
		elseif (seenArray[arg] ~= nil) then
			if HowToSend == 1 then
				SendToAll(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 2 then
				curUser:SendData(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 3 then
				curUser:SendPM(BotName, "User: "..seenArray[arg] )
			end
		else
			if HowToSend == 1 then
				SendToAll(BotName, "I have not seen "..arg.."!" )
			elseif HowToSend == 2 then
				curUser:SendData(BotName, "I have not seen "..arg.."!" )
			elseif HowToSend == 3 then
				curUser:SendPM(BotName, "I have not seen "..arg.."!" )
			end
		end
		return 1
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	sTmp = ""
	sTmp = sTmp..sTab..sTableName.." = {\n"
	for key, value in tTable do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
	if (handle ~= nil) then
		loadstring(handle:read("*all"))
		handle:flush()
		handle:close()
	end
end

The bot must be regged to send pm.. so I skipped nr 4 =)

Important
Since it save to file, witch allows it to remeber after script restart, you must create a file called seen.dat with the the following text in it
seenArray = {
}
if you dont, it will give errors like
attempt to index global `seenArray' (a nil value)

*Edit*

Fixed an typo... ;)
HowToSend 2 Was not working....
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

damo

very nice changes you made however i have a small problem with an error that i get when you look for yourself all others work fine heres the error seen.lua:96: attempt to call field `sName' (a string value)

[UK]Madman

Just missing .. after curUser.sName in the followong line:

SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName " ;)" )

Should read:

SendToAll(BotName, "You should not do #seen's for yourself " ..curUser.sName.."  ;)" )

Madman

Thanks [UK]Madman
Missed that... =)
Script has been edited
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

damo

Thx for all the help with this script is very nice and the save feature is a nice bonus

Madman

QuoteOriginally posted by damo
Thx for all the help with this script is very nice and the save feature is a nice bonus

Np at all =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Ubikk

Is it possible to make the script to work for Ip's too?
E.g: !seen 192.168.240.31

Madman

#13
For the version i posted
Fixed an typo... ;)
HowToSend 2 Was not working....

QuoteOriginally posted by Ubikk
Is it possible to make the script to work for Ip's too?
E.g: !seen 192.168.240.31

Yup it can...

-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo
-- Added OnError Msg
-- Rewrote the ChatArrival
-- Added postibilite so seen ips, Request by Ubikk

BotName = "LeonBot"

minLen = 2
maxLen = 20
HowToSend = 2 -- 1: Send to all, 2: Send to user, 3: PM to the user

require("seen.dat")

function Main()
	if HowToSend == 3 then
		frmHub:RegBot(BotName)
	end
end

function NewUserConnected(curUser)
	local boolDisc = 0
	if string.len(curUser.sName) < minLen then
		curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif string.len(curUser.sName) > maxLen then
		curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif ( string.find (curUser.sName, " ", 1, 1) ) then
		curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	end
	if (boolDisc == 0) then
		if seenArray == nil then
			seenArray = {}
			seenArray[curUser.sName] = {}
			seenArray[curUser.sIP] = {}
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
			SendToAll("Weee")
		else
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
		end
	end
end

function OpConnected(curUser)
	if seenArray == nil then
		seenArray = {}
		seenArray[curUser.sName] = {}
		seenArray[curUser.sIP] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

function OpDisconnected(curUser)
	if seenArray == nil then
		seenArray = {}
		seenArray[curUser.sName] = {}
		seenArray[curUser.sIP] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

UserDisconnected = OpDisconnected

function OnError(ErrorMsg)
	SendToOps(ErrorMsg)
end

function ChatArrival(curUser, data)
	if seenArray == nil then
		seenArray = {}
		seenArray[curUser.sName] = {}
		seenArray[curUser.sIP] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
	local data = string.sub(data, 1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
	if cmd then
		local tCmds = {
		["seen"] = function(curUser, data)
			local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
			if not arg then
				if HowToSend == 1 then
					SendToAll(BotName, "Syntax is: !" ..cmd.. " ")
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "Syntax is: !" ..cmd.. " ")
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "Syntax is: !" ..cmd.. " ")
				end
				return 1
			end
			if (arg == curUser.sName) or (arg == curUser.sIP) then
				if HowToSend == 1 then
					SendToAll(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				end
				return 1
			end
			if seenArray[arg] == nil then
				if HowToSend == 1 then
					SendToAll(BotName, "I have not seen "..arg.."!" )
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "I have not seen "..arg.."!" )
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "I have not seen "..arg.."!" )
				end
				return 1
			end
			if HowToSend == 1 then
				SendToAll(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 2 then
				curUser:SendData(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 3 then
				curUser:SendPM(BotName, "User: "..seenArray[arg] )
			end
			return 1
		end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](curUser, data)
		end
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	sTmp = ""
	sTmp = sTmp..sTab..sTableName.." = {\n"
	for key, value in tTable do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
end

function LoadFromFile(file)
	local handle = io.open(file,"r")
	if (handle ~= nil) then
		loadstring(handle:read("*all"))
		handle:flush()
		handle:close()
	end
end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

damo

very nice updates glad i asked for help now :D

Ubikk

Are you sure HowToSend 2 works now?  ?(

Ubikk

Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)

Madman

QuoteOriginally posted by Ubikk
Are you sure HowToSend 2 works now?  ?(

lol.. sorry... fixed it in Version 1... but forgot to change it in Version 2 ;p

QuoteOriginally posted by Ubikk
Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)

hmm... no idea why...

Maybe somebody got an idea :/
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

jiten

QuoteOriginally posted by Ubikk
Oh.. and by the way, the script is causing all the users a little bit of lag... even to me :( I have a lag of 1-2 seconds on my own hub !! :)
Did the lag disappear when you unloaded (if) this script?

Cheers

plop

this script saves the data files on every chat msg.
poor harddrive, specialy if there is a av checking the data files.
now you found the cause, next find a way 2 solve it.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Madman

#20
QuoteOriginally posted by plop
this script saves the data files on every chat msg.
poor harddrive, specialy if there is a av checking the data files.
now you found the cause, next find a way 2 solve it.

plop

True.. didn't think of that... Thanks plop


My soultion is... make a switch for loging chat
and also a switch that is only triggerd if someone wrote something in main...
if both triger is 1 then save the new data...
on timer... the time can be setted on how many minues you want...  =)

-- Creator Leon
-- Started lua 5 conversion, damo
-- Fully converted to lua 5 by 6Marilyn6Manson6
---- Modded By Madman
-- Added save to file
-- Added HowToSend, request by Ubikk
-- Hidden the command, request by damo
-- Added OnError Msg
-- Rewrote the ChatArrival
-- Added postibilite so seen ips, Request by Ubikk
-- Added switch to seen on chatarrival
-- Added saveing ontimer, only updates chat
-- Added SomeoneChated, only set to 1 if somebody wrote something in main
---- if SomeoneChated is set to one, update file ontimer

BotName = "LeonBot"
SeenChat = 1 -- Save chat 1 = yes, nil = no
minLen = 2
maxLen = 20
HowToSend = 2 -- 1: Send to all, 2: Send to user, 3: PM to the user
ChatTime = 5 -- How many minutes beetween saves

require("Seen.dat")

function Main()
	if HowToSend == 3 then
		frmHub:RegBot(BotName)
	end
	SetTimer(1000*60*ChatTime)
	StartTimer()
end

function OnTimer()
	if SeenChat then
		if SomeoneChated == 1 then
			SaveToFile("Seen.dat", seenArray, "seenArray")
			SomeoneChated = 0
		end
	end
end

function NewUserConnected(curUser)
	local boolDisc = 0
	if string.len(curUser.sName) < minLen then
		curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif string.len(curUser.sName) > maxLen then
		curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	elseif ( string.find (curUser.sName, " ", 1, 1) ) then
		curUser:SendPM(BotName, "Spaces not allowed in nicknames!")
		curUser:SendPM(BotName, "Disconnecting...")
		curUser:Disconnect()
		boolDisc = 1
	end
	if (boolDisc == 0) then
		if seenArray == nil then
			seenArray = {}
			seenArray[curUser.sName] = {}
			seenArray[curUser.sIP] = {}
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
			SendToAll("Weee")
		else
			seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
			SaveToFile("Seen.dat", seenArray, "seenArray")
		end
	end
end

function OpConnected(curUser)
	if seenArray == nil then
		seenArray = {}
		seenArray[curUser.sName] = {}
		seenArray[curUser.sIP] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." connected at %d/%m/%Y %T and is still here.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

function OpDisconnected(curUser)
	if seenArray == nil then
		seenArray = {}
		seenArray[curUser.sName] = {}
		seenArray[curUser.sIP] = {}
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	else
		seenArray[curUser.sName] = os.date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")
		seenArray[curUser.sIP] = os.date(curUser.sIP.." disconnected at %d/%m/%Y %T and has not been seen since.")
		SaveToFile("Seen.dat", seenArray, "seenArray")
	end
end

UserDisconnected = OpDisconnected

function OnError(ErrorMsg)
	SendToOps(ErrorMsg)
end

function ChatArrival(curUser, data)
	if SeenChat then
		if seenArray == nil then
			seenArray = {}
			seenArray[curUser.sName] = {}
			seenArray[curUser.sIP] = {}
			seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
			SomeoneChated = 1
		else
			seenArray[curUser.sName] = os.date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")
			seenArray[curUser.sIP] = os.date(curUser.sIP.." was last seen at %d/%m/%Y %T writing things.")
			SomeoneChated = 1
		end
	end
	local data = string.sub(data, 1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+%?%#](%S+)")
	if cmd then
		local tCmds = {
		["seen"] = function(curUser, data)
			local s,e,arg = string.find(data, "%b<>%s+%S+%s+(%S+)")
			if not arg then
				if HowToSend == 1 then
					SendToAll(BotName, "Syntax is: !" ..cmd.. " ")
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "Syntax is: !" ..cmd.. " ")
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "Syntax is: !" ..cmd.. " ")
				end
				return 1
			end
			arg = string.lower(arg)
			if (arg == curUser.sName) or (arg == curUser.sIP) then
				if HowToSend == 1 then
					SendToAll(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "You should not do seen's for yourself " ..curUser.sName.. " ;)" )
				end
				return 1
			end
			if seenArray[arg] == nil then
				if HowToSend == 1 then
					SendToAll(BotName, "I have not seen "..arg.."!" )
				elseif HowToSend == 2 then
					curUser:SendData(BotName, "I have not seen "..arg.."!" )
				elseif HowToSend == 3 then
					curUser:SendPM(BotName, "I have not seen "..arg.."!" )
				end
				return 1
			end
			if HowToSend == 1 then
				SendToAll(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 2 then
				curUser:SendData(BotName, "User: "..seenArray[arg] )
			elseif HowToSend == 3 then
				curUser:SendPM(BotName, "User: "..seenArray[arg] )
			end
			return 1
		end,
		}
		if tCmds[cmd] then
			return tCmds[cmd](curUser, data)
		end
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	sTmp = ""
	sTmp = sTmp..sTab..sTableName.." = {\n"
	for key, value in tTable do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(Serialize(table, tablename))
	handle:flush()
	handle:close()
end

function LoadFromFile(filename)
	local f = io.open( filename, "r")
	if f then
		local r = f:read( "*a" )
		f:flush()
		f:close()
		local func, err = loadstring(r)
		if func then x,err = pcall(func) end
	end
end

Important
Since it save to file, witch allows it to remeber after script restart, you must create a file called seen.dat with the the following text in it
seenArray = {
}
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

6Marilyn6Manson6

Nice madman very nice ^^

Dessamator

-- Creator Unknown

BotName = "LeonBot"

that should give u a hint of who created it, "leon bot"

and here is the proof :)
Ignorance is Bliss.

Madman

QuoteOriginally posted by Dessamator
-- Creator Unknown

BotName = "LeonBot"

that should give u a hint of who created it, "leon bot"

and here is the proof :)

thanks...
Scripts been edited =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Dessamator

Ignorance is Bliss.

SMF spam blocked by CleanTalk