PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Request for scripts => Topic started by: Scanning on 10 April, 2010, 19:08:55

Title: Block passive unregistered users
Post by: Scanning on 10 April, 2010, 19:08:55
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
Title: Re: Block passive unregistered users
Post by: bastya_elvtars on 10 April, 2010, 19:24:53
What errors do you get exactly? Could you please post the converted code as well?
Title: Re: Block passive unregistered users
Post by: Scanning on 10 April, 2010, 19:32:15

--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
Title: Re: Block passive unregistered users
Post by: bastya_elvtars on 10 April, 2010, 20:27:28
Oh yeah, you just have to replace string.find to string.match.
Title: Re: Block passive unregistered users
Post by: Scanning on 10 April, 2010, 20:46:59
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
Title: Re: Block passive unregistered users
Post by: Scanning on 10 April, 2010, 22:29:57
Trying that one right now, thanks bastya_elvtars and Mutor
Title: Re: Block passive unregistered users
Post by: Scanning on 10 April, 2010, 22:58:54
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 ?
Title: Re: Block passive unregistered users
Post by: Scanning on 12 April, 2010, 21:51:24
Nah, it's still affects active users to, switched to Mutors regme for now and reg for search and download

dunno what's wrong
Title: Re: Block passive unregistered users
Post by: bastya_elvtars on 12 April, 2010, 22:01:11
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
Title: Re: Block passive unregistered users
Post by: Scanning on 13 April, 2010, 12:27:23
Well, I don't know what was wrong, but now it looks like it's working.

Many thanks to both of you
Title: Re: Block passive unregistered users
Post by: bastya_elvtars on 13 April, 2010, 17:41:23
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.