in lua 4
--100% Blocker by chill
--Table Load and Save (added by nErBoS)
sBot = "[fow]-Leech"
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 "..conNick.." 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 "..conNick.." 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
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
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.."\t Was Blocked by: "..aux.."\r\n"
end
--curUser:SendPM(sBot, sTmp)
SendPmToOps(OpChatName, 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
thanks a lot dudes if you can fix this
hehehe yeah i know this script too,
i think it needs to be transferred to lua5
Check this thread (http://board.univ-angers.fr/thread.php?threadid=4001&boardid=13&sid=6720ec7e7b152997efb8781b089e6709).
Best regards.