PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: frankyk on 18 March, 2004, 00:12:40

Title: Help with this script
Post by: frankyk on 18 March, 2004, 00:12:40
Bot = "School-Check"


function Main()

frmHub:RegBot(Bot)

end



function NewUserConnected(user, data)

local s,e,a,b,c,d = strfind(user.sIP, "(%d+).(%d+).(%d+).(%d+)")

if ("169.232." == a.."."..b..".") then

if not (strsub(user.sName,1,6) == "[ucla]" or strsub(user.sName,1,6)=="[UCLA]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end

elseif ("128.54." == a.."."..b..".") then

if not (strsub(user.sName,1,6) == "[ucsd]" or strsub(user.sName,1,6)=="[UCSD]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end


elseif ("169.229." == a.."."..b..".") then

if not (strsub(user.sName,1,6) == "[ucb]" or strsub(user.sName,1,6)=="[UCB]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end


elseif ("128.155." == a.."."..b..".") then

if not (strsub(user.sName,1,6) == "[usc]" or strsub(user.sName,1,6)=="[USC]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end


elseif ("169.233." == a.."."..b..".") then

if not (strsub(user.sName,1,6) == "[ucsc]" or strsub(user.sName,1,6)=="[UCSC]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end


elseif ("120." == a..".") then

if not (strsub(user.sName,1,6) == "[usd]" or strsub(user.sName,1,6)=="[USD]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")

end

end

end


What additional script would I have to add to make this bot BAN people whose IP address don't match their nickname.  Also, how come the bot would 'speak up' when sometimes an IP address matches the nickname format?
Title:
Post by: nErBoS on 18 March, 2004, 00:33:12
Hi,

Hope it helps..

Bot = "School-Check"


function Main()

frmHub:RegBot(Bot)

end



function NewUserConnected(user, data)

local s,e,a,b,c,d = strfind(user.sIP, "(%d+).(%d+).(%d+).(%d+)")

if ("169.232." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucla]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCLA] ha entered the Hub.")

end

elseif ("128.54." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSD] ha entered the Hub.")


end


elseif ("169.229." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucb]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCB] ha entered the Hub.")


end


elseif ("128.155." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[usc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USC] ha entered the Hub.")


end


elseif ("169.233." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSC] ha entered the Hub.")


end


elseif ("120." == a..".") then

if not (strsub(strlower(user.sName),1,6) == "[usd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USD] ha entered the Hub.")


end

end

end

Best regards, nErBoS
Title:
Post by: plop on 18 March, 2004, 01:34:33
you are forgetting about harry potter, aka magic.
check here (http://board.univ-angers.fr/thread.php?threadid=763&boardid=4&styleid=1) for how 2 solve this.

plop
Title:
Post by: nErBoS on 18 March, 2004, 02:00:09
Hi,

Plop great manual on magical caracters, i am a little sleepy here, i found a bug on user.sName that have only 5 caracters corrected that, was this what you ment ??

Bot = "School-Check"


function Main()

frmHub:RegBot(Bot)

end



function NewUserConnected(user, data)

local s,e,a,b,c,d = strfind(user.sIP, "(%d+).(%d+).(%d+).(%d+)")

if ("169.232." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucla]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCLA] ha entered the Hub.")

end

elseif ("128.54." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSD] ha entered the Hub.")


end


elseif ("169.229." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,5) == "[ucb]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCB] ha entered the Hub.")


end


elseif ("128.155." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,5) == "[usc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USC] ha entered the Hub.")


end


elseif ("169.233." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSC] ha entered the Hub.")


end


elseif ("120." == a..".") then

if not (strsub(strlower(user.sName),1,5) == "[usd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USD] ha entered the Hub.")


end

end

end

Please instructe me :)

Best regards, nErBoS
Title:
Post by: plop on 18 March, 2004, 02:51:18
QuoteOriginally posted by nErBoS
Hi,

Plop great manual on magical caracters, i am a little sleepy here, i found a bug on user.sName that have only 5 caracters corrected that, was this what you ment ??

Please instructe me :)

Best regards, nErBoS
nope, it's about this part.
local s,e,a,b,c,d = strfind(user.sIP, "(%d+).(%d+).(%d+).(%d+)")
the . matches anything so you should escape it 2 be safe as it can return bad vallue's.

plop
Title:
Post by: frankyk on 18 March, 2004, 03:01:37
Is the script Nerbos wrote completed?  I used the initial script which seemed to be decent, what is wrong with it?
Title:
Post by: nErBoS on 18 March, 2004, 12:40:11
Hi,

Thanks plop you are right, problem solved, have to pay more atention to that.

frankyk this one is ok..

Bot = "School-Check"


function Main()

frmHub:RegBot(Bot)

end



function NewUserConnected(user, data)

local s,e,a,b,c,d = strfind(user.sIP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")

if ("169.232." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucla]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCLA] ha entered the Hub.")

end

elseif ("128.54." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSD] ha entered the Hub.")


end


elseif ("169.229." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,5) == "[ucb]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCB] ha entered the Hub.")


end


elseif ("128.155." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,5) == "[usc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USC] ha entered the Hub.")


end


elseif ("169.233." == a.."."..b..".") then

if not (strsub(strlower(user.sName),1,6) == "[ucsc]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [UCSC] ha entered the Hub.")


end


elseif ("120." == a..".") then

if not (strsub(strlower(user.sName),1,5) == "[usd]") then

SendToAll(Bot, "The user "..user.sName.." is not from the right school, change your tag!")
user:Ban()
else
SendToAll(Bot, "The user "..user.sName.." from [USD] ha entered the Hub.")


end

end

end

Best regards, nErBoS
Title:
Post by: plop on 19 March, 2004, 19:33:55
QuoteOriginally posted by frankyk
Is the script Nerbos wrote completed?  I used the initial script which seemed to be decent, what is wrong with it?
was just a potential problem, didn't cause any error @ all but wasn't nice either.
nerbos is trying 2 learn lua thats why i only gave the hints so he had 2 fix it himself.
he used a . 2 search for the . in the ip's, but this can cause a problem because . means in lua that any character is ok.
in the last version he altered it 2 %. which means: search for a explicit .
make sure you run the last version he posted so you don't run into that potential problem.

QuoteOriginally posted by nErBoS
Hi,

Thanks plop you are right, problem solved, have to pay more atention to that.

Best regards, nErBoS

yw.
i made the same mistake in the past also, and it can be really confusing when it happens.
you should now be safe from mistakes like that.

plop