PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Finished Scripts => Topic started by: Daywalker? on 03 March, 2008, 22:56:56

Title: BadSearch.lua [API 2]
Post by: Daywalker? on 03 March, 2008, 22:56:56
--[[
03-03-2008

BadSearch LUA 5.13 [API 2] made by Daywalker?

        Updated from the old crusifix script so some code parts are based on badsearch by Mutor

]]
BlCfg = {
-- Botname pulled from the hub or use "Custom-Name"
Bot = SetMan.GetString(21),
-- File to Check users for bad search
EvulSearch = "badfiles.txt",
}

OnError = function(msg)
Core.SendToOps("<"..BlCfg.Bot.."> "..msg.."|")
end

OnStartup = function()
BlCfg.Path = string.gsub(Core.GetPtokaXPath().."scripts/","/","\\")
BlCfg.EvulSearch = BlCfg.Path..BlCfg.EvulSearch
gc,no = nil,table.getn
if _VERSION ~= "Lua 5.1" then
return OnError("Error! This script is incompatible with ".._VERSION), true
end
if loadfile(BlCfg.EvulSearch) then
dofile(BlCfg.EvulSearch)
Core.SendToOps("<"..BlCfg.Bot.."> *** EvulSearch List loaded....|")
end
OnError("*** BadSearch.lua for ".._VERSION.." by Daywalker? has been started. Beware!!...")
end

OnExit = function()
OnError("*** BadSearch.lua for ".._VERSION.." by Daywalker? has been stopped. cYa...")
end

function SearchArrival(user,data)
Core.GetUserAllData(user)
if user.iProfile == -1 or not ProfMan.GetProfile(user.iProfile).tProfilePermissions.bIsOP then
local s,e,search = string.find(data, "$Search %S+%s%S+?%S+?%S+?%S+?(.*)|")
for bah,key in pairs(BlCfg.sBadFiles["bad"]) do 
for oke,key in pairs(BlCfg.sBadFiles["good"]) do
if string.find(search,oke) then
return false
end
if string.find(search,bah) then
local res = "Unknown Path: "..string.char(92)..user.sNick..", you are forbidden "..
"to search for *"..search.." *. "..string.rep(" ",350)..search
Core.SendToOps("<"..BlCfg.Bot.."> \r\n\r\n\t\t\t*** Please Check this user!! :\r\n\r\n\t\t\t*** UserName: "..user.sNick..
"\r\n\t\t\t*** with IP: "..user.sIP..
"\r\n\t\t\t*** with Tag: "..(user.sTag or "N/A")..
"\r\n\t\t\t*** This user is maybe searching for "..
"forbidden files: \r\n\t\t\t*** SearchString: * "..search.." *. "..string.rep(" ",350)..
"\r\n\t\t\t*** Keyword: "..bah..
"\r\n\t\t\t*** Judge by your feeling as an OP\r\n")
return true
end
end
end
end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end

--[[

save the stuff below as badfiles.txt

BlCfg.sBadFiles = {
["good"] = {
["TTH:"] = 1,
["nirvana"] = 1,
["16 bit"] = 1,
["mp3"] = 1,
["Mannerheim"] = 1,
["alizee"] = 1,
},
["bad"] = {
["doggyfuck"] = 1,
["childporn"] = 1,
["childsex"] = 1,
["dephile"] = 1,
["preteen"] = 1,
["r@ygold"] = 1,
["beastiality"] = 1,
["stealthdc"] = 1,
["animalsex"] = 1,
["beastiality"] = 1,
["incest"] = 1,
["rape"] = 1,
["underage"] = 1,
["qwerty"] = 1,
["kiddyporn"] = 1,
["faces of death"] = 1,
["hubflooder"] = 1,
},
}

]]


untested :)   

edit // fixed the SendToOps error  ^^
Title: Re: BadSearch.lua [API 2]
Post by: [NL]Daddy-Bear? on 28 March, 2008, 19:11:32
Hello it?s me again.

Getting this error in main:  BadSearch LUA .lua:42: bad argument #1 to 'find' (string expected, got nil)
>>>  Note line 42 is: if string.find(search,oke) then  <<<
No errors in PX.

Respectfully,

[NL]Daddy-Bear?
Title: Re: BadSearch.lua [API 2]
Post by: Daywalker? on 28 March, 2008, 20:25:17
you did read the whole script?.....

"save the stuff below as badfiles.txt"

if this is not the problem then pls more info required ^^
Title: Re: BadSearch.lua [API 2]
Post by: Daywalker? on 29 March, 2008, 12:07:53
Re: BadSearch 1b.lua [API 2]

--[[
28-03-2008

BadSearch 1b LUA 5.13 [API 2] made by Daywalker?

Updated from the old crusifix script so some code parts are based on badsearch by Mutor

Fixed the search error and updated a few things tnx to Mutor :)


]]
--------------------- Settings -----------------------
--"Botname" ["" = Default Hub Bot]
local Bot = ""
--------------------------------------------------------

OnStartup = function()
Set=function(a,v,h)--(arg,val,hub)
if a == "" then
if h then
return SetMan.GetString(v)
else
return v
end
else
return a
end
end
Bot = Set(Bot,21,true)
EvulSearch = "badfiles.txt"
Path = string.gsub(Core.GetPtokaXPath().."scripts/","/","\\")
EvulSearch = Path..EvulSearch
if _VERSION ~= "Lua 5.1" then
return OnError("Error! This script is incompatible with ".._VERSION), true
end
if loadfile(EvulSearch) then
dofile(EvulSearch)
Core.SendToOps("<"..Bot.."> *** EvulSearch List loaded....|")
else
sBadFiles = {["good"] = {["TTH:"] = 1,["nirvana"] = 1,["16 bit"] = 1,["mp3"] = 1,["Mannerheim"] = 1,["alizee"] = 1,},
["bad"] = {["doggyfuck"] = 1,["childporn"] = 1,["childsex"] = 1,["dephile"] = 1,["preteen"] = 1,
["r@ygold"] = 1,["beastiality"] = 1,["stealthdc"] = 1,["animalsex"] = 1,["beastiality"] = 1,["incest"] = 1,
["rape"] = 1,["underage"] = 1,["qwerty"] = 1,["kiddyporn"] = 1,["faces of death"] = 1,["hubflooder"] = 1,},}
Save_File(EvulSearch,sBadFiles,"sBadFiles")
Core.SendToOps("<"..Bot.."> *** No EvulSearch List Found... Creating New One...|")
end
OnError("*** BadSearch 1b.lua for ".._VERSION.." by Daywalker? has been started. Beware!!...")
end

OnExit = function()
OnError("*** BadSearch 1b.lua for ".._VERSION.." by Daywalker? has been stopped. cYa...")
end

function SearchArrival(user,data)
Core.GetUserAllData(user)
if user.iProfile == -1 or not ProfMan.GetProfile(user.iProfile).tProfilePermissions.bIsOP then
local s,e,search = string.find(data, "$Search %S+%s%S+?%S+?%S+?%S+?(.*)|")
if search then
for oke,key in pairs(sBadFiles["good"]) do
if string.find(search,oke) then return false end
end
for bah,key in pairs(sBadFiles["bad"]) do 
if string.find(search,bah) then
local res = "Unknown Path: "..string.char(92)..user.sNick..", you are forbidden "..
"to search for *"..search.." *. "..string.rep(" ",350)..search
Core.SendToOps("<"..Bot.."> \r\n\r\n\t\t\t*** Please Check this user!! :\r\n\r\n\t\t\t*** UserName: "..user.sNick..
"\r\n\t\t\t*** with IP: "..user.sIP..
"\r\n\t\t\t*** with Tag: "..(user.sTag or "N/A")..
"\r\n\t\t\t*** This user is maybe searching for "..
"forbidden files: \r\n\t\t\t*** SearchString: * "..search.." *. "..string.rep(" ",350)..
"\r\n\t\t\t*** Keyword: "..bah..
"\r\n\t\t\t*** Judge by your feeling as an OP\r\n")
return true
end
end
end
end
end

OnError = function(msg)
Core.SendToOps("<"..Bot.."> "..msg.."|")
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:flush()
hFile:close()
collectgarbage("collect")
end


// changed and updated some things to avoid as many errors as possible at startup :)
Title: Re: BadSearch.lua [API 2]
Post by: [NL]Daddy-Bear? on 31 March, 2008, 21:40:05
Hello it?s me again.

Hello Daywalker?

Just a suggestion won?t be better to replace

if string.find(search,bah) then
local res = "Unknown Path: "..string.char(92)..user.sNick..", you are forbidden "..
"to search for *"..search.." *. "..string.rep(" ",350)..search
Core.SendToOps("<"..BlCfg.Bot.."> \r\n\r\n\t\t\t*** Please Check this user!! :\r\n\r\n\t\t\t*** UserName: "..user.sNick..

In to:
if string.find(search,bah) then
local res = "Unknown Path: "..string.char(92)..user.sNick..", you are forbidden "..
"to search for *"..search.." *. "..string.rep(" ",350)..search
Core.SendToNick(user.sNick,"<"..SetMan.GetString(21)..">"..res.."")  --  added !!
Core.SendToOps("<"..BlCfg.Bot.."> \r\n\r\n\t\t\t*** Please Check this user!! :\r\n\r\n\t\t\t*** UserName: "..user.sNick..


User get now the ?local res? send to him.   ;D

Respectfully,

[NL]Daddy-Bear?
Title: Re: BadSearch.lua [API 2]
Post by: Daywalker? on 31 March, 2008, 22:07:47
Well if you want that message get to the user then do it in pm for notice..

by Core.SendPmToUser(user,Bot,res)

for ex. local res = "Unknown Path: "..string.char(92)..user.sNick..", you are forbidden "..
"to search for *"..search.." *. "..string.rep(" ",350)..search
Core.SendPmToUser(user,Bot,res)


:)