PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: witch on 22 April, 2005, 14:35:10

Title: Download blocker
Post by: witch on 22 April, 2005, 14:35:10
Hola amigos!
Was looking thrue forum, but could'n find solution of my problem. I want to make downloads from me avalible ONLY for regs and above.
Don't know what can help me, script or different client. Now i'm on 0.401 and hub runs on 0.3.3.0.b16.09 powered by RC 10.01c

thx on advince  :))
Title: download blocker
Post by: damo on 22 April, 2005, 15:18:07
why not use the blocker in robo so that only redistered users can download
Title:
Post by: jiten on 22 April, 2005, 15:26:36
If I understood ur request, here it is:
-- requested by witch
-- unreg users upload blocker by jiten
-- modded to LUA 5 by jiten from
-- 100% Blocker by chill
-- Table Load and Save (added by nErBoS)


sBot = "[fow]-Leech"

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

BlockedNicks = {}
fBlock = "block.dat"

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

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

function ConnectToMeArrival(curUser,data)
local _,_,conNick = string.find(data,"(%S+)|$")
if BlockedNicks[string.lower(conNick)] then
if not curUser.bRegistered then
curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload to Unreg Users.")
return 1
else
end
end
local _,_,conNick = string.find(string.sub(data,14,string.len(data)),"^(%S+)")
if BlockedNicks[string.lower(conNick)] then
if not curUser.bRegistered then
curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload to Unreg Users.")
return 1
else
end
end
end

RevConnectToMeArrival = ConnectToMeArrival

function ChatArrival(curUser,data)
if curUser.bOperator then
data = string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
local _,_,nick = string.find(data,"%b<>%s+%S+%s+(%S+)")
if cmd and cmd == cmd2 and nick then
if BlockedNicks[string.lower(nick)] then
BlockedNicks[string.lower(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[string.lower(nick)] == 1 then
curUser:SendPM(sBot, nick.." is already blocked. Use !del to unblock this user.")
return 1
else
BlockedNicks[string.lower(nick)] = curUser.sName
curUser:SendPM(sBot, nick.." is now blocked. Now he only uploads to registered users.")
return 1
end
OnExit()
return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
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

ToArrival = ChatArrival

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
                dofile(file)
handle:flush()
handle:close()
        end
end

*EDIT* Small fix
*EDIT 2* Fixed problem with passive users
Cheers
Title:
Post by: witch on 22 April, 2005, 23:21:41
Thx a lot jiten dude, didn't tested yet....but looks exact what i need. If any errors i will get, i 'll let ya know.

emm 4 got to ask, can u convert this script to lua 4 as well? i also running hub on old ptokax and will be cool to have it there too....

thx man  :D
Title:
Post by: jiten on 23 April, 2005, 10:28:32
QuoteOriginally posted by witch
Thx a lot jiten dude, didn't tested yet....but looks exact what i need. If any errors i will get, i 'll let ya know.

emm 4 got to ask, can u convert this script to lua 4 as well? i also running hub on old ptokax and will be cool to have it there too....

thx man  :D
ym m8 :]
I'll have a look at this one and post the Lua 4 version l8r... maybe at night.

Best regards,

jiten
Title:
Post by: jiten on 24 April, 2005, 13:51:41
Here you go (not fully tested):
-- requested by witch
-- unreg users upload blocker by jiten (lua 4 version)
--100% Blocker by chill
--Table Load and Save (added 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"] = 1,
}

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
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 = strfind(data,"%b<>%s+(%S+)")
local _,_,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.")
return 1
else
BlockedNicks[strlower(nick)] = curUser.sName
curUser:SendPM(sBot, nick.." is now blocked. Now he only uploads to registered users.")
return 1
end
if (uLaterPtokax == 1) then
OnExit()
end

return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
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
*EDIT* Fixed problem with passive users
Cheers
Title:
Post by: ruler on 24 April, 2005, 15:16:21
sorry guys i saw this section and just had to comment!
ive used many download/search blockers and even totally disabled it for all users under to test something and found that there are still some users who are in passive mode that can still download and search!
one user in particular was named 'Komaland' who always got a slot from me even though he was NOT registered and was totally blocked, anyone know why this could be???  
thanks
Title:
Post by: witch on 24 April, 2005, 16:38:55
GRATE script jiten dude, works with no errors so far on bouth versions!!!

Thx a lot m8  :))

...but ja ruler was right some users in passive mode snickin a slot, damn what we can do about it m8  ?(
Title:
Post by: Dessamator on 24 April, 2005, 17:00:00
just change this ::

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


to this ::
BlockTriggs = {
["$Con"] = 1,
                ["$Rev"] = 1,
}
Title:
Post by: jiten on 24 April, 2005, 17:24:20
Well, I hope the bug is fixed now in both scripts.
Fast guy, hein Dessamator? :D

Cheers
Title:
Post by: Dessamator on 24 April, 2005, 17:39:11
lol, i just wrote that, i never tested it,  its all based on theory,:D,
Title:
Post by: witch on 24 April, 2005, 18:44:10
well bad luck guys, they r still coming even after fix  :rolleyes:
Title:
Post by: jiten on 24 April, 2005, 19:06:24
QuoteOriginally posted by witch
well bad luck guys, they r still coming even after fix  :rolleyes:
Well, maybe someone else can give us a hint...
Title:
Post by: Dessamator on 24 April, 2005, 19:23:48
lol
try adding::
BlockTriggs = {

["$Con"] = 1,
["$Rev"] = 1,
["$Mul"]=1,
}
 
Title:
Post by: witch on 24 April, 2005, 19:50:44
QuoteOriginally posted by Dessamator
lol
try adding::
BlockTriggs = {

["$Con"] = 1,
["$Rev"] = 1,
["$Mul"]=1,
}
 
still no luck Dessamator, they still coming  ;(
Title:
Post by: witch on 08 May, 2005, 11:49:24
it's 2 weeks since last post now and no replays  ;(

..so is it posseble to block downloads from passive users or not?

thx in advince
Title:
Post by: Pothead on 08 May, 2005, 11:58:54
QuoteOriginally posted by witch
it's 2 weeks since last post now and no replays  ;(

..so is it posseble to block downloads from passive users or not?

thx in advince
Easily. Switch to passive mode.  :D
Or block passive users from entering a hub.
Or block passive users sending a RevConnectToMe.
Title:
Post by: witch on 08 May, 2005, 12:10:58
QuoteOriginally posted by Pothead
QuoteOriginally posted by witch
it's 2 weeks since last post now and no replays  ;(

..so is it posseble to block downloads from passive users or not?

thx in advince
Easily. Switch to passive mode.  :D
Or block passive users from entering a hub.
Or block passive users sending a RevConnectToMe.
thx 4 replay Pothead!

- switched to passive: result: no1 can download from me, even regs and above...that's no good
- can't block passive from entering the hub, will loose half users.....hehhe
- but i didn't tryed this 1: plz tell me how to block passive users sending a RevConnectToMe

thx :))
Title:
Post by: Pothead on 08 May, 2005, 12:19:19
Write a script.
from Scripting-Interface.txt (you should READ these files)
RevConnectToMeArrival(User, Data)      - Incoming pasive connection request from user. If script return 1 hub don't process data.

So make a script when it receives RevConnectToMeArrival, checks the user is registered (i think this was the original request).  If the user is registered return 0, if unregistered return 1. :)

*** Edit, also do the same for:

SearchArrival(User, Data)         - Incoming search request from user. If script return 1 hub don't process data.

p.s. Are you trying the LUA 4 or LUA 5 script ?.
Title:
Post by: witch on 08 May, 2005, 12:32:54
yeah if i would be an scripter, i deffenetly would write it....but atfortunacly i'm not scripter  :rolleyes:
Title:
Post by: Pothead on 08 May, 2005, 12:43:57
Well for the above script (lua 5) try adding this at some point.
SearchArrival = ConnectToMeArrival
Title:
Post by: NightLitch on 08 May, 2005, 13:18:59
Well if I get some time I can see what I can do about it.

It is not hard at all.

Just make a table with the "Special" Users that shouldn't be accessable by Users ( -1 ) and check that in RevConnectToMeArrival and ConnectToMeArrival. And if even i search the SearchArrival.

Later
Title:
Post by: witch on 08 May, 2005, 13:49:47
thx man  :D
Title:
Post by: jiten on 08 May, 2005, 14:05:55
QuoteOriginally posted by NightLitch
Well if I get some time I can see what I can do about it.

It is not hard at all.

Just make a table with the "Special" Users that shouldn't be accessable by Users ( -1 ) and check that in RevConnectToMeArrival and ConnectToMeArrival. And if even i search the SearchArrival.

Later
In fact that's what the script should do, but, some unregistered passive users seem to get slots from the "special" ones even not being allowed to.
Maybe there's something missing...

Cheers
Title:
Post by: jiten on 08 May, 2005, 15:57:30
Here goes another attempt:
-- requested by witch
-- unreg users upload blocker by jiten
-- ideas from 100% Blocker by chill

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

RevConnectToMeArrival = ConnectToMeArrival
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
Best regards,

jiten
Title:
Post by: witch on 08 May, 2005, 22:38:04
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
Title:
Post by: jiten on 08 May, 2005, 22:49:40
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
Title:
Post by: witch on 09 May, 2005, 01:58:07
aha that's what i thout...hehe  

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

thx
Title:
Post by: jiten on 09 May, 2005, 08:02:55
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
Title:
Post by: witch on 09 May, 2005, 12:14:05
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:
Title:
Post by: [UK]Madman on 09 May, 2005, 16:42:31
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)
Title:
Post by: Pothead on 09 May, 2005, 16:46:33
Try being in only the hub where the script is running and see if they get a slot. :)
Title:
Post by: jiten on 09 May, 2005, 17:40:25
[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
Title:
Post by: witch on 09 May, 2005, 19:11:40
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
Title:
Post by: jiten on 10 May, 2005, 08:09:24
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
Title:
Post by: witch on 10 May, 2005, 12:10:24
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  ;)
Title:
Post by: jiten on 10 May, 2005, 12:48:04
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?
Title:
Post by: witch on 10 May, 2005, 13:25:05
QuoteOriginally posted by jiten
Just to confirm, the Lua 4 one posted in the previous page also has that passive bug, right?
right
Title:
Post by: jiten on 12 May, 2005, 16:21:02
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
Title:
Post by: witch on 12 May, 2005, 17:37:20
jiten & [UK]Madman U ROCKS guys!!!

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

tested and works GREAT   :D
Title:
Post by: jiten on 13 May, 2005, 16:25:38
Anytime :]
It's nice to know that finally it's working as expected.

Cheers