PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Optimus on 27 November, 2003, 16:40:32

Title: - Personal DownloadBlocker -
Post by: Optimus on 27 November, 2003, 16:40:32
Hi guy's

I want to have a Download bloker...

Ok what is different?

It must only Block persons that are on a list (Table)

Example:

BlockMeArray = {}

if !blockme then put me on the Block list so others can't download from me.

if !unblockme i will be removed from the list and people can download from me again.

I have tryed myself but without the results *lol*

Btw, for me it's usefull to have it for OP's only

For more Info just post  ;)


Title: yop...
Post by: Fire Koboy on 27 November, 2003, 16:47:31
That's just the script I asked for a couple of days....
I'm too much interested for my OP to...
Title:
Post by: pHaTTy on 27 November, 2003, 16:55:07
Hmmm i actually put some thought into that other week, but, i cant come up with anything at the moment, well anythink that will work that is, atm i dont think it is possible form the server :/
Title:
Post by: SaintSinner on 27 November, 2003, 17:11:46
how about modifying the leechblocker.
Title:
Post by: Optimus on 27 November, 2003, 18:05:55
Thx guy's,, still hope some 1 will have a briljant Idea... :]
Title:
Post by: pHaTTy on 27 November, 2003, 19:10:57
Hmmm i think i got it :))))


ok when use a command it get user my name do a function and grab user by

user = GetItemByName(whatever)

then using the leechblocker (modded)

you can block the user yep, but means it will block that user to all :/

ARRF I AINT :/


hmm unless if connect to blahblahg check file if the users name is in that file then block conenct to me thingy else return 0 :))) that wud work yep :))
Title: nop...
Post by: Fire Koboy on 27 November, 2003, 19:23:02
I don't understand well (uk-kingdom)pH?tt? ...
Could do write me a script...and explain it a lil bit for me pliz...Lua is hard to learn...and you seem to control it so good....
I wud thank you so much to help me...
I could help you to learn french ...:) lol
Thanx
Title:
Post by: pHaTTy on 27 November, 2003, 19:42:04
Hmm bugga, hmmm maybe someone else wiv the idea i got can, i bissy with many script atm, had only popped in with the idea srry :/

ir wud also take alot tme,,

srry agen maybe Opium will understand me and give it a shot :))

au revoir

-phatty
Title:
Post by: honda on 14 September, 2004, 14:56:39
Hello

I search that script to.. To block a person only for all OP's but not the users and vips and regs.
Does any one have that sort of script??

Greetings Honda
Title:
Post by: bastya_elvtars on 14 September, 2004, 15:13:52
this really cuts into users' freedom i guess. i do not like to use this. If a user is a rulesbreaker, then kick/ban. No other things have effect.
Title:
Post by: ARCHANGEL on 14 September, 2004, 16:16:06
The idea of DC is to share, I am growing very tired of seeing all these upload/download blockers. The ironic thing is this, you kick and ban people who use a speed limiter, yet it's okay for you to totally block?


  The word hypocrite springs to mind

To block everybody but OPs?

  What makes you so special?
That is no better than leeching with a superiority complex


You kick and ban leechers remember, isn't that what you are doing?


  Think about it, when you block sharing you are putting another nail in the coffin of DC.
Title:
Post by: honda on 14 September, 2004, 16:33:30
I only want to block one person!! Not everybody..
There are very much leechblockers but the block the other way.. If you are not reg then no download....
Title:
Post by: Skyhawk on 25 September, 2004, 13:40:45
Great Script...

However i have a small request:

Can you add...

1.  A botname so one can enter those commands in a PM with the bot.

2. A function that saves & loads those blocked nicks to & from a file. eg. blocked.dat


Thx in advance.
Title:
Post by: Skyhawk on 30 September, 2004, 21:56:07
HELLO ???
Title:
Post by: nErBoS on 30 September, 2004, 22:22:09
Hi,

Done...

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

sBot = "BLOCK-BOT"

cmd1 = "+blocknick"

BlockedNicks = {}
fBlock = "block.dat"

--## 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 = {
["$Rev"] = 1,
["$Con"] = 2,
}

function DataArrival(curUser,data)
if strsub(data,1,1) == "$" then
local str1 = strsub(data,1,4)
if BlockTriggs[str1] then
if BlockedNicks[strlower(curUser.sName)] then
curUser:SendData("*** You are not authorized to download.")
return 1
elseif BlockTriggs[str1] == 1 then
local _,_,conNick = strfind(data,"(%S+)|$")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user you are trying to download from is not authorized to upload.")
return 1
end
elseif BlockTriggs[str1] == 2 then
local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user you are trying to download from is not authorized to upload.")
return 1
end
end
end
end
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 == cmd1 and nick then
if BlockedNicks[strlower(nick)] then
BlockedNicks[strlower(nick)] = nil
curUser:SendData("*** "..nick.." is now unblocked.")
else
BlockedNicks[strlower(nick)] = 1
curUser:SendData("*** "..nick.." is now blocked.")
end
if (uLaterPtokax == 1) then
OnExit()
end
return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
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, nErBoS
Title:
Post by: bastya_elvtars on 30 September, 2004, 22:24:39
QuoteOriginally posted by Skyhawk
HELLO ???

patience m8 plz

this is a board, not a supermarket :evil:
Title:
Post by: Skyhawk on 30 September, 2004, 22:26:06
hehe


sorry

i was just too anxoius

MANY THANKS
Title:
Post by: Skyhawk on 30 September, 2004, 22:32:02
does not work
Title:
Post by: nErBoS on 01 October, 2004, 00:24:16
Hi,

I think that you were talking about the commands i have fixed the script above.

Best regards, nErBoS
Title:
Post by: Skyhawk on 01 October, 2004, 00:36:18
I've now copied the script  from above but it wouldn't work   the bot doesn't even give any reaction
Title:
Post by: nErBoS on 01 October, 2004, 01:07:25
Hi,

I have fixed and test it, try it now.

Best regards, nErBoS
Title:
Post by: Skyhawk on 01 October, 2004, 01:46:43
It seems to work. However the table isn't saved until i manually restart the scripts. So therefore some small additional requests

1. Could you alter the script so that the table is saved directly after the +blocknick commmand is executed?

2. And maybe instead of Showing a short message in the mainchat could you do it that the bot answers in a PM to the one entering the command?

3. Finally could you alter the script so that only Masters (Profile number 0) can use this command since this is a very powerfull bot although tiny?


Many many thanks to the grandmaster of LUA
Title:
Post by: Skyhawk on 01 October, 2004, 01:54:21
well i figured request 2 out by myself...

i just replaced this:

curUser:SendData("*** "..nick.." is now unblocked.")

with this:

curUser:SendPM(sBot, nick.." is now unblocked.")



Thanks to you i am really starting to learn LUA
Title:
Post by: Skyhawk on 01 October, 2004, 02:01:13
well maybe it isn't neccessary in ptokax > 0.3.3.0 to save the table after command?

Title:
Post by: nErBoS on 01 October, 2004, 02:37:06
Hi,

1) I assume that you are using the ptokax 0.3.3.0, the function OnExit works when you are shutting down the software or restarting the script, this function only existes on 0.3.3.0, then i made a configuration set for you to choose each ptokax version you are using, then if you want to save the table every time it has a change just put uLaterPtokax = 1 (it will act like you were using a Test Drive). But like you did is also possible  ;)

2) That's a start to learn LUA like you said. I have start by translating scripts, then i have start to put togheter some scripts, then i have start to make my own scripts. Good Luck if you are realy interested in learning LUA.

3) Just change this line ....

Quoteif (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.bOperator then

for this...

Quoteif (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and user.iProfile == 0 then

I have bolded the changrd parts to you understand  ;)

Best regards, nErBoS
Title:
Post by: BoJlk on 01 October, 2004, 09:17:53
Is it possible to make this script to block from user on my hub downloading from me.

It's important to preserve the Upload bandwidth...
Title:
Post by: honda on 01 October, 2004, 10:49:35
Hello

I saw the option to send the message in PM.

curUser:SendPM(sBot, nick.." is now unblocked.")

But what is the command for in Opchat.. Then every Op knows it....
Title:
Post by: Skyhawk on 01 October, 2004, 11:31:41
SendPmToOps
Title:
Post by: Skyhawk on 01 October, 2004, 11:47:12
QuoteOriginally posted by nErBoS

3) Just change this line ....

Quoteif (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.bOperator then

for this...

Quoteif (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and user.iProfile == 0 then

I have bolded the changrd parts to you understand  ;)

Best regards, nErBoS


If i do this then the script doesn't work anymore (i.e. the bot doesn't reply eg  ... has been blocked.



I am using PtokaX DC Hub 0.3.3.0 build 15.25 [debug]

if you have any other version higher than that please tell me
Title:
Post by: bastya_elvtars on 01 October, 2004, 11:51:02
QuoteOriginally posted by BoJlk
Is it possible to make this script to block from user on my hub downloading from me.

It's important to preserve the Upload bandwidth...

don't share anything
Title:
Post by: honda on 01 October, 2004, 13:12:46
hello me again

SendPmToOps that works.. But what i mean was..
How can i get the message in Opchat??
Its handy that  i can send to Ops but in Opchat is better way for me.


Sorry for the bad english
Title:
Post by: nErBoS on 01 October, 2004, 13:33:42
Hi,

Honda try out this...

SendPmToNick("YOUR_OPCHAT_NAME", sBot, nick.." is now unblocked.")
Skyhawk, sorry wrong table, try this one...

Quoteif (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) and curUser.iProfile == 0 then

Best regards, nErBoS
Title:
Post by: honda on 01 October, 2004, 15:59:58
hello Nerbos

Thnx for the info..
I have tried it. And when i set my nick in it or a other persons nick no problem it works.. But when i do the Opchat name nothing..
Can there be a problem with rights??

The profiles working good..

Greetings..
Title:
Post by: nErBoS on 01 October, 2004, 22:36:52
Hi,

Try out this one then...

SendPmToOps("YOUR_OPCHAT_NAME", nick.." is now unblocked.")
like Skyhawk has sugested.

Best regards, nErBoS
Title:
Post by: honda on 02 October, 2004, 01:04:52
Works great Mutor..

Thanks for the help everybody..
Title:
Post by: honda on 02 October, 2004, 19:53:02
Hello

I have added a extra command !unblock. And it works.
A little cut and paste work.

But i have a problem that ik can't solve by myself.

How can i make a !showblock. Then you can see who are blocked.
The Operators and higher can use this command.
Can someone help me with this??
This is the scirpt..

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

sBot = "BLOCK-BOT"

cmd1 = "!block"
cmd2 = "!unblock"
--cmd3 = "!showblock"


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


--## Configuration ##--

uLaterPtokax = 1 -- 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 = {
["$Rev"] = 1,
["$Con"] = 2,
}

function DataArrival(curUser,data)
if strsub(data,1,1) == "$" then
local str1 = strsub(data,1,4)
if BlockTriggs[str1] then
if BlockedNicks[strlower(curUser.sName)] then
curUser:SendData("*** You are not authorized to download.")
return 1
else if BlockTriggs[str1] == 1 then
local _,_,conNick = strfind(data,"(%S+)|$")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user ..nick.. you are trying to download from is not authorized to upload.")
return 1
end
else if BlockTriggs[str1] == 2 then
local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user ..nick.. you are trying to download from is not authorized to upload.")
return 1
end
end
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
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
SendPmToOps(OpChatName, nick.." is now unblocked.")
return 1
end
else if cmd and cmd == cmd1 then
if BlockedNicks[strlower(nick)] == 1 then
curUser:SendPM(sBot, nick.." is already blocked. Use !unblock to unblock this user.")
return 1
else
BlockedNicks[strlower(nick)] = 1
SendPmToOps(OpChatName, nick.." is now blocked.")
return 1
end
if (uLaterPtokax == 1) then
OnExit()
end

return 1  -- TELLS THE HUB TO STOP PROCESSING THE DATA
end
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
Title:
Post by: nErBoS on 02 October, 2004, 23:16:46
Hi,

Try this...

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

sBot = "BLOCK-BOT"

cmd1 = "!block"
cmd2 = "!unblock"
cmd3 = "!showblock"


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


--## Configuration ##--

uLaterPtokax = 1 -- 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 = {
["$Rev"] = 1,
["$Con"] = 2,
}

function DataArrival(curUser,data)
if strsub(data,1,1) == "$" then
local str1 = strsub(data,1,4)
if BlockTriggs[str1] then
if BlockedNicks[strlower(curUser.sName)] then
curUser:SendData("*** You are not authorized to download.")
return 1
else if BlockTriggs[str1] == 1 then
local _,_,conNick = strfind(data,"(%S+)|$")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user ..nick.. you are trying to download from is not authorized to upload.")
return 1
end
else if BlockTriggs[str1] == 2 then
local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user ..nick.. you are trying to download from is not authorized to upload.")
return 1
end
end
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
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
SendPmToOps(OpChatName, nick.." is now unblocked.")
return 1
end
elseif cmd and cmd == cmd1 then
if BlockedNicks[strlower(nick)] == 1 then
curUser:SendPM(sBot, nick.." is already blocked. Use !unblock to unblock this user.")
return 1
else
BlockedNicks[strlower(nick)] = 1
SendPmToOps(OpChatName, nick.." is now blocked.")
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 = "Users Blocked in this HUB:\r\n\r\n"
for nick, aux in BlockedNicks do
sTmp = sTmp.."User: "..nick.."\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, nErBoS
Title:
Post by: honda on 03 October, 2004, 20:52:27
Hello Nerbos

I have tried it. But getting nothing.. with !showblock

No error of something like that. I tried some changes but no hope..
Title:
Post by: nErBoS on 03 October, 2004, 21:36:14
Hi,

I have fixed that in the script above.

Best regards, nErBoS
Title:
Post by: honda on 04 October, 2004, 09:52:29
Hi

I have tried that script above bot isn't working or i do something wrong  :)) .

That's why my question.. I have tried many thing with the script above..

Greetings

honda
Title:
Post by: nErBoS on 04 October, 2004, 13:41:17
Hi,

I have tried and the script is working fine. What is not working ?? Do you have any error on the script editor of your ptokax ???

Best regards, nErBoS
Title:
Post by: honda on 05 October, 2004, 12:04:47
Oke will test every thing tonight.. The big problem was   !showblock maybe i will change the name to something else.. Maybe that is the problem..

Greetings honda

Thnx voor response
Title:
Post by: nErBoS on 05 October, 2004, 12:39:55
Hi,

No problem on changing the command name for another command name, just need to change here...

cmd3 = "!showblock"
Best regards, nErBoS
Title: leech blokker
Post by: johnynl on 05 October, 2004, 23:38:41

well this is what we got till this far now but the next part of the script does not give any error at all
also no text in any screen at all
plz help us out
Title:
Post by: honda on 05 October, 2004, 23:50:09
Hello

I try every thing.. But the show command is not working.. I can block and unblock ppl. But when i try !showblock or !please.. its not working.

The strange thing is no error on the ptokax software.. of that there is fault in data arrival or something.

It looks that it works good but i getting no pm with the names of de blocked ppl..

Kind regards Honda
Title:
Post by: nErBoS on 06 October, 2004, 00:32:47
Hi,

Honda...

The command will only work with a Master, not to OP.

johnynl...

change this...

SendPMToOps(OpChatName, sTemp)
to this...

SendPMToOps(OpChatName, sTmp)
Best regards, nErBoS
Title:
Post by: honda on 06 October, 2004, 14:02:56
Thnx nerbos

Its working now.. With master en netfounder..

Nice work..  :D
Title:
Post by: johnynl on 06 October, 2004, 14:21:15
Yep great man.
but we still got one question:
is ot posible to add the name to the file who put the block?
would be a nice option to see that too, so we can take action if someone put's to many ppl on block

many thank for this script so far from our ops and me.
Title:
Post by: nErBoS on 06 October, 2004, 14:33:18
Hi,

Here you have...

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

sBot = "BLOCK-BOT"

cmd1 = "!block"
cmd2 = "!unblock"
cmd3 = "!showblock"


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


--## Configuration ##--

uLaterPtokax = 1 -- 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 = {
["$Rev"] = 1,
["$Con"] = 2,
}

function DataArrival(curUser,data)
if strsub(data,1,1) == "$" then
local str1 = strsub(data,1,4)
if BlockTriggs[str1] then
if BlockedNicks[strlower(curUser.sName)] then
curUser:SendData("*** You are not authorized to download.")
return 1
else if BlockTriggs[str1] == 1 then
local _,_,conNick = strfind(data,"(%S+)|$")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user "..nick.." you are trying to download from is not authorized to upload.")
return 1
end
else if BlockTriggs[str1] == 2 then
local _,_,conNick = strfind(strsub(data,14,strlen(data)),"^(%S+)")
if BlockedNicks[strlower(conNick)] then
curUser:SendData("*** The user "..nick.." you are trying to download from is not authorized to upload.")
return 1
end
end
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
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
SendPmToOps(OpChatName, nick.." is now unblocked.")
return 1
end
elseif cmd and cmd == cmd1 then
if BlockedNicks[strlower(nick)] == 1 then
curUser:SendPM(sBot, nick.." is already blocked. Use !unblock to unblock this user.")
return 1
else
BlockedNicks[strlower(nick)] = curUser.sName
SendPmToOps(OpChatName, nick.." is now blocked.")
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 = "Users Blocked in this HUB:\r\n\r\n"
for nick, aux in BlockedNicks do
sTmp = sTmp.."User: "..nick.."\tBlocked 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

BEWARE: If you use this script you must delete your "block.dat" because this will save the table with the nick of the person who blocked.

Best regards, nErBoS
Title:
Post by: honda on 06 October, 2004, 21:02:17
Cool.. Work Nerbos..

I have just make one adjustment  at this place

BlockedNicks[strlower(nick)] = user.sName

to this

BlockedNicks[strlower(nick)] = curUser.sName

Then it works great..
Title:
Post by: Psycho_Chihuahua on 06 October, 2004, 21:45:33
missing a set of "'s as well


curUser:SendData("*** The user ..nick.. you are trying to download from is not authorized to upload.")


changeto

curUser:SendData("*** The user "..nick.." you are trying to download from is not authorized to upload.")

^^
Title:
Post by: nErBoS on 07 October, 2004, 00:06:53
Hi,

I have corrected the script above, thank you both.

Best regards, nErBoS
Title:
Post by: charlie on 07 October, 2004, 08:54:53
hi all...

i tested it an it works fine... i only had one mistake... the file fBlock = "block.dat" will not be created... i tested it with uLaterPtokax = 1 and with uLaterPtokax = 0

Is this only by me?
Title:
Post by: honda on 07 October, 2004, 14:51:56
hello

Change another thing..

curUser:SendData("*** The user "..nick.." you are trying to download from is not authorized to upload.")

to this

curUser:SendData("*** The user "..conNick.." you are trying to download from is not authorized to upload.")

greetings
Title:
Post by: charlie on 07 October, 2004, 16:12:50
thx for the tip honda...

but it don?t work... i can do what i want there is no file...

and after restart scripts/hub no user is blocked
Title:
Post by: honda on 07 October, 2004, 16:19:18
The block.dat will come in the srcipt dir.

Normaly if you do !block then the block.dat. will make it self.

I don't know what the problem can be.  You have Ptokax ??
Title:
Post by: nErBoS on 08 October, 2004, 00:43:53
Hi,

charlie....

If you have uLaterPtokax = 1 the table is saved in the file every time you block or unblock someone.

Best regards, nErBoS
Title:
Post by: angelsanges on 11 September, 2005, 23:50:34
it can be converted to LUA 5?