Hello there :)
I need a script that blocks passive unregistered users from search ( just search ) download i don't care about :), to save bandwidh, like http://forum.ptokax.org/index.php?topic=6779.0
But even if i try to convert that one, it works for some minutes and then i get errors
Or if someone has any other suggestions, i would love to get some tips
thanks in advance
What errors do you get exactly? Could you please post the converted code as well?
--Block passive search for unregistered users, made by Mutor
sBot = "SomeHubsBot"
sFeedNick = "Owner"
SearchArrival = function (user, data)
if not RegMan.GetReg(user.sNick) and not user.bActive then
local s,e,search = string.find(data,"([^%?]+)|$")
local res = "Unknown Path"..string.char(92)..user.sNick..", search is disabled for you :P Only active users can search, type +active (Or register yourself)"..string.rep(" ",350)..search
Core.SendToNick(user.sNick,"$SR "..SetMan.GetString(21).." "..res.." 0 0/0"..
SetMan.GetString(0).." ("..Core.GetHubIP()..":"..SetMan.GetString(4)..")")
Core.SendPmToNick(sFeedNick, sBot, user.sNick.. " with ip " ..user.sIP.. " is trying to search in passive mode ")
return true
end
end
and the error is attemt to concatenate local search a nil value
Oh yeah, you just have to replace string.find to string.match.
Well, i must be lost in space, but still same error in line:
local res = "Unknown Path"..string.char(92)..user.sNick..", search is disabled for you :P Only active users can search, type +active (Or register yourself)"..string.rep(" ",350)..search
Trying that one right now, thanks bastya_elvtars and Mutor
It looks like it's affecting active users to thou, they starting to register.
and if i search in passive mode and then switch to active, i get the blocked message, but when i register, it goes away.
But i'm going to test it more
It affects active users to, any suggestions ?
Nah, it's still affects active users to, switched to Mutors regme for now and reg for search and download
dunno what's wrong
A fix for you.
--[[
Passive search block, by Mutor
Blocks search for unregistered passive users
Returns fraudulent search result.
]]
OnStartup = function()
h,b,i,u = SetMan.GetString(0),SetMan.GetString(21),SetMan.GetString(3):gsub(";.*",""),SetMan.GetString(4)
t,bot = "TTH:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",SetMan.GetString(21)
end
SearchArrival = function (user,data)
local p,n = user.iProfile,user.sNick
if p == -1 and Core.GetUserValue(user,0) ~= "A" then
local _,_,search = string.find(data,"([^?]+)|$")
if search then
local res = "Unknown Path"..string.char(92)..n..", search is "..
"disabled for you :P "..string.rep("\t",15)..search
return Core.SendToUser(user,"$SR "..b.." "..res.." 0 1/2"..t.." ("..i..":"..u..")|"..
"<"..bot.."> "..n..", search is disabled for you. Please close the "..
string.format("%q",search:gsub("%$"," ")).." search window. Thank you.|"),true
end
return true
end
end
Well, I don't know what was wrong, but now it looks like it's working.
Many thanks to both of you
Mutor, you were using Core.GetUserData and the correct one would have been Core.GetUserValue. This was the only thing I have changed in your script.