Help with this script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Help with this script

Started by frankyk, 18 March, 2004, 00:12:40

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

frankyk

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?

nErBoS

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
--## nErBoS Spot ##--

plop

you are forgetting about harry potter, aka magic.
check here for how 2 solve this.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

nErBoS

#3
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
--## nErBoS Spot ##--

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

frankyk

Is the script Nerbos wrote completed?  I used the initial script which seemed to be decent, what is wrong with it?

nErBoS

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
--## nErBoS Spot ##--

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk