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 ;)
That's just the script I asked for a couple of days....
I'm too much interested for my OP to...
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 :/
how about modifying the leechblocker.
Thx guy's,, still hope some 1 will have a briljant Idea... :]
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 :))
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
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
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
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.
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.
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....
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.
HELLO ???
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
QuoteOriginally posted by Skyhawk
HELLO ???
patience m8 plz
this is a board, not a supermarket :evil:
hehe
sorry
i was just too anxoius
MANY THANKS
does not work
Hi,
I think that you were talking about the commands i have fixed the script above.
Best regards, nErBoS
I've now copied the script from above but it wouldn't work the bot doesn't even give any reaction
Hi,
I have fixed and test it, try it now.
Best regards, nErBoS
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
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
well maybe it isn't neccessary in ptokax > 0.3.3.0 to save the table after command?
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
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...
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....
SendPmToOps
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
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
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
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
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..
Hi,
Try out this one then...
SendPmToOps("YOUR_OPCHAT_NAME", nick.." is now unblocked.")
like Skyhawk has sugested.
Best regards, nErBoS
Works great Mutor..
Thanks for the help everybody..
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
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
Hello Nerbos
I have tried it. But getting nothing.. with !showblock
No error of something like that. I tried some changes but no hope..
Hi,
I have fixed that in the script above.
Best regards, nErBoS
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
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
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
Hi,
No problem on changing the command name for another command name, just need to change here...
cmd3 = "!showblock"
Best regards, nErBoS
--100% Blocker by chill
--Table Load and Save (added by nErBoS)
sBot = "BLOCK-BOT"
cmd1 = "!block"
cmd2 = "!unblock"
cmd3 = "!laatzien"
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 = {
["$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.")
SaveToFile(fBlock , BlockedNicks , "BlockedNicks") ---------
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.")
SaveToFile(fBlock , BlockedNicks , "BlockedNicks") ---------
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
LoadFromFile(file) -------
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)
SendPMToOps(OpChatName, sTemp)
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
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
elseif (cmd and cmd == cmd3 and curUser.bOperator) then
LoadFromFile(file) -------
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)
SendPMToOps(OpChatName, sTemp)
return 1
end
plz help us out
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
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
Thnx nerbos
Its working now.. With master en netfounder..
Nice work.. :D
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.
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
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..
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.")
^^
Hi,
I have corrected the script above, thank you both.
Best regards, nErBoS
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?
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
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
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 ??
Hi,
charlie....
If you have uLaterPtokax = 1 the table is saved in the file every time you block or unblock someone.
Best regards, nErBoS
it can be converted to LUA 5?