anti-leech
 

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

anti-leech

Started by damo, 21 April, 2005, 18:04:24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

damo

was wondering if any one could make an anti-leech script as i havent seen one about. would be nice thx.

jiten

Have a look at this one or just search the forum for "leech bot".

Cheers

damo

this leech bot aint what im looking for. this lets users leech i want one that stops then altogether channel bot had one built in. ie if there share donst increase after a set time then they are leeching and the bot takes action

jiten

Well, if u have that script in Lua 4 (the stand-alone one), post it here.

Cheers

damo

wish it was stand alone but it aint so looks like a new script needs to be wrote thx anyway

jiten

#5
Here goes one:
-- share checker by jiten
-- ideas from:
--- ShaveShare v4.8 request by judas ( 10/08 - 2004 )
--- by Herodes ( 11/08 - 2004 )
--- 100% Blocker by chill and modded by nErBoS

Bot = "Share"

secs=1000 
minutes = 60 
hours = 60 ^2

tUsers = {} 
wtime = 30*minutes		---this is the time in seconds. .. Feel free to use the #*hours to say in # hours ... and  #*minutes to say in # minutes .. :) 

sharertxt = "shares.tbl"	--Will be created in the script folder
sh = {}

-- do not edit this
frequency = 10
-- 

function Main()
	frmHub:RegBot(Bot)
	SetTimer(1000)
	StartTimer()
	bal = math.floor(wtime/frequency)
end

function NewUserConnected(user, data)
	local share = user.iShareSize
	local i = string.format("%0.2f", tonumber(share)/(1024*1024*1024))
	CheckShare(user, i)
	if user.sMyInfoString then 
		local ishere = 0 
		if tUsers[user.sName] == nil and ishere ~= 1 then 
			tUsers[user.sName] = {}  
			tUsers[user.sName][1] = 0 
			tUsers[user.sName][2] = 1 
		end 
	end 
end 

OpConnected = NewUserConnected

function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1) 
	s,e,cmd = string.find(data,"%b<>%s+(%S+)") 
	if (cmd=="!sgrw") then
		if (user.bOperator) then
			local s,e,who = string.find(data,"%b<>%s+%S+%s+(%S+)")
			if (who == nil or who == "") then
				user:SendPM(Bot, "Syntax Error, !sgrw , you must write a name.")
			else
				user:SendPM(Bot, CheckUser(who))
			end
		else
			user:SendPM(Bot, "You don?t have permission to use this command.")
		end
		return 1
	end
end

ToArrival = ChatArrival

function CheckUser(user)
	local tmp = ""
	if (Verify(sharertxt) == nil) then
		tmp = tmp.."the file hasn't been created yet."
	else
		local e = io.open(sharertxt,"r")
		while 1 do
			local line = e:read("*l")
			if (line == nil) then
				tmp = tmp.."The user "..user.." wasn't found in the list, have you write the right name ?"
				break
			else
				local s,e,who,lshare, fshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+(%S+)")
				if (who ~= nil and string.lower(who) == string.lower(user) ) then
					if (GetItemByName(user) ~= nil) then
						tmp = tmp.."The user "..user.." is sharing "..lshare.." GB his last share was "..fshare.." GB."
					else 
						tmp = tmp.."The user "..user.." has shared "..lshare.." GB."
					end
					break
				end
			end
		end
		e:read()
		e:close()
	end
	return tmp
end

function CheckShare(user, share)
	local tmp = ""
	local time = 0
	if (Verify(sharertxt) == nil) then
		local f = io.open(sharertxt,"w+")
		f:write(user.sName.." & "..share.." & 0\r\n")
		f:close()
	else
		local g = io.open(sharertxt,"r")
		while 1 do
			local line = g:read("*l")
			if (line == nil) then
				if (time == 0) then
					tmp = tmp..user.sName.." & "..share.." & 0\r\n"
				end
				break
			else
				local s,e,who,nshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+%S+")
				if (who ~= nil and string.lower(who) == string.lower(user.sName)) then
					if (tonumber(nshare) > tonumber(share)) then
						SendPmToOps(Bot, "The user "..user.sName.." has least share then his last loggin.")
						SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					elseif (tonumber(nshare) < tonumber(share)) then
						SendPmToOps(Bot, "The user "..user.sName.." has more share then his last loggin.")
						SendPmToOps(Bot, "He had "..nshare.." GB and now he has "..share.." GB.")
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					elseif (tonumber(nshare) == tonumber(share)) then
						tmp = tmp..user.sName.." & "..share.." & "..nshare.."\r\n"
						sh[user.sName] = share
						time = 1
					end
				else
					tmp = tmp..line.."\r\n"
				end
			end
		end
		g:read()
		g:close()
		local h = io.open(sharertxt,"w+")
		h:write(tmp)
		h:close()
	end
end

function Verify(filename)
	local f = io.open(filename, "r")
	if f then
		f:close()
		return true
	end
end

function DoTimeUnits(time)
	local time, msg = time*1000, ""
	local tO = { { 86400000, 0, "days"}, { 3600000, 0, "hours"}, { 60000, 0, "minutes"}, { 1000, 0, "seconds"}, };
	for i , v in (tO) do
		if time >= tO[i][1] then
			repeat 
				tO[i][2] = tO[i][2] + 1
				time = time - tO[i][1]
			until time < tO[i][1]
		end
	end
	for i,v in tO do 
		if tO[i][2] ~= 0 then
			msg = msg.." "..tO[i][2].." "..tO[i][3]
		end
	end
	return msg
end

--- // --- Transforming bytes Into KB, MB, GB, TB, PT and Returning the ideal (highest possible) Unit --- // --- 
function DoShareUnits(intSize)				--- Thanks to kepp and NotRambitWombat 
	if intSize ~= 0 then 
		local tUnits = { "Bytes", "KB", "MB", "GB", "TB" } 
		intSize = tonumber(intSize); 
		local sUnits; 
		for index = 1, table.getn(tUnits) do 
			if(intSize < 1024) then 
				sUnits = tUnits[index]; 
				break; 
			else  
				intSize = intSize / 1024; 
			end 
		end 
		return string.format("%0.1f %s",intSize, sUnits); 
	else 
		return "nothing" 
	end 
end 

function TakeCare(table, timeallowed, balance, freq) 
	for user, time in table do 
		local usr = GetItemByName(user) 
		table[user][1] = table[user][1] + 1 
		if usr and usr.sMyInfoString then 
			_,_,share = string.find(usr.sMyInfoString, "%$(%d+)%$") 
			if ( table[user][1] >= timeallowed ) then 
				if (Verify(sharertxt) ~= nil) then
					local e = io.open(sharertxt,"r")
					while 1 do
						local line = e:read("*l")
						if (line ~= nil) then
							local s,e,who,lshare, fshare = string.find(line, "(%S+)%s+%&%s+(%S+)%s+&%s+(%S+)")
							if (who ~= nil and string.lower(who) == string.lower(user) ) then
								if lshare <= fshare then
									usr:SendPM(Bot, "You didn't fill up your share. You are being banned.") 
									usr:TimeBan(60) -- Action for users that don't change/add share
									table[usr.sName] = nil
								else
									table[usr.sName] = nil
								end
								break
							end
						end
					end
					e:read()
					e:close()
				end
			elseif ( table[user][1] == balance * table[user][2] ) then 
				table[user][2] = table[user][2] + 1 
			end 
		end 
	end 
end 

function OnTimer()
	TakeCare(tUsers, wtime, bal, frequency)
	collectgarbage()
	io.flush()
end
*EDIT* Added Herodes optimized DoTimeUnits function

Cheers

damo

cheers for that looks good

jiten

QuoteOriginally posted by damo
cheers for that looks good
Goody :]

Herodes

jiten: There is a nicer DoTimeUnits function
function DoTimeUnits(time)
	local time, msg = time*1000, ""
	local tO = { { 86400000, 0, "days"}, { 3600000, 0, "hours"}, { 60000, 0, "minutes"}, { 1000, 0, "seconds"}, };
	for i , v in (tO) do
		if time >= tO[i][1] then
			repeat 
				tO[i][2] = tO[i][2] + 1
				time = time - tO[i][1]
			until time < tO[i][1]
		end
	end
	for i,v in tO do 
		if tO[i][2] ~= 0 then
			msg = msg.." "..tO[i][2].." "..tO[i][3]
		end
	end
	return msg
end

jiten

QuoteOriginally posted by Herodes
jiten: There is a nicer DoTimeUnits function
Roger that ;)
First post updated.

Cheers

yoonohoo

Can the above be adapted to exclude certain profiles...
in fact all but user, reg and vip.

Or even better including a few lines to configure the profiles.

Many thanks

It might be simple for you but rocket science for me...

Dessamator

yep it can be done, but im unsure how u want it by commands or by defining in the script ?
Ignorance is Bliss.

yoonohoo

Dessamator
When you mentioned by commands you mean right click?

Maybe better in script as long as I can change it. I've got way too many right clicks already.



Thanks for the reply

It might be simple for you but rocket science for me...

SMF spam blocked by CleanTalk