Download blocker - Page 2
 

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

Download blocker

Started by witch, 22 April, 2005, 14:35:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

witch

thx jiten for another try.....i tested it on old ptokax and got this error, or is this script writen on lua5 fot new ptoka?:

Syntax error: attempt to call global `loadfile' (a nil value)
stack traceback:
   1:  function `Main' at line 21 [file `...05\RCv9.0g\RCv9.0g\scripts\downloadblocker.lua']
 
thx



jiten

QuoteOriginally posted by witch
thx jiten for another try.....i tested it on old ptokax and got this error, or is this script writen on lua5 fot new ptoka?:

Syntax error: attempt to call global `loadfile' (a nil value)
stack traceback:
   1:  function `Main' at line 21 [file `...05\RCv9.0g\RCv9.0g\scripts\downloadblocker.lua']
 
thx
That's a Lua 5 one ;)

Cheers

witch

aha that's what i thout...hehe  

any chance to convert it to lua 4?  :))

thx



jiten

I may convert it, but, firstly wanted to know if the Lua 5 one works flawlessly (without those slot sneaking passive users).

Cheers
QuoteOriginally posted by witch
aha that's what i thout...hehe  

any chance to convert it to lua 4?  :))

thx

witch

QuoteOriginally posted by jiten
I may convert it, but, firstly wanted to know if the Lua 5 one works flawlessly (without those slot sneaking passive users).

Cheers
Just tested it, hmm no luck...still da same result: passive users geting slot with np  :rolleyes:



[UK]Madman

Could it be down to your string find, the position of the targets name is different from connect to me and revconnect .. so your string find is correctly finding the remote nicks name for active connections, and finding the users name for passive.

$RevConnectToMe  
$ConnectToMe  :

May be wrong, but I had to use separate string finds in a d/load blocker I made :o)

Pothead

Try being in only the hub where the script is running and see if they get a slot. :)

jiten

[UK]Madman, you were right. I forgot that they were different :D
Here goes a possible working one:
-- requested by witch
-- unreg users upload blocker by jiten 
-- ideas from 100% Blocker by chill
-- thanks to [UK]Madman for the hint

sBot = frmHub:GetHubBotName()

BlockedNicks = {}
fBlock = "block.dat"

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

function OnExit()
	local f = io.open(fBlock,"w+")
	f:write(Serialize(BlockedNicks, "BlockedNicks"))
	f:flush()
	f:close()
end

function ChatArrival(curUser,data)
	if curUser.bOperator then
		data = string.sub(data,1,-2)
		local s,e,cmd = string.find ( data, "%b<>%s+[%!%?%+%#](%S+)" )
		if cmd then
			local tCmds = {
			["del"] =	function(curUser,data)
					local s,e,nick = string.find ( data, "%b<>%s+%S+%s+(%S+)" )
					if BlockedNicks[string.lower(nick)] then
						BlockedNicks[string.lower(nick)] = nil
						curUser:SendPM(sBot, nick.." is now unblocked. Now he can upload to anyone.")
					end
				end,
			["add"] =	function(curUser,data)
					local s,e,nick = string.find ( data, "%b<>%s+%S+%s+(%S+)" )
					if BlockedNicks[string.lower(nick)] == 1 then
						curUser:SendPM(sBot, nick.." is already blocked. Use !del  to unblock this user.")
					else
						BlockedNicks[string.lower(nick)] = curUser.sName
						curUser:SendPM(sBot, nick.." is now blocked. Now he only uploads to registered users.") 
					end
					OnExit()
				end,
			["show"] =	function (curUser,data)
					local sTmp,aux,nick = "Upload Blocker Users in this HUB:\r\n\r\n"
					for nick, aux in BlockedNicks do
						sTmp = sTmp.."User:-->> "..nick.."\t Was Blocked by: "..aux.."\r\n"
					end
					curUser:SendPM(sBot, sTmp)
				end,
			}
			if tCmds[cmd] then 
				return tCmds[cmd](curUser,data), 1
			end
		end
	end
end

ToArrival = ChatArrival

function ConnectToMeArrival(curUser, data)
	data = string.sub(data,1,-2);
	local s,e,nick = string.find(data,"%S+%s+(%S+)");
	nick = GetItemByName(nick);
	if (nick == nil) then return 1; end
	if BlockedNicks[string.lower(nick.sName)] then
		if not curUser.bRegistered then
			curUser:SendData("*** The user "..nick.sName.." you are trying to download from is not authorized to upload to Unreg Users.")
			return 1
		end
	end
end

function RevConnectToMeArrival(curUser,data)
	data = string.sub(data,1,-2);
	local s,e,nick = string.find(data,"%S+%s+%S+%s+(%S+)");
	nick = GetItemByName(nick);
	if (curUser == nil) then return 1; end
	if BlockedNicks[string.lower(nick.sName)] then
		if not curUser.bRegistered then
			curUser:SendData("*** The user "..nick.sName.." you are trying to download from is not authorized to upload to Unreg Users.")
			return 1
		end
	end
end

SearchArrival = ConnectToMeArrival

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
Cheers

witch

HUHAHUAHUAH HAAAA WORKS AL LAST  :D

THX A LOT jiten dude !!!
whatever u got time PLZ convert it in lua 4 as well.

1000000 THX  :P



jiten

QuoteOriginally posted by witch
HUHAHUAHUAH HAAAA WORKS AL LAST  :D

THX A LOT jiten dude !!!
whatever u got time PLZ convert it in lua 4 as well.

1000000 THX  :P
Glad we sorted it out :D
Yup, when I get some time I'll post the Lua 4 one.
Btw, the first one I posted gave you the same problems?

Best regards,

jiten

witch

QuoteOriginally posted by jiten

Btw, the first one I posted gave you the same problems?

emm first script u posted works with no errors, but as i says passive users still geting slots.....but this 1 is really works GREAT!

thx again  ;)



jiten

QuoteOriginally posted by witch
QuoteOriginally posted by jiten

Btw, the first one I posted gave you the same problems?

emm first script u posted works with no errors, but as i says passive users still geting slots.....
Just to confirm, the Lua 4 one posted in the previous page also has that passive bug, right?

witch

QuoteOriginally posted by jiten
Just to confirm, the Lua 4 one posted in the previous page also has that passive bug, right?
right



jiten

Give this a try:
-- requested by witch
-- unreg users upload blocker by jiten (lua 4 version)
-- based on 100% Blocker by chill modded by nErBoS

sBot = "[fow]-Leech"

cmd1 = "!add"
cmd2 = "!del"
cmd3 = "!show"


BlockedNicks = {}
fBlock = "block.dat"
OpChatName = frmHub:GetOpChatName()	--Use this line for inbuilt Px opchat


--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax Version lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	frmHub:EnableFullData(1) 
	LoadFromFile(fBlock)
end

function OnExit()
	SaveToFile(fBlock , BlockedNicks , "BlockedNicks")
end

BlockTriggs = {
	["$Con"] = 1,
	["$Rev"] = 2,
}

function DataArrival(curUser,data)
	if strsub(data,1,1) == "$" then
		local str1 = strsub(data,1,4)
		if BlockTriggs[str1] == 1 then
			local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
			if BlockedNicks[strlower(conNick)] then
				if curUser.iProfile == -1 then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload to Unreg Users.")
					return 1
				end
			end
		elseif BlockTriggs[str1] == 2 then
			local _,_,conNick = strfind(data,"(%S+)|$")
			if BlockedNicks[strlower(conNick)] then
				if curUser.iProfile == -1 then
					curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload to Unreg Users.")
					return 1
				end
			end
		end
	end
--	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.iProfile == 5 or curUser.iProfile == 0 then
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.bOperator then
		data = strsub(data,1,strlen(data)-1)
		local _,_,cmd,nick = strfind(data,"%b<>%s+(%S+)%s+(%S+)")
		if cmd and cmd == cmd2 and nick then
			if BlockedNicks[strlower(nick)] then
				BlockedNicks[strlower(nick)] = nil
				curUser:SendPM(sBot, nick.." is now unblocked. Now he can upload to anyone.")
				return 1
			end
		elseif cmd and cmd == cmd1 then
			if BlockedNicks[strlower(nick)] == 1 then
				curUser:SendPM(sBot, nick.." is already blocked. Use !del  to unblock this user.")
			else
				BlockedNicks[strlower(nick)] = curUser.sName
				curUser:SendPM(sBot, nick.." is now blocked. Now he only uploads to registered users.") 
			end
			if (uLaterPtokax == 1) then OnExit() end
			return 1
		elseif (cmd and cmd == cmd3 and curUser.bOperator) then
			local sTmp,aux,nick = "Upload Blocker Users in this HUB:\r\n\r\n"
			for nick, aux in BlockedNicks do
				sTmp = sTmp.."User:-->> "..nick.."\t Was Blocked by: "..aux.."\r\n"
			end
			curUser:SendPM(sBot, sTmp)
			return 1
		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 format("[%q]",key) or format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and 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)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end
Best regards,

jiten

witch

jiten & [UK]Madman U ROCKS guys!!!

BIG thx to ya for this script from me and ALL my OPs !!!

tested and works GREAT   :D



jiten

Anytime :]
It's nice to know that finally it's working as expected.

Cheers

SMF spam blocked by CleanTalk