Leech 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

Leech Bot

Started by jiten, 24 March, 2005, 15:43:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

-- Lua 5 version by jiten (completely rewritten)
-- Removed: Unnecessary code;
-- Added: Profile x can (not) download from profile y table
-- Changed: Commands' structure to tables
-- Added: Immune users that can download from blocked nicks (requested by felix444) (1/1/2006)
-- Fixed: tImmune if
-- Changed: tIdxBlocked to allow connections between every profile by default (1/2/2006)

-- 100% Blocker by chill
-- Table Load and Save (added by nErBoS)

sBot = "LeechBot"

tBlocked = {}

-- File where the blocked nicks are stored
fBlock = "tBlock.tbl"

tImmune = {
--	[Blocked Uploader's Nick] = {
--		[Nick allowed to download from him]
--	},
	["uploader"] = {
		["downloader1"] = 1,
		["downloader2"] = 1,
	},
}

tIdxBlocked = {
--	[Downloader Profile Number] = {
--		[Uploader Profile Number] = 1 - Connection Blocked; 0 - Unblocked Connection
--	},

	[0] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[1] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[2] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[3] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[4] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[5] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
	[-1] = { [-1] = 0, [0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, },
}

Main = function()
	if loadfile(fBlock) then dofile(fBlock) end
end

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

CTMArrival = function(user,data)
	local sFind
	if string.sub(data,1,4) == "$Rev" then sFind = "(%S+)|$" elseif string.sub(data,1,4) == "$Con" then sFind = "%S+%s+(%S+)" end
	local s,e,nick = string.find(data,sFind)
	-- (user is blocked and can't download? OR user's profile can download from nick's? OR nick is blocked and can't upload?) AND (can immune user download from blocked nick?)
	if (tBlocked[string.lower(user.sName)] or tIdxBlocked[user.iProfile][GetItemByName(nick).iProfile] == 1 or tBlocked[string.lower(nick)]) then
		if not (tImmune[string.lower(GetItemByName(nick).sName)] and tImmune[string.lower(GetItemByName(nick).sName)][string.lower(user.sName)]) then
			user:SendData(sBot,"*** Error: You are not authorized to download from "..nick..".")
			return 1
		end
	end
end

ConnectToMeArrival = CTMArrival
RevConnectToMeArrival = CTMArrival

tCmds = {
	["!block"] = 
	function(user,data)
		local s,e,nick = string.find(data,"%b<>%s+%S+%s+(%S+)")
		if nick then
			if tBlocked[string.lower(nick)] == 1 then
				user:SendData(sBot,"*** Error: "..nick.." is already blocked.")
			else
				tBlocked[string.lower(nick)] = string.lower(user.sName) SaveToFile(fBlock,tBlocked,"tBlocked")
				user:SendData(sBot,"*** "..nick.." is now blocked.") 
			end
		else
			user:SendData(sBot,"*** Syntax Error: Type !block <nick>")
		end
	end,
	["!unblock"] = 
	function(user,data)
		local s,e,nick = string.find(data,"%b<>%s+%S+%s+(%S+)")
		if nick then
			if tBlocked[string.lower(nick)] then
				tBlocked[string.lower(nick)] = nil SaveToFile(fBlock,tBlocked,"tBlocked")
				user:SendData(sBot,"*** "..nick.." is now unblocked.")
			else
				user:SendData(sBot,"*** Error: "..nick.." isn't blocked.")
			end
		else
			user:SendData(sBot,"*** Syntax Error: Type !unblock <nick>")
		end
	end,
	["!showblock"] =
	function(user)
		local msg = "\r\n\r\n".."\t"..string.rep("- -",20).."\r\n" 
		msg = msg.."\t\tCurrent Blocked Users:\r\n" 
		msg = msg.."\t"..string.rep("- -",20).."\r\n"
		for v, i in tBlocked do msg = msg.."\t ? "..v.."\t blocked by "..i.."\r\n" end
		user:SendData(sBot,msg)
	end,
}

Serialize = function(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n");
	for key,value in tTable do
		if (type(value) ~= "function") then
			local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
			if(type(value) == "table") then
				Serialize(value,sKey,hFile,sTab.."\t");
			else
				local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
				hFile:write(sTab.."\t"..sKey.." = "..sValue);
			end
			hFile:write(",\n");
		end
	end
	hFile:write(sTab.."}");
end

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

James

Hi
is possible to change this script in Dl @ Up Blocker ? for active @ passive User.

Thx in Advance
James

Dessamator

whaaat?, i didnt understand the request ! could u explain it?
Ignorance is Bliss.

Krysalis

I think he means blocking download and upload separately.

Now there is
!block
!unblock

he wants

!blockup
!blockdown

!unblockup
!unblockdown

i think

Greets

James

Sorry !!! my bad english..speak only german ,french or romanian ...

i thought that this is only a download blocker but it's an upload blocker too. Now its all right.
but i thank you all for your help!-)))

James

chettedeboeuf

Hi !
Is it possible to have reason with '!block' command ??
And with the list the reasan should appear

Thank you

yoonohoo

What about adding a rightclick command with a line for the reason?
Thanx

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

Dessamator

Do it yourself, check the howto section !
Ignorance is Bliss.

yoonohoo

Hey Dessamator
I'm very grateful 4 all your help in the past, present and maybe future but no need 2b so harsh...
If the
QuoteDo it yourself, check the howto section !
was 4 me see my sig!
Been there, tried, even managed to create the raw cmd (i think thats what you call it)
"$UserCommand 1 3 Block User$<%[mynick]> !block %[line:nick] %[line:reason]|"
that was easy anyway just copied from another script and changed the command word and add or take the lines, so I could have this also
$UserCommand 1 2 Block User$<%[mynick]> !block %[line:reason]|"
But the shite hits the fan when it gets to the functions and the variables? and everything else but the raws.
So thats why I come and seek 4 help in this forum. If I could I would have done it and not seek for help (can only talk, write, 4 myself)...It would give me much more pleasure!

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

Dessamator

#9
Well, uve done most of it, and i wasnt being harsh, its isnt really hard to create right click, u just need to copy and paste one of the right click scripts, and change what u need.

either way all u need now is a function, in this case :

function OpConnected(user)
user:SendData("$UserCommand 1 3 Block User$<%[mynick]> !block %[line:nick] %[line:reason]|")

end


You can add the other commands using the same syntax , good luck.
Ignorance is Bliss.

jiten

First post updated with the most recent Leech Bot code.

SMF spam blocked by CleanTalk