PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Stravides on 04 April, 2005, 12:23:51

Title: OpiumVolage Filechecker to LUA 5
Post by: Stravides on 04 April, 2005, 12:23:51
Whatever happened to EnableSearchData and how is that done now...

I have tried
     SRArrival
     SearchArrival
     UnknownArrival
     SupportArrival
     ChatArrival
     DataArrival

Just lost now....

i'm using the Searchkicker by OpiumVolage (http://board.univ-angers.fr/thread.php?threadid=5&boardid=12)

and I have (i think) converted the main, but it doesnt work :(

-- vim:ts=4:sw=4:noet
-- FileChecker.lua, rewrite of a 'SearchKick' bot for PtokaX by ptaczek and
-- Leon (called The Illegalist)
-- version 1.0 for DCH++
-- by Sedulus 20030910, requested by BSOD2600
-- 20030919: 1.0
--
-- Translated back to PtokaX (OpiumVolage 9 Sept. 2003)
-- Added timer for automating search
--
-- (using more mem (3 tables, instead of one) but less cpu)
--
-- searches for all terms in the SearchFor table,
-- sends a message to the user that he/she shares the file, with the response
-- message.
-- set disconnectUser to 1 if you want the user disconnected as well (not
-- recommended, as bots always seem to find a way to misinterpret data ;) )
--
-- spaces in the SearchFor table will be converted to dollar's, but they will
-- (purposely) only match if there's a space in the result later.
-- so "a b" won't match "b a" or "aXXXb"

--// useful stuff
botName = "FileChecker"
disconnectUser = nil -- disconnect the user, nil = don't

opchatName = nil -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
mb = 1024 * 1024
gb = 1024 * mb

timerValue = 10*1000 -- Every 10 seconds (higher value will reduce load)
useTimer = 1 -- set to 1 to enable timer functions
counter = 1

SearchTypes = {
ANY = 1,
AUDIO = 2,
COMPRESSED = 3,
DOCUMENT = 4,
EXECUTABLE = 5,
IMAGE = 6,
VIDEO = 7,
FOLDER = 8, -- do not use FOLDER's! the $SR's are formatted differently
}

st = SearchTypes
--// MODIFY THIS TABLE <-------
--      { searchType, words[, minimumSize[, regexMatch]] }
SearchFor = {
["Please don't share (pre)teen/incest/sick porn"] = {
{ st.IMAGE, "preteen" },
{ st.VIDEO, "preteen" },
{ st.IMAGE, "incest" },
{ st.VIDEO, "incest" },
{ st.IMAGE, "underage" },
{ st.VIDEO, "underage" },
{ st.IMAGE, "teenage sex" },
{ st.VIDEO, "teenage sex" },
},
["Please don't share ANY installed application nor any UNZIPPED installer!"] = {
{ st.ANY, "explorer.scf" },
{ st.ANY, "explore.ex_" },
{ st.ANY, "cd_clint.dll" },
{ st.EXECUTABLE, "express msimn.exe", 0, "express\\msimn%.exe$" },
{ st.EXECUTABLE, "IEXPLORE.EXE" },
{ st.ANY, "bfdist.vlu" },
{ st.ANY, "War3Inst.log" },
{ st.ANY, "ut2003.log" },
{ st.EXECUTABLE, "NFSHP2.exe" },
{ st.ANY, "avp2.rez" },
{ st.ANY, "ntuser.dat" },
{ st.EXECUTABLE, "winword.exe" },
{ st.ANY, "sav", 0, "%.sav$" },
{ st.ANY, "dll", 0, "%.dll$" },
{ st.ANY, "ex_", 0, "%.ex_$" },
{ st.EXECUTABLE, "setup.exe", 0, "\\setup%.exe$" },
},
["Do not share incomplete downloads!"] = {
{ st.ANY, "antifrag", 0, "antifrag$" },
{ st.ANY, "download dat", 0, "download[0-9]+%.dat$" },
},
["No, we don't allow uncompressed DVD's in here. Please os.remove all your VOB files"] = {
{ st.ANY, "VTS_01_0.VOB" },
},
["Please do not share large WAV files"] = {
{ st.AUDIO, ".wav", 30*mb, "wav$" },
},
["If you're sharing copies of your files to increase your share size, we are on to you"] = {
{ st.ANY, "copy of", 300*mb, "\\Copy of" },
{ st.ANY, "kopie van", 300*mb, "\\Kopie van" },
},
-- ["Please do not share unzipped DVD's and/or other large files. Use rar-sets."] = {
-- { st.ANY, ".", 1*gb },
-- },
}

--// convert the tables
SearchTable = {}
ResultTable = {}

function Main()
frmHub:EnableSearchData(1)
botLen = string.len( botName )
local i = 0 -- add the serial botnames in here as well.. so the user doesn't think he is flooded by one person
for k,v in SearchFor do
for _,search in v do
-- add $Search
local s = "$Search Hub:"..botName..i.." "
if search[3] then
s = s.."T?F?"..search[3]
else
s = s.."F?F?0"
end
s = s.."?"..search[1].."?"..string.gsub( search[2], " ", "$" ).."|"
table.insert( SearchTable, s )
-- add $SR match
local idx = string.lower( search[2] )
ResultTable[idx] = { msg = k }
if search[4] then ResultTable[idx].regex = string.lower( search[4] ) end
-- next..
i = i + 1
end
end
st, SearchTypes, SearchFor = nil, nil, nil

-- set options
if opchatName then
messageFunc = SendToOps
else
messageFunc = SendPmToOps
opchatName = botName
end
if useTimer then SetTimer(timerValue) StartTimer() end
end

-- on new user
function NewUserConnected( client )
table.foreachi(SearchTable, function(_, v) client:SendData( v ) end)
end

-- on $SR
function DataArrival( client, line )
local match = nil
if string.sub( line, 1, 4 ) == "$SR " then
-- test if it was a result to us only
local ret,c,to = string.find( line, "\005([^\005|]*)|$" )
if ret and string.sub( to, 1, botLen ) == botName then
local ret,c,file,size = string.find( line, "^%$SR [^ ]+ ([^\005]*)\005([0-9]+) " )
if ret then
file = string.lower( file )
for k,v in ResultTable do
if ( v.regex and string.find( file, v.regex ) ) or ( not v.regex and string.find( file, k, 1, 1 ) ) then
match = 1
-- warn( client, file.." ("..dchpp.formatBytes( size ).." ("..size.."))", v.msg )
warn( client, file.." ("..size..")", v.msg )
end
end
end
end
end
-- disconnect user
if match and disconnectUser and not client.bOperator then
client:SendData( "<"..botName.."> You are being kicked" )
client:Disconnect()
return 1
end
end

function warn( client, file, response )
-- send message to user
client:SendData( "<"..botName.."> You are sharing the following file: "..file..": "..response )
if client.bOperator then return end
message = client.sName.." shares: "..file
-- send message to all Operators
messageFunc( opchatName, message )
end

function OnTimer()
if SearchTable.n < 1 then return end
SendToAll(SearchTable[counter])
counter = counter + 1
if counter > SearchTable.n then counter =1 end
end

Title:
Post by: [UK]Madman on 04 April, 2005, 15:13:41
Looking quickly, it seems that all you need to do is change DataArrival  to SRArrival
Title:
Post by: Typhoon on 04 April, 2005, 18:14:55
frmHub:EnableSearchData()
  and
  frmHub:EnableFullData()


is removed in new PtokaX version.. it's enabled all the time now , should states the same in the ChangeLog :)



Typhoon?
Title:
Post by: Stravides on 04 April, 2005, 23:07:26
manay thanks for the replies - I tried to use SRArrival in the script and connected with lots of *cough* dodgy files and it never picked up one - i stayed in the hub for 5 hours and the timer was set to 10 mins :)

maybe I'm not doing this right

instead of

function DataArrival( client, line )

i'm using
function SRArrival( client, line )

many thanks ?? can someone else test it or am i just going mad :)

it says
Syntax ...ILES\HUBS\RPGBooks Cymru LUA 5\scripts\filechker.lua:179: attempt to compare nil with number

ie this line -->   if SearchTable.n < 1 then return end            
Title:
Post by: TTB on 04 April, 2005, 23:15:34
I'm testing it now...

*edit* Got a bug >> Syntax ...r ===---\DVD HUB ADSL\TESTHUB5\scripts\badfiles3.lua:178: attempt to compare nil with number
Title:
Post by: Stravides on 04 April, 2005, 23:53:31
ok Fixed it...

replace
function OnTimer()
if SearchTable.n < 1 then
return
end
SendToAll(SearchTable[counter])
counter = counter + 1
if counter > SearchTable.n then
counter =1
end
end
with
function OnTimer()
if table.getn(SearchTable) < 1 then
return
end
SendToAll(SearchTable[counter])
counter = counter + 1
if counter > table.getn(SearchTable) then
counter =1
end
end

Simple when ya think about it :)  DOH !!!

many thanks just for being here i think...
Title:
Post by: TTB on 05 April, 2005, 00:02:17
LOL!

Ghehe... well... *copy* *paste* and also trying  :D

I will keep my progress also updated here!
Title:
Post by: Stravides on 05 April, 2005, 00:15:37
They say two heads are better than one - imagine how happy a kid with acne must be :)
Title:
Post by: TTB on 05 April, 2005, 00:18:22
LoLz  :D


Well.. it's weird, but the script doesn't do anything in my testhub...

I share a renamed TXT >> incest.avi.

Mhh... still waiting
Title: Ok it works Active now Passive anyone ???
Post by: Stravides on 05 April, 2005, 02:17:50
OK we've now tested that - it appears to only search the ACTIVE users - any idea how to open its eyes to the passive users also ??

any help gladly appreciated...

Stravides