PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: OpiumVolage on 10 October, 2003, 23:36:19

Title: SearchKicker
Post by: OpiumVolage on 10 October, 2003, 23:36:19
A SearchKicker.

-- 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 = "-TropiCo-" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
opchatName = nil -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
mb = 1024 * 1024
gb = 1024 * mb
-- Timer value, will send search for 1 of the file on all users at each timer
timerValue = 10*1000 -- Every 10 seconds (higher value will reduce load)
useTimer = 1 -- set to 1 to enable timer functions
counter = 1
--// do not modify this table, lookup the meanings in the $Search section in the protocol documentation
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 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 = strlen( 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].."?"..gsub( search[2], " ", "$" ).."|"
tinsert( SearchTable, s )
-- add $SR match
local idx = strlower( search[2] )
ResultTable[idx] = { msg = k }
if search[4] then ResultTable[idx].regex = strlower( 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 )
foreachi(SearchTable, function(_, v) %client:SendData( v ) end)
end

-- on $SR
function DataArrival( client, line )
local match = nil
if strsub( line, 1, 4 ) == "$SR " then
-- test if it was a result to us only
local ret,c,to = strfind( line, "\005([^\005|]*)|$" )
if ret and strsub( to, 1, botLen ) == botName then
local ret,c,file,size = strfind( line, "^%$SR [^ ]+ ([^\005]*)\005([0-9]+) " )
if ret then
file = strlower( file )
for k,v in ResultTable do
if ( v.regex and strfind( file, v.regex ) ) or ( not v.regex and strfind( 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: Dyzan on 15 October, 2003, 20:53:06
Nice Script.

Just testing the new forum =)

/Dyzan

PS: Great to se you all again!
Title:
Post by: Typhoon on 15 October, 2003, 21:09:17
OpiumVolage . this script is for DCH++ .. which i think are using LUA 5.0  .. and not LUA 4.0 as PtokaX does.

so its quite useless!...if i am right
Title:
Post by: OpiumVolage on 16 October, 2003, 09:54:11
Was for DCH++ ;)

-- Translated back to PtokaX (OpiumVolage 9 Sept. 2003)
-- Added timer for automating search
Title:
Post by: Roy on 16 October, 2003, 10:18:14
Very nice, im gonna "steal" some of them installed filenames and put them in the forbidden files ADL search of DC++k


Roy
Title:
Post by: [ES]latinmusic on 23 October, 2003, 15:12:43
What i miss here is the path, this script does not return the path where the file is stored, the user with troubles must be notified about the name of the file, its extension and the path where the file is stored.
This script must contained the following lines i think:
if( strsub(data, 1, 3) == "$SR" ) then
**etc, etc**
local path = strsub(data, s, e)
*etc, etc**
user:SendData(BotName, **etc, etc**)
user:SendData(BotName, "Path: "..path.. ".")
Those lines not work, is only for documentation.
Title: Connecting as passive makes the script...
Post by: Corsari on 27 November, 2003, 17:43:48
... fail.

I use DC++. I've noticed that connecting as passive makes you to be untouched by the script.

This is somethign I've seen also with a similar script.
As example, we don't want .avi files shared. But all the passive users with .avi files are connecting and not affected by the check/disconnect done by scripts.

Is it a Ptokax bug? Or what?

Anyway as test, I'm running the hub and the client on the same pc. Does this work? Is it an active/passive hub issue?

Do I need to forward any additonal port other than 411 both TCP and UDP (I use 411 on the actual hub)?

Do you know why?

Thank you for any answer

Robert
Title:
Post by: plop on 27 November, 2003, 19:13:19
QuoteOriginally posted by Corsari
... fail.

I use DC++. I've noticed that connecting as passive makes you to be untouched by the script.

This is somethign I've seen also with a similar script.
As example, we don't want .avi files shared. But all the passive users with .avi files are connecting and not affected by the check/disconnect done by scripts.

Is it a Ptokax bug? Or what?

Anyway as test, I'm running the hub and the client on the same pc. Does this work? Is it an active/passive hub issue?

Do I need to forward any additonal port other than 411 both TCP and UDP (I use 411 on the actual hub)?

Do you know why?

Thank you for any answer

Robert
port 413 is used 2 search pasive users.

plop
Title:
Post by: [G-T-E]Gate? on 01 December, 2003, 23:59:22
Y am I getting the following responce
>> Syntax Error: attempt to call field `EnableSearchData' (a nil value)

Tks ...
Title:
Post by: plop on 02 December, 2003, 00:45:41
QuoteOriginally posted by [G-T-E]Gate?
Y am I getting the following responce
>> Syntax Error: attempt to call field `EnableSearchData' (a nil value)

Tks ...
this thread should be moved, the script is for 0.3.2.6.
you get that error when you try 2 run it on earlyer versions of ptokax.

plop
Title:
Post by: [G-T-E]Gate? on 02 December, 2003, 01:30:17
Strange ..
 Iam am running PtokaX 326 TD3
Title:
Post by: plop on 02 December, 2003, 01:47:24
QuoteOriginally posted by [G-T-E]Gate?
Strange ..
 Iam am running PtokaX 326 TD3
not really check the changelog from TD4.
- added frmHub:EnableSearchData() and frmHub:EnableFullData() to LUA (more in Scripting.txt)
thats where it was added.

plop
Title:
Post by: Joker on 09 December, 2003, 10:38:20
Hi.

I tryed script and i like it.  :]  Thank you OpiumVolage.

I think you neet to add there:
frmHub:RegBot(botName)

Is it possible to someone help me to add SU+ profile in this script. I need messages to be send to SU+ , not to all OP:s . I tryed it , but i faild.   :(    

I think  i need part like this added in the script:
function SendPmTo(profile, client, file, response)
local table = GetUsersByProfile(profile)
for id, name in table do SendPmToNick(name, client, file, response) end
end

SendPmTo("SU+",  "<"..botName.."> You are sharing the following file: "..file..": "..response)


Or something like that.  ?(

Can anyone please help me  to add this kind function in this FileChecker script.

Thanx.
Title:
Post by: OpiumVolage on 09 December, 2003, 13:09:43
The part sending messages is:
if opchatName then
messageFunc = SendToOps
else
messageFunc = SendPmToOps
opchatName = botName
end

So you nee to find messageFunc and replace by call to function you need (Dirty hack) or define your own messageFunc ;))
Title:
Post by: IceCoder on 09 December, 2003, 14:01:04
Good one Opium :p
Title: hum..
Post by: mOrrI on 09 December, 2003, 14:02:32
Does this script works good in...
version 0.3.2.6 TestDrive 4?????

And how can i see the invalid files and add more invalid files ? thanks :)
Title:
Post by: OpiumVolage on 09 December, 2003, 14:32:35
Yes this script is for TD4, i haven't tested it much but original script is really good.

For the invalid files:
--// MODIFY THIS TABLE <-------
--      { searchType, words[, minimumSize[, regexMatch]] }

searchType is type of the search defined in the first table,
words: What to search

the two others are optionnal

minimumSize: self explainatory ;)
regexMatch: a regex to match with returned results.
Title: hum...
Post by: mOrrI on 09 December, 2003, 20:17:22
i think i get the picture fromt he examples in the bot :)

NICE BOT :)

this is the stuff!!!!

Warning who has S**T in the share :)
Title:
Post by: Savage-XP on 09 December, 2003, 22:59:26
Yes Morri, it works great! :))
Title:
Post by: Neospider69 on 11 December, 2003, 03:16:04
hehehehe

Savage-XP & Morri (sem saber)

N?o v?o come?ar em despiques aqui tb, pois n?

You aren?t going to start in a kind of wrestling here, are you?
Title: hum...
Post by: mOrrI on 11 December, 2003, 04:31:46
i really don't know u 2..
Title:
Post by: acethecase on 11 December, 2003, 19:15:59
Hiya...

Is it posible for scrip to ignore"not to check" Owner,SU,OP,VIP
BUT still to check Users,Guest..
I know it?s posible but dont now how to whrite it in scrip.

And if it is posible to make implant that user get?s 3 times
warning and after 3 times have been warned and still have not fix files, then user get kick?or ban!

TnX foR ur Help!!

Cya
Title:
Post by: anubis_say on 09 January, 2004, 12:09:59
HI!

If i want just kick those users, who sharing not  good files, what can i do?
Title: well...
Post by: mOrrI on 09 January, 2004, 16:56:35
well i can try and see the profile thing and the kick thing...

when i get home :p
Title:
Post by: anubis_say on 10 January, 2004, 14:07:07
go home fast :]
Title: ehehhehe
Post by: mOrrI on 10 January, 2004, 22:26:46
For the Kick part:


-- 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 ;) )


Check the Script :)
Title: Search Kicker
Post by: Cp6uja on 07 June, 2004, 11:03:50
Nice Script
--==>I need this script !!!
YuHuuuuuuuu<==--
Title: Hi !!!
Post by: Cp6uja on 07 June, 2004, 19:30:26
it works great !!!
Nice-very nice
Title:
Post by: sander815 on 06 April, 2005, 16:17:35
how do i get this script to report in opchat?
i added this:
--// useful stuff

botName = "--FilECheckEr--"

disconnectUser = nil -- disconnect the user, nil = don't

-- opchatName = "-FilECheckEr-" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil

opchatName = "-FilECheckEr-" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil

and restrated the script, but it still reports in mainchat
Title:
Post by: electronic_Psycho on 06 April, 2005, 16:23:22
Hi sander815 ..   :)

you need oNly To put your op chate name ..
---------------------------------
-- opchatName = "Your op chat name" -- set opchat nick here if
---------------------------------
opchatName = "Your op chat name" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil?>


 ;)
Title:
Post by: jiten on 06 April, 2005, 18:16:56
QuoteOriginally posted by electronic_Psycho
Hi sander815 ..   :)

you need oNly To put your op chate name ..
---------------------------------
-- opchatName = "Your op chat name" -- set opchat nick here if
---------------------------------
opchatName = "Your op chat name" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil?>


 ;)

Yups, something like:

opchatName = frmHub:GetOpChatName()
Title:
Post by: Stravides on 06 April, 2005, 23:26:25
Yea I tried this and am using a modded version -but doesnt this only check ACTIVE users ???
Title:
Post by: sander815 on 07 April, 2005, 08:43:02
ok, i thought i had to set the nick for the bot there

now i entered my opchatname, but i still see all the msgs in mainchat:
<--OpChat--> xxx shares: dc\phg\uv100dcl\unidk\win16\setup.exe (44608)

i want them in opchat, not in mainchat
Title:
Post by: ConejoDelMal on 07 April, 2005, 08:56:03
Just change this:
-- opchatName = "-TropiCo-" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
opchatName = nil -- set opchat nick here if you want messages to opchat instead of mainchat, else nil

for this:
opchatName = "--OpChat--" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
--opchatName = nil -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
Title:
Post by: jiten on 07 April, 2005, 11:04:55
Well, I think it should be like this for u to receive the messages in PM:

botName = "--OpChat--"
--opchatName = "--OpChat--" -- set opchat nick here if you want messages to opchat instead of mainchat, else nil
opchatName = nil -- set opchat nick here if you want messages to opchat instead of mainchat, else nil

Best regards.