Clonebot 1.1
 

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

Clonebot 1.1

Started by bastya_elvtars, 03 April, 2005, 19:53:10

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

bastya_elvtars

Very-very preparation stage. Seems to work howeva. :P Please test carefully! ;)

-- Clone Alert 1.1
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch

OpChatName = "opschat"		--Rename to opchatbot
Bot = "[Sentry]"			--Rename to you main Px bot
PmOps = "1"				--Should Ops be notified 1=yes 0=no (STRONGLY recommended to leave enabled!)



function NewUserConnected(curUser,sdata) 
	for _,Nick in frmHub:GetOnlineUsers() do
		if curUser.sIP==Nick.sIP and not (curUser.bOperator and Nick.bOperator) then
			if curUser.iShare==Nick.iShare then
				curUser:SendPM(Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
				curUser:Disconnect()
				Nick:SendPM(Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
				Nick:Disconnect()
				if PMOps == "1" then
					SendPmToOps(OpChatName, "*** Cloned user = "..curUser.sName.." logged in, Nick is a clone of = "..Nick.sName)
					SendPmToOps(OpChatName, "***"..curUser.sName.." and "..Nick.sName.." have been disconnected")
				end
			else
				SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
			end
		end
	end 
end
Everything could have been anything else and it would have just as much meaning.

jiten

Well, it's working ok with me  :D
Btw, i found a little bug, nothing much.
It should be:

if PmOps == "1" then


or

PMOps = "1"


Thanks for this one.

Cheers

jiten

#2
Made some mods in this Clonebot. Here it is:

-- Clone Alert 1.1
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten 

OpChatName = "OpChat"		--Rename to opchatbot
Bot = "?bot?"			--Rename to you main Px bot
PmOps = "1"				--Should Ops be notified 1=yes 0=no (STRONGLY recommended to leave enabled!)

--imunity stuff 
fimmune= "logs/cloneimmune.txt" 
immunetbl = {} 

function Main() 
	--imunity stuff 
	LoadFromFile(fimmune) 
end

function NewUserConnected(curUser,sdata) 
	for _,Nick in frmHub:GetOnlineUsers() do
		if not(immunetbl[curUser.sName]== 1 or immunetbl[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
			if curUser.iShareSize==Nick.iShareSize then
				curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
				curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
				curUser:TimeBan(5)
				Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
				if PmOps == "1" then
						SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
				else
						SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
				end
			end
		end
	end 
end

----------------------------->Immunity Stuff<---------------------------------
function immune(user,data) 
	local s,e,cmd,Name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" ) 
	if (Name == nil) then 
		user:SendData(Bot, "*** Error: Type !addclone nick") 
	else 
		victim = GetItemByName(Name)  
		if victim==nil then  
			user:SendData(Bot, "*** Error: User is not online.") 
		elseif	immunetbl[victim.sName] == nil then 
			immunetbl[victim.sName] = 1 
			saveimmune() 
			user:SendData(Bot, victim.sName.." is now immune to clone checks!")
		else 
			user:SendData("nope") 
		end
	end 
end 

function delimmune(user,data)
	local s,e,Name = string.find(data, "%b<>%s+%S+%s+(.+)")
	if (Name == nil) then 
		user:SendData(Bot, "*** Error: Type !delclone nick") 
	else 
		victim =GetItemByName(Name)
		if victim==nil then  
			user:SendData(Bot, "*** Error: That user is not online.") 
		elseif	immunetbl[victim.sName] == 1 then 
			immunetbl[victim.sName] = nil 
			saveimmune() 
			user:SendData(Bot,"Now "..victim.sName.." is not no longer immune to clone checks!")
		else 
			user:SendData(Bot,"The user "..victim.sName.." is not immune!") 
		end
	end 
end 

function showimmune(user)
	if isEmpty(immunetbl) then
		user:SendPM(Bot,"*** Error: There aren't any immuned users")
	else
		local Tmp,usr,table1 = "\r\n\t\ These are the Clone Immuned User(s):\r\n\r\n"  
		for usr, table1 in immunetbl do 
			if GetItemByName(usr) then
				Tmp = Tmp.."\t".."  ? (Online)   "..usr.." \r\n" 
			else
				Tmp = Tmp.."\t".."  ? (Offline)  "..usr.." \r\n" 
			end 
		end	 			
		user:SendPM(Bot,Tmp)
	end
end 

-------------------save immune 
function saveimmune(user,data)  
	local fimmune = io.open("logs/cloneimmune.txt", "w+") 
	assert(fimmune, "logs/cloneimmune.txt") 
	fimmune:write("immunetbl = {");  
	for a,b in immunetbl do  
		if b then  
			fimmune:write(string.format("[%q]=",a)..b..",");  
		end  
	end  
	fimmune:write("}" );  
	fimmune:close() 
end  

function ChatArrival (user,data) 
	if (user.bOperator) then 
		data = string.sub(data,1,string.len(data)-1) 
		local s,e,cmd = string.find( data, "%b<>%s+(%S+)" ) 
		if cmd=="!addclone" then 
			immune(user,data) 
		return 1 
		elseif cmd=="!delclone" then 
			delimmune(user,data) 
		return 1
		elseif cmd=="!showclone" then 
			showimmune(user,data)
		return 1
		end 
	end 
end 

ToArrival = ChatArrival

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

-------------table checker by herodes
--- for an associative table, like ["smth"] = "smth else",
function isEmpty(t)
	for i,v in t do
		return false;
	end
	return true;
end;

*EDIT - Corrected typos (imune to immune)
Best regards,

jiten

bastya_elvtars

Nice job, now it's like it's lua4 brother. My point was: I make the detector, others make the decorations. :D Thx, jiten, good job there!
Everything could have been anything else and it would have just as much meaning.

jiten

QuoteOriginally posted by bastya_elvtars
Nice job, now it's like it's lua4 brother. My point was: I make the detector, others make the decorations. :D Thx, jiten, good job there!

yw m8  :]

DEEP-GOA

error:

Syntax C:\0.3.3.0.b16.06.nt.dgb\scripts\CloneAlert1.1.lua:46: attempt to index global `immunetbl' (a nil value)

maybe a bug?

greetz & zakaboom

http://deep-goa.no-ip.org
Put any term or title on me you want. What I am is what I do. I make things.

bastya_elvtars

Thats seems a typo to me. replace to imunetbl and it must work. :)
Everything could have been anything else and it would have just as much meaning.

jiten

QuoteOriginally posted by DEEP-GOA
error:

Syntax C:\0.3.3.0.b16.06.nt.dgb\scripts\CloneAlert1.1.lua:46: attempt to index global `immunetbl' (a nil value)

maybe a bug?

greetz & zakaboom

Yups, was a typo  :D
First post updated.

DEEP-GOA

hiho

mmany thanks,, now works fine,,   deepy8) should read the code lol

zakagreetings

http://deep-goa.no-ip.org
Put any term or title on me you want. What I am is what I do. I make things.

jiten

QuoteOriginally posted by DEEP-GOA
hiho

mmany thanks,, now works fine,,   deepy8) should read the code lol

zakagreetings

yw m8  :]

Typhoon

as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?



jiten

QuoteOriginally posted by Typhoon?
as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?

Well, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  ;)

Btw, removed those 2 functions to have a shorter one.

Cheers

Typhoon

QuoteOriginally posted by jiten
QuoteOriginally posted by Typhoon?
as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?

Well, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  ;)

Btw, removed those 2 functions to have a shorter one.

Cheers

oh yeah forgot if file is nil :)

Typhoon?



jiten


??????Hawk??????

hi

QuoteWell, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  



maby use something like this for loading...
function LoadFile(file)
	local r,e = io.open(file,"r")				
		if r then
			f = assert(loadfile(file), " ")
		else
				r,e = io.open(file, "w" )
				r:write("|")
				r:close()
		end
end


??????Hawk??????

bastya_elvtars

QuoteOriginally posted by Mutor
QuoteI make the detector, others make the decorations

Who made what?   :P

-peace

:)

I gave credits to you, and I made the new way detector. Are you satisfied now? ;)
Everything could have been anything else and it would have just as much meaning.

Fruitbat?

soz for newbie questions but what i am i doing wrong

running :-
PtokaX DC Hub 0.3.3.0 build 16.09
 Robocop 10.01c
FunScript Version 6.3 Made by Madman

but when i added this script it works some times and not others plus if i open ptokax/Advanced to check memory used by scripts i have 3 or 4 of this script running.This happens when i refresh scripts.

testing this in a mirror image of my hub ( as always test settings first before i apply to main hub)

ne input would be grateful

Thx
Fruitbat?

Dessamator

nop, tested it with the same ptokax, no errors here, and no extra scripts in ptokax !!
Ignorance is Bliss.

jiten

Yups, no errors here. Maybe u're doing something wrong there. Try copying the script all over again and then change the script loading order. Don't know if this will help, but, it's worth a try.

ConejoDelMal

#19
well....i tested this script, and in a hub with 150 users the script is eating memory.... i checked ptokax and this script alone was using 800kb....dont know if i have something wrong, or if its the code

*edited*
But it didnt multiply itself... :P
Rede-DC Comunidade Portuguesa de DC

Dessamator

hmmm, well mayb herodes can help, hes good with memory related "bugs" !!
Ignorance is Bliss.

bastya_elvtars

As it has to work with all users' all properties on a connect, it should not be surprising. however, it would be nice if you pasted a result of !stat here.
Everything could have been anything else and it would have just as much meaning.

Herodes

#22
gave it a touch .. syntax errors checked only ..
runs on 46/62:Mem/GC with an empty table on my family pc .. :)
-- Clone Alert 1.5
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5

OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "?bot?" -- Rename to you main Px bot
PmOps = true -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)

function Main()
	tImmune = {}
	if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end

function OnExit()
	collectgarbage()
	local f = io.open("logs/cloneimmune.txt", "w+")
	local m = "tImmune = { "
	for a, b in tImmune do m = m..string.format("%q, ", string.gsub( a, "\"", "\"" )); end
	m = m.." }"
	f:write( m ); f:close();
end

function NewUserConnected( user, data )
	for _, nick in frmHub:GetOnlineUsers() do
		if not ( user.bOperator or nick.bOperator ) then
			if not ( tImmune[user.sName] or tImmune[nick.sName] ) then
				if (user.sIP == nick.sIP) then
					user:SendPM( Bot, "Double Login is not allowed. You are already connected to this hub with this nick: "..nick.sName )
					nick:SendPM( Bot, "Double Login is not allowed. You are already connected to this hub with this nick: "..user.sName )
					if ( PmOps ) then
						SendPmToOps(OpChatName, "*** User "..user.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
					elseif (user.iShareSize == nick.iShareSize) then
						SendPmToOps(OpChatName, "*** Cloned user <"..user.sName.."> ("..user.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..nick.sName..">")
						user:SendPM( Bot, "You're being timebanned. Your IP: "..user.sIP )
						user:TimeBan( 5 )
					end
				end
			end
		end
	end
end

function ChatArrival (user,data)
	if (user.bOperator) then
		local data = string.sub( data, 1, -2 )
		local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
		if cmd then
			return Parse( user, cmd, data, false )
		end
	end
end

function ToArrival ( user, data )
	if ( user.bOperator ) then
		local data = string.sub( data , 1, -2 )
		local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
		if cmd then
			return Parse ( user, cmd , data , true )
		end
	end
end

function Parse( user, cmd, data, how )

	local function SendBack( user, msg , from, how )
		if how then user:SendPM( from or Bot , msg );return 1; end;
		user:SendData( from or Bot, msg );return 1;
	end

	local t = {
	--- Add to cloneList
	["+clone"] = function ( user , data , how )
		local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )

		if not name then user:SendData(Bot, "*** Error: Type !addclone nick") end
		if tImmune[name] then user:SendData("nope") end

		local nick = GetItemByName(name)
		if not nick then user:SendData(Bot, "*** Error: User is not online.") end

		tImmune[name] = 1
		OnExit()
		user:SendData(Bot, name.." is now immune to clone checks!")
		return 1
	end ,
	--- Remove from cloneList
	["-clone"] = function ( user , data , how )
		local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")
		if not name then user:SendData(Bot, "*** Error: Type !delclone nick") end
		if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end

		local nick = GetItemByName( name )
		if not nick then user:SendData(Bot, "*** Error: That user is not online.") end

		tImmune[name] = nil
		OnExit()
		user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
		return 1
	end,
	--- Show cloneList
	["?clone"] = function ( user , data, how )
		local m = ""
		collectgarbage()
		for nick, _ in tImmune do
			local s = "Offline"
			if GetItemByName(nick) then s = "Online"; end
			m = m.."\r\n\t  ? ("..s..")  "..nick
		end
		if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
		m = "\r\nThe following users can have clones in this hub:"..m
		return SendBack( user, m , Bot, how )
	end,
	--- Show cloneBot help
	["?clonehelp"] = function ( user, data , how )
		local m = "\r\n\r\nHere are the commands for the CloneBot:"
		m = m.."\r\n\t+clone  \t allows  to have a clone"
		m = m.."\r\n\t-clone  \t removes  from the clone list"
		m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
		m = m.."\r\n\t?clonehelp \t allows  to have a clone"
		return SendBack( user, m, Bot, how )
	end, }

	if t[cmd] then return t[cmd]( user, data, how ) end
end

bastya_elvtars

function Main()

	tImmune = {}

	if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end

end

I used this method and works...
Everything could have been anything else and it would have just as much meaning.

ConejoDelMal

i will test it later today, and this time i try not to forget the !stat ..  :P
Rede-DC Comunidade Portuguesa de DC

SMF spam blocked by CleanTalk