Aim: This bot tries to guess the videos shared by a new user, and kicks him off, if it's below 3gb. Its a *shitty* hack of an old search kick script I picked up here.
Status: I'm making it search for 9 video and 1 mp3 types. The MP3 search is more like a terminating condition. The moment MP3 results come in, we evaluate whether the user has shared enough data or not. The *hitch* being that the bot NEVER fetches more than 20 search results. Hence it never gets to the mp3 search results( at which pt it'd terminate,plus we assume that any user will have one mp3 atleast )
Any workarounds?
Here is the code:
--Borrowed from FileCheck
--// useful stuff
botName = "FileCheck"
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
iter = 0 -- initialize this counter for each video type search
-- Timer value, will send search for 1 of the file on all users at each timer
timerValue = 50*1000 -- Every 10 seconds (higher value will reduce load)
useTimer = 1 -- set to 1 to enable timer functions
minVideos = 3 * gb -- minimum 3gb of videos must be shared
sharesize = 0 -- set this to zero at every Iteration.
vidTypes = 10 -- How many video types do we deal with?
-- FIXME -includes the last dummy wmf as a termination condition
prevBot = "0" -- Which was the latest sub-bot we received data from?
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 = {
["You're NOT sharing enough videos!"] = {
{ st.VIDEO, ".avi", "avi$" },
{ st.VIDEO, ".mpeg","mpeg$"},
{ st.VIDEO, ".mov", "mov$" },
{ st.VIDEO, ".mpg", "mpg$" },
{ st.ANY , ".dat", "dat$" },
{ st.VIDEO, ".asf", "asf$" },
{ st.ANY, ".divx", "divx$" },
{ st.VIDEo, ".wmv", "wmv$" },
{ st.ANY, ".vob", "vob$" },
{ st.ANY, ".mp3", "mp3$" },
},
}
--// convert the tables
SearchTable = {}
ResultTable = {}
function Main()
frmHub:RegBot(botName)
frmHub:EnableSearchData(1)
botLen = strlen( botName )
prevBot = "Blah"
local i = 0 -- add the serial botnames in here as well.. so the user doesn't think he is flooded by one person
iter = 0
for k,v in SearchFor do
for _,search in v do
-- add $Search
local s = "$Search Hub:"..botName..i.." "
s = s.."F?F?0"
-- Removed the size criterion
s = s.."?"..search[1].."?"..gsub( search[2], " ", "$" ).."|"
tinsert( SearchTable, s )
-- add $SR match
local idx = strlower( search[2] )
ResultTable[idx] = { msg = k }
if search[3] then ResultTable[idx].regex = strlower( search[3] ) 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 )
sharesize = 0
iter = 0
prevBot = "FileCheck0"
foreachi(SearchTable, function(_, v) %client:SendData( v ) end)
end
-- on $SR
function DataArrival( client, line )
--client:SendData("Checking botID as:"..prevBot.." presently at "..(sharesize/gb).." Gbytes")
local ret,c,to = strfind( line, "\005([^\005|]*)|$" )
if ( to ~= prevBot ) then
prevBot = to
end
local match = nil
local gigs = 0
local curr_bot = prevBot
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
--unlike prev bot, here we must ADD the sizes!
match = 1
sharesize = sharesize + size
--warn( client, file.." ("..(size/mb).." MB)", " " ) --earlier was v.msg
end
end
end
end
end
--debug
iter = iter + 1
client:SendData( ": presently at "..(sharesize/gb).." Gbytes")
-- disconnect user
if sharesize > minVideos then
gigs = sharesize/ gb
client:SendData( "<"..botName.."> You have shared enough videos, "..gig2.." Gbytes.Welcome!!" )
return 1
end
if prevBot == "FileCheck10" then -- meaning we've searched for all files.
if (not match or sharesize < minVideos ) and not client.bOperator then
-- If client hasnt shared videos or lesser than minVideos, kick him
gigs = sharesize / gb
client:SendData( "<"..botName.."> You havent shared enough videos, only "..gigs.." Gbytes" )
client:Disconnect()
return 1
end --( not match )
gigs = sharesize / gb
client:SendData( "<"..botName.."> You have shared enough videos, only "..gig2.." Gbytes.Welcome!!" )
return 1
end -- for (iter==vidTypes)
end
function warn( client, file, response )
-- send message to user
client:SendData( "<"..prevBot.."> 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 )
SendPmToOps( opchatName, botName )
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
I've seen attempts on such scripts in the past. None worked... :-(
About the 20 search results... don't you always get MAX 5 results?
QuoteOriginally posted by klownietklowniet
I've seen attempts on such scripts in the past. None worked... :-(
About the 20 search results... don't you always get MAX 5 results?
Now that you mention .... yes, it was 5 per category like MPG/MPEG/DAT.
But how can this be overcome??
QuoteOriginally posted by devilixx
QuoteOriginally posted by klownietklowniet
I've seen attempts on such scripts in the past. None worked... :-(
About the 20 search results... don't you always get MAX 5 results?
Now that you mention .... yes, it was 5 per category like MPG/MPEG/DAT.
But how can this be overcome??
learn c++ and alter the source from dc++k.
in theory all you have 2 do is change forbidden files 2 allowed and add the sizes.
can't help you with that as i don't know c++ (want 2 learn it but no time).
plop
QuoteOriginally posted by plop
learn c++ and alter the source from dc++k.
in theory all you have 2 do is change forbidden files 2 allowed and add the sizes.
can't help you with that as i don't know c++ (want 2 learn it but no time).
plop
I just dont get this.
a. phatty told me to use dc++k myself. But what is it, where can I download, that I cannot find in searches. Can anyone PM me that?
b. Im working on PtokAx. Where did dc++k come into the picture then??
Care to explain further?
dc++k is a patched dc++ client.
it can automaticly check filelists for fake shares the moment a user connects 2 your hub.
beside fake shares it can search the whole share (it downloads the list) for bad files (junk and forbidden).
if you want a stable version (forbidden files doesn't fully work, so far i seen it report it 2x) just send a blanco email 2 dcplusplusK@plop.nl.
it will be send 2 you in a mather of minutes, inc a short manual, link 2 a full manual and homepage.
plop